On Sun, 2022-05-08 at 22:41 +0200, Peter Zijlstra wrote: > > No, it does what you think it should do, you're just getting confused > by > the inverted PREEMPT_NEED_RESCHED bit :-) Fair enough, that makes sense! Thanks for pointing that out. That is a very clever optimization. I suppose that should_resched() check is also something that KLP could use by periodically poking tasks that get stuck in the KLP transition (and are running) by simply calling set_preempt_need_resched(), after which that klp_patch_pending() check can happen only in the __cond_resched() path where we already call preempt_schedule_common() anyway? Is that something that would work, and be low enough overhead in the general case to be acceptable?