Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1526753
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups |
| Date | 2016-11-21 16:10 +0100 |
| Message-ID | <sFYoh-2MJ-39@gated-at.bofh.it> (permalink) |
| References | <sEWye-2tW-9@gated-at.bofh.it> <sEWyf-2tW-55@gated-at.bofh.it> <sFVTr-18L-7@gated-at.bofh.it> <sFVTr-18L-5@gated-at.bofh.it> <sFWcN-1f8-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 11/21, Oleg Nesterov wrote: > > No, no, I meant that afaics both readers can see per_cpu_sum() != 0 and > thus the writer won't be woken up. Till the next down_read/up_read. > > Suppose that we have 2 CPU's, both counters == 1, both readers decrement. > its counter at the same time. > > READER_ON_CPU_0 READER_ON_CPU_1 > > --ctr_0; --ctr_1; > > if (ctr_0 + ctr_1) if (ctr_0 + ctr_1) > wakeup(); wakeup(); > > Why we can't miss a wakeup? > > This patch doesn't even add a barrier, but I think wmb() won't be enough > anyway. And in fact I am not sure this optimization makes sense... But it would be nice to avoid wake_up() when the writer sleeps in rcu_sync_enter(). Or this is the "slow mode" sem (cgroup_threadgroup_rwsem). I need to re-check, but what do you think about the change below? Oleg. --- x/kernel/locking/percpu-rwsem.c +++ x/kernel/locking/percpu-rwsem.c @@ -103,7 +103,9 @@ void __percpu_up_read(struct percpu_rw_s __this_cpu_dec(*sem->read_count); /* Prod writer to recheck readers_active */ - wake_up(&sem->writer); + smp_mb(); + if (sem->readers_block) + wake_up(&sem->writer); } EXPORT_SYMBOL_GPL(__percpu_up_read);
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -tip 0/3] locking/percpu-rwsem: writer-side optimizations Davidlohr Bueso <dave@stgolabs.net> - 2016-11-18 20:00 +0100
[PATCH 1/3] locking/percpu-rwsem: Move text file into Documentation/locking/ Davidlohr Bueso <dave@stgolabs.net> - 2016-11-18 20:00 +0100
[PATCH 2/3] locking/percpu-rwsem: Replace bulky wait-queues with swait Davidlohr Bueso <dave@stgolabs.net> - 2016-11-18 20:00 +0100
Re: [PATCH 2/3] locking/percpu-rwsem: Replace bulky wait-queues with swait Oleg Nesterov <oleg@redhat.com> - 2016-11-21 14:00 +0100
Re: [PATCH 2/3] locking/percpu-rwsem: Replace bulky wait-queues with swait Davidlohr Bueso <dave@stgolabs.net> - 2016-11-21 18:30 +0100
[PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Davidlohr Bueso <dave@stgolabs.net> - 2016-11-18 20:00 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Peter Zijlstra <peterz@infradead.org> - 2016-11-21 13:30 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Oleg Nesterov <oleg@redhat.com> - 2016-11-21 13:50 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Oleg Nesterov <oleg@redhat.com> - 2016-11-21 16:10 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Davidlohr Bueso <dave@stgolabs.net> - 2016-11-22 05:00 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Oleg Nesterov <oleg@redhat.com> - 2016-11-23 15:50 +0100
Re: [PATCH 3/3] locking/percpu-rwsem: Avoid unnecessary writer wakeups Oleg Nesterov <oleg@redhat.com> - 2016-11-21 13:30 +0100
csiph-web