Re: [PATCH v3 tip/core/rcu 1/9] rcu: Add call_rcu_tasks()

Paul E. McKenney
2014-08-02T22:50:51Z

On Fri, Aug 01, 2014 at 08:57:53PM +0200, Oleg Nesterov wrote:
> On 07/31, Paul E. McKenney wrote:
> >
> > + rcu_read_lock();
> > + for_each_process_thread(g, t) {
> > + if (t != current && ACCESS_ONCE(t->on_rq) &&
> > + !is_idle_task(t)) {
> > + get_task_struct(t);
> > + t->rcu_tasks_nvcsw = ACCESS_ONCE(t->nvcsw);
> > + ACCESS_ONCE(t->rcu_tasks_holdout) = 1;
> > + list_add(&t->rcu_tasks_holdout_list,
> > + &rcu_tasks_holdouts);
> > + }
> > + }
> > + rcu_read_unlock();
>
> So let me repeat. for_each_process_thread() above can not (in general) see
> the exiting tasks which have already called exit_notify(), because such a
> task can be removed from rcu lists at any time.
>
> Now suppose that proc_exit_connector() is probed. Or another function which
> can be called after exit_notify(), this doesn't matter.
>
> An exiting task T jumps into trampoline and gets the preemption. It can be
> already (auto)reaped and removed from rcu lists.
>
> synchronize_rcu_tasks() can not see this task, so it can return before T gets
> a chance to resume.

Good catch!!!

So it looks like I will need to hook into do_exit() after all. Oh well,
can't have everything...

Thanx, Paul