lkml.org 
[lkml]   [2019]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5/5] locking/percpu-rwsem: Remove the embedded rwsem
On Mon, Nov 18, 2019 at 03:19:35PM -0800, Davidlohr Bueso wrote:
> Similarly, afaict we can get rid of __percpu_up_read() and put the
> slowpath all into percpu_up_read(). Also explicitly mention the
> single task nature of the writer (which is a better comment for
> the rcuwait_wake_up()).

> static inline void percpu_down_read(struct percpu_rw_semaphore *sem)
> {
> @@ -103,10 +102,23 @@ static inline void percpu_up_read(struct percpu_rw_semaphore *sem)
> /*
> * Same as in percpu_down_read().
> */
> + if (likely(rcu_sync_is_idle(&sem->rss))) {
> __this_cpu_dec(*sem->read_count);
> + goto done;
> + }
> +
> + /*
> + * slowpath; reader will only ever wake a single blocked writer.
> + */
> + smp_mb(); /* B matches C */
> + /*
> + * In other words, if they see our decrement (presumably to
> + * aggregate zero, as that is the only time it matters) they
> + * will also see our critical section.
> + */
> + __this_cpu_dec(*sem->read_count);
> + rcuwait_wake_up(&sem->writer);
> +done:
> preempt_enable();
> }

Let me write that as a normal if () { } else { }.

But yes, that's small enough I suppose.

\
 
 \ /
  Last update: 2019-12-17 11:45    [W:0.051 / U:2.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site