The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peng Huang <penghuang@google.com>
To: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	 Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	 Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Andrea Righi <arighi@nvidia.com>,
	 Changwoo Min <changwoo@igalia.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	 Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	 Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	 linux-kernel@vger.kernel.org, sched-ext@lists.linux.dev,
	 stable@vger.kernel.org, Peng Huang <penghuang@google.com>
Subject: [PATCH v2 0/2] sched_ext, sched/fair: Drain blocked fair load on scx_switched_all
Date: Mon, 23 Nov 2026 12:13:49 -0800	[thread overview]
Message-ID: <cover.1795462673.git.penghuang@google.com> (raw)
In-Reply-To: <20261122015729.2512645-1-penghuang@google.com>

v1 [1] skipped rq->cfs.avg.util_sum in update_idle_rq_clock_pelt() when
scx_switched_all() was active. As Vincent Guittot pointed out, that hid
the underlying issue: once all fair tasks switch to sched_ext, fair
blocked load should be properly drained and propagated rather than left
stale in rq->cfs.avg.

Investigating why rq->cfs.avg.util_sum remained non-zero showed two
causes:

1. In update_tg_cfs_{util,runnable,load}(), if the group entity @se's
   _avg had already decayed to 0 while its _sum still held a sub-divider
   residual when the child gcfs_rq's _avg also reached 0, delta_avg == 0
   caused an early return without clearing @se's residual _sum from the
   parent cfs_rq.
2. Tasks that exited or migrated while sleeping before scx_enable()
   leave deferred removals in cfs_rq->removed, and switched_from_fair()
   only visits cfs_rq chains with live fair tasks. Once
   __scx_switched_all is enabled, periodic blocked-load updates stop,
   stranding unvisited leaf cfs_rqs in rq->cfs.avg.

Patch 1 clears residual task-group _sum values on zero-avg propagation
while keeping parent period_contrib divider scaling for non-zero
averages. Patch 2 reuses __sched_balance_update_blocked_averages() in
scx_enable()'s per-CPU scx_switched_all() loop to drain cfs_rq->removed
and propagate blocked averages across all leaf cfs_rqs.

Changes in v2:
- Drop the pelt.h workaround from v1 (Vincent Guittot).
- Clear residual sums in update_tg_cfs_{util,runnable,load}() when
  propagating a zero average (Vincent Guittot).
- Reuse __sched_balance_update_blocked_averages() in scx_enable() under
  scx_switched_all() to drain remaining blocked fair load (Vincent
  Guittot).

[1] https://lore.kernel.org/r/20261122015729.2512645-1-penghuang@google.com

Peng Huang (2):
  sched/fair: Clear residual sums on zero task-group avg propagation
  sched_ext, sched/fair: Drain blocked load on scx_switched_all

 kernel/sched/ext/ext.c |  9 ++++-----
 kernel/sched/fair.c    | 42 +++++++++++++++++++++++++++++++++---------
 kernel/sched/sched.h   |  1 +
 3 files changed, 38 insertions(+), 14 deletions(-)

-- 
2.56.1.831.g720f3f5937-goog


  parent reply	other threads:[~2026-11-23 20:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22  1:57 [PATCH] sched/pelt: Skip dormant cfs util_sum under scx_switched_all Peng Huang
2026-11-23 10:34 ` Vincent Guittot
2026-11-23 16:09   ` Peng Huang
2026-11-23 17:07     ` Vincent Guittot
2026-11-23 20:14       ` Peng Huang
2026-11-23 20:13 ` Peng Huang [this message]
2026-11-23 20:13   ` [PATCH v2 1/2] sched/fair: Clear residual sums on zero task-group avg propagation Peng Huang
2026-11-23 20:13   ` [PATCH v2 2/2] sched_ext, sched/fair: Drain blocked load on scx_switched_all Peng Huang

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=cover.1795462673.git.penghuang@google.com \
    --to=penghuang@google.com \
    --cc=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.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