Re: [PATCH 2/3] locking/percpu-rwsem: Replace bulky wait-queues with swait

From: Oleg Nesterov
Date: Mon Nov 21 2016 - 07:55:45 EST

On 11/18, Davidlohr Bueso wrote:
> @@ -12,7 +12,7 @@ struct percpu_rw_semaphore {
> struct rcu_sync rss;
> unsigned int __percpu *read_count;
> struct rw_semaphore rw_sem;
> - wait_queue_head_t writer;
> + struct swait_queue_head writer;

I won't argue, but even swait_queue_head is overkill in this case.

We can just add "struct task_struct *writer" into percpu_rw_semaphore,


writer = task_rcu_dereference(&sem->writer);
if (writer)

percpu_down_write() can set sem->writer == current and do the simple
while-not-condition-schedule() loop.

But this probably needs a couple of new helpers, and probably they
can have more users.