Re: [PATCH v4 1/3] rcu-tasks: Add helpers to visit tasks on the exit lists
From: Ravindran, Binoy
Date: Mon Nov 30 2026 - 13:17:47 EST
On Mon, Nov 30, 2026, Paul E. McKenney wrote:
> OK, I will bite...
>
> Why not simply invoke synchronize_rcu_tasks(), after which any of the
> tasks that were missed will have already exited?
That was our first attempt, and it is not enough, for two reasons.
First, the task we miss can be in a quiescent state as far as RCU Tasks
is concerned. It is sleeping voluntarily in do_exit() after
exit_notify(), with a return address into the old patch's code on its
stack. A voluntary context switch is an RCU Tasks quiescent state, and
check_holdout_task() drops a holdout as soon as its nvcsw has changed,
so the grace period can end while the task is still asleep there. When
it wakes, it returns into freed text. With synchronize_rcu_tasks()
before the free of the replaced patch and a 2 s sleep injected after
exit_notify(), 5 of 6 runs still crashed.
Second, the problem is not only the free. The transition must not
switch a task while one of its frames is in a function being patched.
The invisible task is never checked, so klp_try_complete_transition()
can finish while the task still runs the old function, and the
consistency model is broken whether or not anything is freed. A wait
at free cannot repair that, since it runs after the transition has
already completed.
So the transition itself has to see these tasks and check their
stacks, which is what the rest of this series does. In v5, which I
plan to post this week, the two helpers in this patch are replaced by
a single walk of the exit lists that can drop the list lock, using the
same cursor scheme as rcu_tasks_postscan(). If you would prefer a
different interface on the RCU side, I am happy to rework it.
Thanks,
Binoy