mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Loehle <christian.loehle@arm.com>
To: Mehmet Fide <mehmet.fide@gmail.com>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>
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
Subject: Re: [RFC PATCH] sched/fair: Skip PELT on !CONFIG_SMP
Date: Sun, 29 Nov 2026 19:25:08 +0000	[thread overview]
Message-ID: <f5f09e6d-a69e-497f-a740-a24849b75b6c@arm.com> (raw)
In-Reply-To: <20261129191929.854496-1-mehmet.fide@gmail.com>

On 11/29/26 19:19, Mehmet Fide wrote:
> Since commit cac5cefbade9 ("sched/smp: Make SMP unconditional") a
> CONFIG_SMP=n kernel runs the PELT updates of the fair class. Before it,
> !SMP had stubs for update_load_avg(), which only called
> cfs_rq_util_change(), for {attach,detach,remove}_entity_load_avg() and
> for util_est_{enqueue,dequeue}().
> 
> On a single CPU nothing needs these averages: there is nothing to
> balance, and schedutil, and with it UCLAMP_TASK, depends on SMP. The
> group shares read them, but on one CPU a runnable group gets tg->shares
> in every cgroup_mode with or without them, but for "tasks", which
> scales tg->shares by the runnable average.
> 
> Return early from these functions again on !CONFIG_SMP, with the
> IS_ENABLED(CONFIG_SMP) toggles the cover letter of the series suggested
> for the UP overhead. detach_entity_cfs_rq() again tests
> se->avg.last_update_time, which stays 0 without the updates, only on
> SMP.
> 
> Round trips between two tasks on a Toradex Colibri VF50 (NXP Vybrid
> VF500, a single Cortex-A5, CONFIG_SMP=n, PREEMPT_VOLUNTARY, HZ=100,
> FAIR_GROUP_SCHED), in us, the mean of three boots, and of two boots for
> a build with -falign-functions=32:
> 
>                       default build      -falign-functions=32
>                       before   after     before   after
>   pipe                   224     178        189     148
>   futex                  272     221        248     213
>   unix stream            397     367        372     322
>   sched_yield, 2 calls    35      40         43      28
> 
> In both builds the instructions per round trip go from 11800-11840 to
> 10170 for the pipe and from 4805 to 4020 for sched_yield. sched_yield
> depends on the code layout: its L1 I-cache misses per round trip go
> from 66 to 98 in the default build, and from 98 to 45 in the other.
> 
> Link: https://lore.kernel.org/all/20250528080924.2273858-1-mingo@kernel.org/
> Signed-off-by: Mehmet Fide <mehmet.fide@gmail.com>
> ---
> 
> Notes:
>     RFC because I do not know whether the PELT updates on UP are wanted
>     for something I missed, and whether the RT, DL, IRQ and HW pressure
>     averages should get the same treatment: they were !SMP stubs before
>     cac5cefbade9 too and still run, as I measured only the fair class.

We can still use them for DVFS, i.e. schedutil, can't we?
Besides, the entire point of the commit was to get rid of the SMP ifdeffery
and this is introducing them in a worse way.

>     
>     With the patch, /proc/<pid>/sched and the sched debugfs files show the
>     initial averages, and cgroup_mode "tasks" uses one task per group.
>     
>     Tested on the VF50 before and after: cgroup v2 cpu.weight 100:300 gives
>     a 1:3 split, cpu.max of 20 % gives 2010 of 10000 ms, cgroup moves,
>     policy and nice changes, fork and exec; the same on a PROVE_LOCKING and
>     DEBUG_ATOMIC_SLEEP kernel without a report. kernel/sched builds with W=1
>     without new warnings for ARM multi_v7_defconfig, x86_64 defconfig,
>     x86_64 with SMP=n, FAIR_GROUP_SCHED and CFS_BANDWIDTH, and tinyconfig.
>     systemd reported the boot 0.18 s (0.6 %) faster, the median of ten each.
> 
>  kernel/sched/fair.c | 29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 2d9d3d68626..159b3eb53c2 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -5908,11 +5908,16 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
>   */
>  static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  {
> +	u32 divider;
> +
> +	if (!IS_ENABLED(CONFIG_SMP))
> +		return;
> +
>  	/*
>  	 * cfs_rq->avg.period_contrib can be used for both cfs_rq and se.
>  	 * See ___update_load_avg() for details.
>  	 */
> -	u32 divider = get_pelt_divider(&cfs_rq->avg);
> +	divider = get_pelt_divider(&cfs_rq->avg);
>  
>  	/*
>  	 * When we attach the @se to the @cfs_rq, we must align the decay
> @@ -5963,6 +5968,9 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
>   */
>  static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  {
> +	if (!IS_ENABLED(CONFIG_SMP))
> +		return;
> +
>  	dequeue_load_avg(cfs_rq, se);
>  	__update_sa(&cfs_rq->avg, util, -se->avg.util_avg, -se->avg.util_sum);
>  	__update_sa(&cfs_rq->avg, runnable, -se->avg.runnable_avg, -se->avg.runnable_sum);
> @@ -6058,9 +6066,17 @@ static inline void util_est_update(struct sched_entity *se)
>  /* Update task and its cfs_rq load average */
>  static inline void update_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
>  {
> -	u64 now = cfs_rq_clock_pelt(cfs_rq);
> +	u64 now;
>  	int decayed;
>  
> +	/* Load balancing and schedutil, the users of PELT, need SMP */
> +	if (!IS_ENABLED(CONFIG_SMP)) {
> +		cfs_rq_util_change(cfs_rq, 0);
> +		return;
> +	}
> +
> +	now = cfs_rq_clock_pelt(cfs_rq);
> +
>  	/*
>  	 * Track task load average for carrying it to new CPU after migrated, and
>  	 * track group sched_entity load average for task_h_load calculation in migration
> @@ -6123,6 +6139,9 @@ static void remove_entity_load_avg(struct sched_entity *se)
>  	struct cfs_rq *cfs_rq = cfs_rq_of(se);
>  	unsigned long flags;
>  
> +	if (!IS_ENABLED(CONFIG_SMP))
> +		return;
> +
>  	/*
>  	 * tasks cannot exit without having gone through wake_up_new_task() ->
>  	 * enqueue_task_fair() which will have added things to the cfs_rq,
> @@ -6172,7 +6191,7 @@ static inline void util_est_enqueue(struct cfs_rq *cfs_rq,
>  {
>  	unsigned int enqueued;
>  
> -	if (!sched_feat(UTIL_EST))
> +	if (!IS_ENABLED(CONFIG_SMP) || !sched_feat(UTIL_EST))
>  		return;
>  
>  	/* Update root cfs_rq's estimated utilization */
> @@ -6188,7 +6207,7 @@ static inline void util_est_dequeue(struct cfs_rq *cfs_rq,
>  {
>  	unsigned int enqueued;
>  
> -	if (!sched_feat(UTIL_EST))
> +	if (!IS_ENABLED(CONFIG_SMP) || !sched_feat(UTIL_EST))
>  		return;
>  
>  	/* Update root cfs_rq's estimated utilization */
> @@ -15495,7 +15514,7 @@ static void detach_entity_cfs_rq(struct sched_entity *se)
>  	 * - A task which has been woken up by try_to_wake_up() but is
>  	 *   waiting for actually being woken up by sched_ttwu_pending().
>  	 */
> -	if (!se->avg.last_update_time)
> +	if (IS_ENABLED(CONFIG_SMP) && !se->avg.last_update_time)
>  		return;
>  
>  	/* Catch up with the cfs_rq and remove our load when we leave */


  reply	other threads:[~2026-11-29 19:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 19:19 Mehmet Fide
2026-11-29 19:25 ` Christian Loehle [this message]
2026-11-29 19:32   ` Mehmet Fide
2026-11-29 19:53     ` Christian Loehle

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=f5f09e6d-a69e-497f-a740-a24849b75b6c@arm.com \
    --to=christian.loehle@arm.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mehmet.fide@gmail.com \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --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

all inboxes | Powered by JetHome®