Re: [PATCH v4 10/16] locking/rwsem: Wake up almost all readers in wait queue
From: Waiman Long
Date: Tue Apr 16 2019 - 13:37:44 EST
On 04/16/2019 12:50 PM, Davidlohr Bueso wrote:
> On Sat, 13 Apr 2019, Waiman Long wrote:
>> + * We limit the maximum number of readers that can be woken up for a
>> + * wake-up call to not penalizing the waking thread for spending too
>> + * much time doing it.
>> + */
>> +#define MAX_READERS_WAKEUPÂÂÂ 0x100
> Although with wake_q this is not really so... Could it at least be
> rewritten, dunno something like so:
> * Magic number to batch-wakeup waiting readers, even when writers
> * are also present in the queue. This both limits the amount of
> * work the waking thread must do (albeit wake_q)Â and also prevents
> * any potential counter overflow, however unlikely.
The wording looks good to me. Will modify that for the next version.
BTW, wake_q_add() has low overhead and so the lock hold time should be
short. Outside the wait_lock, wake_up_q() still has a high overhead if
there are many tasks to be woken up.