On Sat 2022-05-07 10:46:28, Song Liu wrote: > Busy kernel threads may block the transition of livepatch. Call > klp_try_switch_task from __cond_resched to make the transition easier. Do you have some numbers how this speeds up the transition and how it slows down the scheduler, please? cond_resched() is typically called in cycles with many interactions where the task might spend a lot of time. There are two possibilities. cond_resched() is called in: + livepatched function In this case, klp_try_switch_task(current) will always fail. And it will non-necessarily slow down every iteration by checking the very same stack. + non-livepatched function In this case, the transition will succeed on the first attempt. OK, but it would succeed also without that patch. The task would most likely sleep in this cond_resched() so that it might be successfully transitioned on the next occasion. >From my POV this patch this patch brings more harm than good. Note that scheduling is a fast path. It is repeated zillion-times on any system. But livepatch transition is a slow path. It does not matter if it takes 1 second or 1 hour. Best Regards, Petr