From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795980315; b=r86m5xvljAyYlBiGQ7/ccOYaIeR/WQQ5oxNz/VSGFYl6Y4QNITVUru/6eBYEp45gt3o3 TutlvHzvUfNZpgMMUEQIoLExgGfVjyAP7oU8nj2OjBf166o9Ay6CsVbkVERihq5bk32xm 9IvCQ1LB7huj8W4TUqT3va++RwNGvDvEFRl8fBoQS4I7aEnecyv7MixOjKzr3qJh1B/xw C7GcVZ13rkjAXzeyp/8yxt+ED4KkPJJsR5vy+i/+aSnSpvgCdC4r5yrXo75wBfLsWKNXQ ycTB4jQLK0S4NrIb1h6wXh1UL+n/UTDp5086PGXWloklYUelb2Ftu3LkTls0v13k0kQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795980315; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=A/lvO/PgRH9cwbp8B8l+1R3Y4qxM2o69t+v25utXRas=; b=HMu6ERPGajXOeXVNZhLiRbp1WtHzjHb/zjiLQX69Kgr7BDhUwQFjgPhVkmHgCL82EUbo itdWNRDY6Ibc1iN32qg6GC2UjSHoOMvcye8QIqPKLcXFeo1rnQ2Dr3QFfKQUeR/x6kkSJ 7dXm54lg6L2PuYQndi5sIRl5qqKFkgaa0Jimxi4zAo0GZ74K1UK8uNxwblD5gChbRvPBt jADHhfOybcsWElr3CJgBc8FwZQ3noT8ncrTyzjLgJObSRaQhP+NO1Yxp9dXY77hKjj70Y vX+ipPHMXm1Lsdrn6/zoQ0FmggCtNqNRE53feTGneHI0QvdxjCdh4UUlK9u9sDyPrWA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b="P/PK9PkJ"; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FFA3606A327 for ; Sun, 29 Nov 2026 19:25:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5FFA3606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=P/PK9PkJ Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5AE9C1575; Sun, 29 Nov 2026 11:25:10 -0800 (PST) Received: from [10.57.71.175] (unknown [10.57.71.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A048F3F86F; Sun, 29 Nov 2026 11:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795980313; bh=cQ+gwwEW0kNRaH4hOP9oMb43vg+y+jfavLENzjVy7fg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=P/PK9PkJYbwsLJY4qyBNfWamKgggUJrusPqV21UexrrtSu9Y8zqSK+N38/s6teaUy 3W1wF0IJkqo05g2M3kh06DXDnbNv0r/NHcvLfhsuOxy0DmuSKnV4zdcYYLy2BqKxYd 2iRAcUH6JYWFaKHYZ2dkQ01u8s32Ot01r9sAiLMA= Message-ID: Date: Sun, 29 Nov 2026 19:25:08 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] sched/fair: Skip PELT on !CONFIG_SMP To: Mehmet Fide , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , linux-kernel@vger.kernel.org References: <20261129191929.854496-1-mehmet.fide@gmail.com> From: Christian Loehle Content-Language: en-US In-Reply-To: <20261129191929.854496-1-mehmet.fide@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > --- > > 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//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 */