sched/fair: Fix external p->on_rq users
Sean noted that ever since commit152e11f6df("sched/fair: Implement delayed dequeue") KVM's preemption notifiers have started mis-classifying preemption vs blocking. Notably p->on_rq is no longer sufficient to determine if a task is runnable or blocked -- the aforementioned commit introduces tasks that remain on the runqueue even through they will not run again, and should be considered blocked for many cases. Add the task_is_runnable() helper to classify things and audit all external users of the p->on_rq state. Also add a few comments. Fixes:152e11f6df("sched/fair: Implement delayed dequeue") Reported-by: Sean Christopherson <seanjc@google.com> Tested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lkml.kernel.org/r/20241010091843.GK33184@noisy.programming.kicks-ass.net
This commit is contained in:
committed by
Ingo Molnar
parent
c650812419
commit
cd9626e9eb
+6
-1
@@ -109,7 +109,12 @@ static int __set_task_frozen(struct task_struct *p, void *arg)
|
||||
{
|
||||
unsigned int state = READ_ONCE(p->__state);
|
||||
|
||||
if (p->on_rq)
|
||||
/*
|
||||
* Allow freezing the sched_delayed tasks; they will not execute until
|
||||
* ttwu() fixes them up, so it is safe to swap their state now, instead
|
||||
* of waiting for them to get fully dequeued.
|
||||
*/
|
||||
if (task_is_runnable(p))
|
||||
return 0;
|
||||
|
||||
if (p != current && task_curr(p))
|
||||
|
||||
Reference in New Issue
Block a user