Re: [PATCH v3 2/3] livepatch: Include exiting tasks in the transition

From: Ravindran, Binoy

Date: Fri Nov 27 2026 - 14:13:29 EST



Hi Petr,

> By other words, the task is removed from the rcu_tasks_exit_list
> in the later 2nd RCU period. So, if synchronize_rcu() is going
> to wait for this 2nd period then it might end prematurely because
> the quiescent state is reported by rcu_note_context_switch()
> early in __schedule().

Yes, that matches my reading.

> But I might miss something. I am not sure which period
> synchronize_rcu() is waiting for.

synchronize_rcu() waits for RCU readers that started before it. Of the
two sections that the comment above rcu_tasks_postscan() describes,
only the second is an RCU reader: the stretch from the final
preempt_disable() in do_exit() to the final schedule().

rcu_note_context_switch() notes the quiescent state early in
__schedule(), before switch_to(). With an expedited grace period in
progress, it also reports it right there, through rcu_report_exp_rdp()
(kernel/rcu/tree_plugin.h). The grace period can then end while the
task still runs traceable code in the rest of __schedule(). RCU does
not need to cover that code, but livepatch does.

klp_synchronize_transition() covers it, because the work item can run
on that CPU only after the task has switched out. It was also cheaper
in my tests. With synchronize_rcu() (v3), the median transition time
went from 8 to 12 ms in the default mode and from 8 ms to 0.8 s with
preempt=full. With klp_synchronize_transition() (v4), the medians were
7 ms and 11 ms.

So v5 keeps klp_synchronize_transition(), with the comment reworded as
you suggested.

Thanks,
Binoy