Re: [PATCH 2/2] locking/rwsem: Wake up all readers for wait queue waker

From: Waiman Long
Date: Thu Feb 16 2023 - 16:08:16 EST


On 2/13/23 22:09, Hillf Danton wrote:
On Mon, 13 Feb 2023 14:48:32 -0500 Waiman Long <longman@xxxxxxxxxx>
@@ -1281,7 +1282,7 @@ static struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem)
raw_spin_lock_irqsave(&sem->wait_lock, flags);
if (!list_empty(&sem->wait_list))
- rwsem_mark_wake(sem, RWSEM_WAKE_READ_OWNED, &wake_q);
+ rwsem_mark_wake(sem, RWSEM_WAKE_READ_OWNED, &wake_q, false);
raw_spin_unlock_irqrestore(&sem->wait_lock, flags);
wake_up_q(&wake_q);
--
2.31.1
Downgrade is conceptually the right time to let all read waiters go
regardless write waiter.

Still, a downgraded task is still in the read critical section and we shouldn't introduce arbitrary latency to that. Let's focus on the easy one and we can discuss about other possibility later.

Thanks,
Longman