Skip to content

sched/core: Don't count voluntary idle picks as forced idle

Kuba Piecuch lkml sashiko-reviews sched-ext 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2sched/core: Don't count voluntary idle picks as forced idlekernel/sched/core.c+6 -91 reply
2/2selftests/sched_ext: Add core_forceidle test for voluntary idle pickstools/testing/selftests/sched_ext/Makefile tools/testing/selftests/sched_ext/core_forceidle.bpf.c tools/testing/selftests/sched_ext/core_forceidle.c+667 -01 reply

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchTejun Heo
1/2A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] sched/core: Don't count voluntary idle picks as forced idle

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

Signature · 1 line
2.56.1.839.g22a8290db9-goog