Re: [PATCH v2 2/3] livepatch: Include exiting tasks in the transition
From: Ravindran, Binoy
Date: Wed Nov 25 2026 - 18:09:12 EST
On Wed, Nov 25, 2026, Yafang Shao wrote:
> klp_exiting_try() is the only function ever passed as @fn, so does the
> callback indirection buy us anything? We could drop @fn and @arg and
> let klp_visit_exiting_tasks() return the result directly, which would
> also get rid of the "*(bool *)arg = false".
No, it does not. v3 replaces klp_visit_exiting_tasks() and
klp_exiting_try() with
static bool klp_try_switch_exiting_tasks(void)
which returns false if a task in the snapshot has not switched yet or
the snapshot was incomplete. It sits right before
klp_try_complete_transition(), so the forward declaration of
klp_try_switch_task() goes away too.
> Can we use synchronize_rcu() instead in the two places this series
> adds, the same way rcu_tasks_postgp() does?
Yes. Both waits only cover the do_exit() tail after
exit_tasks_rcu_finish(), which runs with preemption disabled, in normal
kernel context, until the final schedule(). synchronize_rcu() waits for
that region, which is exactly what rcu_tasks_postgp() relies on, and I
agree that the "RCU is not watching" argument behind
klp_synchronize_transition() does not apply here. It also avoids
queuing work on every CPU.
I reran the tests with both changes. The reproducer, the lockdep and
PROVE_RCU runs, and 20,000 replace cycles without the injected sleep all
passed with no fault or report. One cost showed up: with preempt=full,
the median transition time in my exit-storm test rose from 8 ms to
0.8 s, while the 90th and 99th percentiles stayed about the same. I
think that is acceptable, since a transition is not latency-critical,
but I can go back to klp_synchronize_transition() if you prefer. The
details are in the v3 cover letter, which I am sending now.
Thanks for the review.
Binoy