Re: [PATCH v4 1/3] rcu-tasks: Add helpers to visit tasks on the exit lists
From: Ravindran, Binoy
Date: Mon Nov 30 2026 - 19:29:26 EST
On Mon, Nov 30, 2026, Paul E. McKenney wrote:
> I instead suggest keeping your overall algorithm, including your walk
> of the tasks list, and replacing the call to your Tasks-RCU helper
> function with synchronize_rcu_tasks(). This does not wait for tasks
> with preemption disabled that are working towards their last call
> to schedule(), but those can be handled with a subsequent call to
> synchronize_rcu_tasks_rude().
Thanks, and sorry for misreading your first question. I see what you
mean now, and I tried the core of it.
The test kernel is v7.4-rc2 with that change and nothing else from our
series. The transition walks the task list as before, and it does not
walk the exit lists. Once every task it finds has switched,
klp_try_complete_transition() calls synchronize_rcu_tasks() and then
synchronize_rcu_tasks_rude(), just before the cleanup.
To trigger the race, a test-only hook makes exiting tasks sleep after
exit_notify(). Two livepatches that both replace do_exit() replace
each other in a loop, and the old module is removed each time.
With a 2 s sleep, all 12 runs crashed. In every run, an exiting task
woke up and went back into memory that the removed module had used.
That memory was unmapped, filled with int3 after the free, or already
holding the next module's code.
With a 20 ms sleep, all 12 runs finished their cycles, 120 in all,
without a fault. Without the two waits, the same 20 ms test crashed in
11 of 12 runs.
So the waits only delay the cleanup. A short sleep can end in time,
but a long one does not. The reason is that a task asleep in do_exit()
after exit_notify() is in an RCU Tasks quiescent state, so the grace
period does not wait for it. The rude flavor does not help either,
because it does not cover a sleeping task.
That is why the series has the transition find these tasks on the
exit lists and check their stacks, as it does for every other task.
Thanks,
Binoy