Skip to content

Commit c7b92e8

Browse files
committed
Merge tag 'sched-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fixes from Ingo Molnar: "Fix a cfs_rq->h_nr_runnable accounting bug that trips up a defensive SCHED_WARN_ON() on certain workloads. The bug is believed to be (accidentally) self-correcting, hence no behavioral side effects are expected. Also print se.slice in debug output, since this value can now be set via the syscall ABI and can be useful to track" * tag 'sched-urgent-2025-02-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/debug: Provide slice length for fair tasks sched/fair: Fix inaccurate h_nr_runnable accounting with delayed dequeue
2 parents a8f5fe6 + 9065ce6 commit c7b92e8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

kernel/sched/debug.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,8 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
12621262
if (task_has_dl_policy(p)) {
12631263
P(dl.runtime);
12641264
P(dl.deadline);
1265+
} else if (fair_policy(p->policy)) {
1266+
P(se.slice);
12651267
}
12661268
#ifdef CONFIG_SCHED_CLASS_EXT
12671269
__PS("ext.enabled", task_on_scx(p));

kernel/sched/fair.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5385,6 +5385,15 @@ static __always_inline void return_cfs_rq_runtime(struct cfs_rq *cfs_rq);
53855385
static void set_delayed(struct sched_entity *se)
53865386
{
53875387
se->sched_delayed = 1;
5388+
5389+
/*
5390+
* Delayed se of cfs_rq have no tasks queued on them.
5391+
* Do not adjust h_nr_runnable since dequeue_entities()
5392+
* will account it for blocked tasks.
5393+
*/
5394+
if (!entity_is_task(se))
5395+
return;
5396+
53885397
for_each_sched_entity(se) {
53895398
struct cfs_rq *cfs_rq = cfs_rq_of(se);
53905399

@@ -5397,6 +5406,16 @@ static void set_delayed(struct sched_entity *se)
53975406
static void clear_delayed(struct sched_entity *se)
53985407
{
53995408
se->sched_delayed = 0;
5409+
5410+
/*
5411+
* Delayed se of cfs_rq have no tasks queued on them.
5412+
* Do not adjust h_nr_runnable since a dequeue has
5413+
* already accounted for it or an enqueue of a task
5414+
* below it will account for it in enqueue_task_fair().
5415+
*/
5416+
if (!entity_is_task(se))
5417+
return;
5418+
54005419
for_each_sched_entity(se) {
54015420
struct cfs_rq *cfs_rq = cfs_rq_of(se);
54025421

0 commit comments

Comments
 (0)