[PATCH 0/2] sched/core: Don't count voluntary idle picks as forced idle
From: Kuba Piecuch
Date: Tue Dec 01 2026 - 07:03:26 EST
In pick_next_task(), core scheduling increments core_forceidle_count
whenever a sibling picks idle with rq_i->nr_running > 0. That mistakes a
voluntary idle pick -- such as a sched_ext task parked on a non-local DSQ
while pick_task() returns NULL -- for cookie-mismatch forced idle. When all
siblings voluntarily pick idle, core_forceidle_count > 0 with
core_forceidle_occupation == 0 triggers the warning in
__sched_core_account_forceidle(); when another sibling is busy, voluntary
idle is billed as forced idle and triggers forced-idle-only paths
(queue_core_balance(), forced_idle_rq(), sched_core_idle_needs_pick()).
Patch 1 moves the core_forceidle_count and core_forceidle_seq increments
into the !cookie_equals(p, cookie) fallback when sched_core_find() returns
NULL.
Patch 2 adds a core_forceidle sched_ext selftest covering voluntary idle
with an idle sibling, voluntary idle with an untagged busy sibling, and a
sanity check that genuine cookie-mismatch forced idle is still counted.
Without patch 1, the selftest triggers:
WARNING: kernel/sched/core_sched.c:262 at __sched_core_account_forceidle+0x23e/0x260, CPU#0: swapper/0/0
and fails with:
ERR: core_forceidle.c:449
Phase 1: voluntary idle counted as forced idle (obs=1 fi=1 zero_occ=1)
This series is based on tip/sched/urgent because
commit d2583cb03113 ("sched/deadline: Clear stale rq->dl_server when
core-sched replaces a pick") modifies the same loop in pick_next_task().
Patch 2 touches tools/testing/selftests/sched_ext/ only; please route
through whichever tree is more convenient (or take patch 1 via tip and
patch 2 via sched_ext once patch 1 lands).
The patches were written with the help of an AI coding assistant. I have
reviewed the patches and verified the tests run by the tool.
Kuba Piecuch (2):
sched/core: Don't count voluntary idle picks as forced idle
selftests/sched_ext: Add core_forceidle test for voluntary idle picks
kernel/sched/core.c | 15 +-
tools/testing/selftests/sched_ext/Makefile | 1 +
.../selftests/sched_ext/core_forceidle.bpf.c | 176 +++++++
.../selftests/sched_ext/core_forceidle.c | 490 ++++++++++++++++++
4 files changed, 673 insertions(+), 9 deletions(-)
create mode 100644 tools/testing/selftests/sched_ext/core_forceidle.bpf.c
create mode 100644 tools/testing/selftests/sched_ext/core_forceidle.c
base-commit: f4eb2ace3efdd8b6e3b0946bbd316166edb1a51e
--
2.56.1.839.g22a8290db9-goog