Re: [PATCH 03/11] locking, rwsem: introduce basis for down_write_killable

From: Peter Zijlstra
Date: Thu May 12 2016 - 08:12:24 EST


On Wed, May 11, 2016 at 08:03:46PM +0200, Michal Hocko wrote:
> I still cannot say I would understand why the pending
> RWSEM_WAITING_BIAS matters but I would probably need to look at the code
> again with a clean head, __rwsem_wake is quite tricky...

Ah, you're asking why an unconditional __rwsem_wake(ANY) isn't enough?

Because; if at that point there's nobody waiting, we're left with an
empty list and WAITER_BIAS set. This in turn will make all fast paths
fail.

Look at rwsem_down_read_failed() for instance; if we enter that we'll
unconditionally queue ourself, with nobody left to come wake us.