mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuba Piecuch <jpiecuch@google.com>
To: Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>
Cc: Kuba Piecuch <jpiecuch@google.com>,
	Ingo Molnar <mingo@redhat.com>,
	 Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	 Josh Don <joshdon@google.com>, David Vernet <void@manifault.com>,
	 Andrea Righi <arighi@nvidia.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev,  linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] sched/core: Don't count voluntary idle picks as forced idle
Date: Tue,  1 Dec 2026 12:03:02 +0000	[thread overview]
Message-ID: <20261201120123.3678974-1-jpiecuch@google.com> (raw)

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


             reply	other threads:[~2026-12-01 12:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:03 Kuba Piecuch [this message]
2026-12-01 12:03 ` [PATCH 1/2] " Kuba Piecuch
2026-12-01 12:03 ` [PATCH 2/2] selftests/sched_ext: Add core_forceidle test for voluntary idle picks Kuba Piecuch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201120123.3678974-1-jpiecuch@google.com \
    --to=jpiecuch@google.com \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®