Messages in this thread | | | Date | Mon, 5 Dec 2016 12:26:36 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues |
| |
Davidlohr, Peter, I'll try to read this patch later, just one note.
On 12/05, Peter Zijlstra wrote: > > On Fri, Dec 02, 2016 at 06:18:39PM -0800, Davidlohr Bueso wrote: > > @@ -102,8 +103,13 @@ void __percpu_up_read(struct percpu_rw_semaphore *sem) > > */ > > __this_cpu_dec(*sem->read_count); > > > > + rcu_read_lock(); > > + writer = rcu_dereference(sem->writer); > > Don't think this is correct, I think Oleg suggested using > task_rcu_dereference(), which is a giant pile of magic.
Yes, but on a second thought task_rcu_dereference() won't really help, but we can just use rcu_dereference().
> The problem is that task_struct isn't RCU protected as such.
Yes. But percpu_down_write() should not be used after exit_notify(), so we can rely on rcu_read_lock(), release_task()->call_rcu(delayed_put_task_struct) can't be called until an exiting task passes exit_notify().
But then we probably need WARN_ON(current->exit_state) in percpu_down_write().
And personally I think this change should add the new helpers, they can have more users. Something like
struct xxx { struct task_struct *task; };
xxx_wake_up(struct xxx *xxx) { rcu_read_lock(); task = rcu_dereference(xxx->task); if (task) wake_up_process(task); rcu_read_unlock(); }
#define xxx_wait_event(xxx, event) { // comment to explain why WARN_ON(current->exit_state);
xxx->task = current;
... }
Oleg.
| |