Re: [PATCH v3 2/3] livepatch: Include exiting tasks in the transition
From: Yafang Shao
Date: Wed Nov 25 2026 - 22:13:15 EST
On Thu, Nov 26, 2026 at 8:58 AM Ravindran, Binoy <binoy@xxxxxx> wrote:
>
>
> Thanks, this is right. A dying task reports its quiescent state in
> rcu_note_context_switch(), early in __schedule(), and then still runs
> traceable code, such as update_rq_clock() and pick_next_task(), until
> switch_to(). RCU does not promise to wait for code after that point, and
> with expedited grace periods the quiescent state is reported right
> there, so synchronize_rcu() can return too early.
> klp_synchronize_transition(), which v2 used, does not have this
> problem: schedule_on_each_cpu() completes only after the work item has
> run on every CPU, which on the dying task's CPU happens only after
> switch_to().
>
> v4 goes back to klp_synchronize_transition() for both waits and keeps
> klp_try_switch_exiting_tasks() from v3. I will send it after rerunning
> the tests.
>
> Yafang, this reverses your second suggestion; I hope the reason above
> makes sense. It also brings back the v2 transition times.
Agreed. I missed the point that the quiescent state is reported early
in __schedule(), and that the code from there until switch_to() is not
covered by synchronize_rcu(). Thanks for pointing that out.
--
Regards
Yafang