Messages in this thread |  | | Date | Tue, 17 Dec 2019 11:45:19 +0100 | From | Peter Zijlstra <> | Subject | Re: [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.
|  |