diff options
author | Peter Zijlstra <peterz@infradead.org> | 2024-10-10 11:38:10 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2024-10-14 09:14:35 +0200 |
commit | cd9626e9ebc77edec33023fe95dab4b04ffc819d (patch) | |
tree | f634627362f80150130afc99ccda5cf58e584614 /include | |
parent | sched/psi: Fix mistaken CPU pressure indication after corrupted task state bug (diff) | |
download | linux-cd9626e9ebc77edec33023fe95dab4b04ffc819d.tar.xz linux-cd9626e9ebc77edec33023fe95dab4b04ffc819d.zip |
sched/fair: Fix external p->on_rq users
Sean noted that ever since commit 152e11f6df29 ("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: 152e11f6df29 ("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
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/sched.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index e6ee4258169a..8a9517e6640c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2133,6 +2133,11 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu) #endif /* CONFIG_SMP */ +static inline bool task_is_runnable(struct task_struct *p) +{ + return p->on_rq && !p->se.sched_delayed; +} + extern bool sched_task_on_rq(struct task_struct *p); extern unsigned long get_wchan(struct task_struct *p); extern struct task_struct *cpu_curr_snapshot(int cpu); |