Re: [PATCH 1/2] sched/core: Don't count voluntary idle picks as forced idle
From: Tejun Heo
Date: Tue Dec 01 2026 - 10:11:36 EST
On Tue, Dec 01, 2026 at 12:03:03PM +0000, Kuba Piecuch wrote:
> In pick_next_task(), the per-sibling loop increments
> rq->core->core_forceidle_count whenever p == rq_i->idle and
> rq_i->nr_running > 0. That conflates a sibling forced idle by a cookie
> mismatch with a sibling whose pick_task() voluntarily returned idle while
> rq_i->nr_running > 0.
>
> Voluntary idle with nr_running > 0 is legitimate whenever a scheduling
> class keeps queued tasks off the CPU and returns NULL from pick_task(),
> such as sched_ext tasks parked on a non-local DSQ. Counting those
> voluntary idle picks as forced idle has two effects:
>
> - If all siblings pick idle (occ == 0), core_forceidle_count becomes
> non-zero while core_forceidle_occupation is 0, triggering
> WARN_ON_ONCE(!rq->core->core_forceidle_occupation) in
> __sched_core_account_forceidle() when schedstats is enabled.
> - If another sibling is running (occ > 0), the voluntary idle time is
> spuriously billed as forced idle to the running sibling's cgroup and
> triggers forced-idle-only paths (queue_core_balance(), forced_idle_rq(),
> sched_core_idle_needs_pick()).
>
> Increment core_forceidle_count and core_forceidle_seq only inside the
> !cookie_equals(p, cookie) branch when sched_core_find() returns NULL and
> replaces a non-idle pick with idle. Since cookie_equals() always returns
> true for rq_i->idle, voluntary idle picks are never counted as forced
> idle, and entering the mismatch branch guarantees a non-idle @max so
> core_forceidle_occupation is always non-zero whenever forced idle is
> recorded.
>
> Fixes: 4feee7d12603 ("sched/core: Forced idle accounting")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Kuba Piecuch <jpiecuch@xxxxxxxxxx>
Acked-by: Tejun Heo <tj@xxxxxxxxxx>
Thanks.
--
tejun