Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1536010
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues |
| Date | 2016-12-05 12:30 +0100 |
| Message-ID | <sKZD4-3S7-5@gated-at.bofh.it> (permalink) |
| References | <sEWye-2tW-9@gated-at.bofh.it> <sEWye-2tW-29@gated-at.bofh.it> <sK85H-3yk-1@gated-at.bofh.it> <sKWYx-2e2-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Davidlohr Bueso <dave@stgolabs.net> - 2016-12-03 03:20 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Peter Zijlstra <peterz@infradead.org> - 2016-12-05 09:40 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Oleg Nesterov <oleg@redhat.com> - 2016-12-05 12:30 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Oleg Nesterov <oleg@redhat.com> - 2016-12-05 12:50 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Davidlohr Bueso <dave@stgolabs.net> - 2016-12-05 18:40 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Oleg Nesterov <oleg@redhat.com> - 2016-12-05 18:20 +0100
Re: [PATCH v2 2/3] locking/percpu-rwsem: Rework writer block/wake to not use wait-queues Oleg Nesterov <oleg@redhat.com> - 2016-12-05 18:20 +0100
csiph-web