Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-05 Thread Frederic Weisbecker
On Wed, Sep 04, 2019 at 11:20:03AM -0700, Linus Torvalds wrote: > On Wed, Sep 4, 2019 at 9:33 AM Frederic Weisbecker > wrote: > > > > I thought the point of these rcu_users was to be able to do: > > > > rcu_read_lock() > > p = rcu_dereference(task) > > if (!refcount_inc_not_zero(p->rcu_users)) {

Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-04 Thread Linus Torvalds
On Wed, Sep 4, 2019 at 9:33 AM Frederic Weisbecker wrote: > > I thought the point of these rcu_users was to be able to do: > > rcu_read_lock() > p = rcu_dereference(task) > if (!refcount_inc_not_zero(p->rcu_users)) { No. Because of the shared state, you can't do that from RCU context. But you

Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-04 Thread Frederic Weisbecker
On Wed, Sep 04, 2019 at 05:32:46PM +0200, Oleg Nesterov wrote: > On 09/04, Frederic Weisbecker wrote: > > > > So what happens if, say: > > > > > >CPU 1 CPU 2 > >-- > >rcu_read_lock() > >p =

Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-04 Thread Oleg Nesterov
On 09/04, Frederic Weisbecker wrote: > > So what happens if, say: > > >CPU 1 CPU 2 >-- >rcu_read_lock() >p = rcu_dereference(rq->task) >if (refcount_inc_not_zero(p->rcu_users)) { >

Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-04 Thread Frederic Weisbecker
On Mon, Sep 02, 2019 at 11:51:34PM -0500, Eric W. Biederman wrote: > > Add a count of the number of rcu users (currently 1) of the task > struct so that we can later add the scheduler case and get rid of the > very subtle task_rcu_dereference, and just use rcu_dereference. > > As suggested by

Re: [PATCH 1/3] task: Add a count of task rcu users

2019-09-04 Thread Oleg Nesterov
On 09/02, Eric W. Biederman wrote: > > @@ -900,10 +900,9 @@ static struct task_struct *dup_task_struct(struct > task_struct *orig, int node) > - /* > - * One for us, one for whoever does the "release_task()" (usually > - * parent) > - */ > + /* One for the user space

[PATCH 1/3] task: Add a count of task rcu users

2019-09-02 Thread Eric W. Biederman
Add a count of the number of rcu users (currently 1) of the task struct so that we can later add the scheduler case and get rid of the very subtle task_rcu_dereference, and just use rcu_dereference. As suggested by Oleg have the count overlap rcu_head so that no additional space in task_struct