From nobody Mon Apr 6 11:02:25 2026 Received: from canpmsgout08.his.huawei.com (canpmsgout08.his.huawei.com [113.46.200.223]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54D8A30FF1D for ; Fri, 20 Mar 2026 06:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.223 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987619; cv=none; b=SmsG1zhxFZG+oc1pauUg29dV2QqZPjVbQtzk17dzTIA0I0QzOg24HtFOuslS8oCjbcujbpznZB82b1sWFEK6doS1DD/n0IyMT42WIcjGHwqguGSaBKYeKvVoT6KVI4yuahJHdglkyULyGqRMS38UKpof+15rZEOmM2ld07SIGdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773987619; c=relaxed/simple; bh=iwAsPGgv5owW0EZQTvV5hPM4kemza5FPhD+E/H96duA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D4fdcQU4dfJBGctMx4r1WW4/C8hOuQv55lyiqF1kI6s/1LKz5rPxcOulfiBXdJJAi5ZL/ZE+44pV6y0gHuSJRuK9BpAbRm6SJJ7LM+W3otqXc88275pwdLrbW4xK8tx+FSNHkwn2TQleH8BWmlpFxmBxdbpvwIXiJMtvE4cKMwE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=mk2pDjNK; arc=none smtp.client-ip=113.46.200.223 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="mk2pDjNK" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=HNOYJL4Vn81gEyytjC8CvgR7HKhIHEkzpdQRN2UUz2s=; b=mk2pDjNKIEziYBSiAECfoSzzOCRSWNG5OM3AjYEHeXn3iMCsJEVSGtKzzShjma8DHFNDAjE8T 2joVuyWg2Kfi/683vflCu6Dss6m/7y9NkMZ55bSugb+9ffxHVNYNyc2zm8h/H/XLXH3IHdAckVS mOM2hSlsr/qBOUqmajLQCm0= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4fcXNZ3KKzzmV78; Fri, 20 Mar 2026 14:15:10 +0800 (CST) Received: from kwepemr500016.china.huawei.com (unknown [7.202.195.68]) by mail.maildlp.com (Postfix) with ESMTPS id 23FBE40565; Fri, 20 Mar 2026 14:20:12 +0800 (CST) Received: from huawei.com (10.67.174.242) by kwepemr500016.china.huawei.com (7.202.195.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 20 Mar 2026 14:20:11 +0800 From: Chen Jinghuang To: , , , , CC: , , , , , , , Subject: [RFC PATCH v5 5/9] sched/fair: Hoist idle_stamp up from idle_balance Date: Fri, 20 Mar 2026 05:59:16 +0000 Message-ID: <20260320055920.2518389-6-chenjinghuang2@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260320055920.2518389-1-chenjinghuang2@huawei.com> References: <20260320055920.2518389-1-chenjinghuang2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemr500016.china.huawei.com (7.202.195.68) Content-Type: text/plain; charset="utf-8" From: Steve Sistare Move the update of idle_stamp from idle_balance to the call site in pick_next_task_fair, to prepare for a future patch that adds work to pick_next_task_fair which must be included in the idle_stamp interval. No functional change. Signed-off-by: Steve Sistare Signed-off-by: Chen Jinghuang --- kernel/sched/fair.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 92c3bcff5b6b..742462d41118 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5078,6 +5078,16 @@ static inline void update_misfit_status(struct task_= struct *p, struct rq *rq) } =20 #ifdef CONFIG_SMP +static inline void rq_idle_stamp_update(struct rq *rq) +{ + rq->idle_stamp =3D rq_clock(rq); +} + +static inline void rq_idle_stamp_clear(struct rq *rq) +{ + rq->idle_stamp =3D 0; +} + static void overload_clear(struct rq *rq) { struct sparsemask *overload_cpus; @@ -5100,6 +5110,8 @@ static void overload_set(struct rq *rq) rcu_read_unlock(); } #else /* CONFIG_SMP */ +static inline void rq_idle_stamp_update(struct rq *rq) {} +static inline void rq_idle_stamp_clear(struct rq *rq) {} static inline void overload_clear(struct rq *rq) {} static inline void overload_set(struct rq *rq) {} #endif @@ -9011,8 +9023,17 @@ pick_next_task_fair(struct rq *rq, struct task_struc= t *prev, struct rq_flags *rf =20 idle: if (rf) { + /* + * We must set idle_stamp _before_ calling idle_balance(), such that we + * measure the duration of idle_balance() as idle time. + */ + rq_idle_stamp_update(rq); + new_tasks =3D sched_balance_newidle(rq, rf); =20 + if (new_tasks) + rq_idle_stamp_clear(rq); + /* * Because sched_balance_newidle() releases (and re-acquires) * rq->lock, it is possible for any higher priority task to @@ -12911,13 +12932,6 @@ static int sched_balance_newidle(struct rq *this_r= q, struct rq_flags *rf) if (this_rq->ttwu_pending) return 0; =20 - /* - * We must set idle_stamp _before_ calling sched_balance_rq() - * for CPU_NEWLY_IDLE, such that we measure the this duration - * as idle time. - */ - this_rq->idle_stamp =3D rq_clock(this_rq); - /* * Do not pull tasks towards !active CPUs... */ @@ -13026,9 +13040,7 @@ static int sched_balance_newidle(struct rq *this_rq= , struct rq_flags *rf) if (time_after(this_rq->next_balance, next_balance)) this_rq->next_balance =3D next_balance; =20 - if (pulled_task) - this_rq->idle_stamp =3D 0; - else + if (!pulled_task) nohz_newidle_balance(this_rq); =20 rq_repin_lock(this_rq, rf); --=20 2.34.1