Messages in this thread | | | Date | Thu, 14 Mar 2013 08:20:31 -0700 | Subject | Re: [PATCH 11/12] rwsem: wake all readers when first waiter is a reader | From | Michel Lespinasse <> |
| |
On Thu, Mar 14, 2013 at 4:39 AM, Peter Hurley <peter@hurleysoftware.com> wrote: > On Thu, 2013-03-14 at 00:03 -0700, Michel Lespinasse wrote: >> > CPU 0 | CPU 1 >> > | >> > | down_write() >> > >> > ... CPU 1 has the write lock for the semaphore. >> > Meanwhile, 1 or more down_read(s) are attempted and fail; >> > these are put on the wait list. >> >> I'm not sure of the relevance of these other down_read() calls - >> please note that as these extra readers are put on the wait list, >> their +read_bias adjustments are canceled so that the count value >> ends up at write_bias + waiting_bias (for a total active count of 1) > > The relevance of the waiting readers is that when CPU 1 drops the writer > ___and grabs the spin lock___, it then wakes up these already-waiting > readers (CPU 0 is still parked in down_read_failed() waiting to acquire > the spin lock). > > When CPU 1 wakes up these readers, the sem count goes > 0 and the > waiting list is emptied. CPU 1 then drops the spin lock and leaves > up_write().
Ah, correct. So the race you noticed is real, and the one I found is just a more complicated way to hit it.
I'll add a fix in v2 of this patch series (probably later today).
BTW, you seem to have been paying pretty close attention, would you mind giving appropriate Reviewed-by tags when I send v2 ?
| |