From nobody Fri Dec 26 17:22:39 2025 Received: from wxsgout04.xfusion.com (wxsgout03.xfusion.com [36.139.52.80]) (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 80FA0171C4 for ; Wed, 3 Jan 2024 04:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xfusion.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xfusion.com Received: from wuxshcsitd00600.xfusion.com (unknown [10.32.133.213]) by wxsgout04.xfusion.com (SkyGuard) with ESMTPS id 4T4bw92tcmzB13y6; Wed, 3 Jan 2024 12:14:49 +0800 (CST) Received: from localhost (10.82.147.3) by wuxshcsitd00600.xfusion.com (10.32.133.213) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 3 Jan 2024 12:18:31 +0800 Date: Wed, 3 Jan 2024 12:18:31 +0800 From: Wang Jinchao To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , CC: , Subject: [PATCH] sched/fair: Optimize min_vruntime update on unchanged vruntime Message-ID: <202401031216+0800-wangjinchao@xfusion.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-ClientProxiedBy: wuxshcsitd00601.xfusion.com (10.32.135.241) To wuxshcsitd00600.xfusion.com (10.32.133.213) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When (!(curr && curr->on_rq) && !se) is true, there is no need to update min_vruntime. Simplify the if-else logic accordingly. Signed-off-by: Wang Jinchao --- kernel/sched/fair.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index d7a3c63a2171..a4afdeee515d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -755,21 +755,16 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq) struct sched_entity *se =3D __pick_first_entity(cfs_rq); struct sched_entity *curr =3D cfs_rq->curr; =20 - u64 vruntime =3D cfs_rq->min_vruntime; + u64 vruntime =3D U64_MAX; =20 - if (curr) { - if (curr->on_rq) - vruntime =3D curr->vruntime; - else - curr =3D NULL; - } + if (curr && curr->on_rq) + vruntime =3D curr->vruntime; + if (se) + vruntime =3D min_vruntime(vruntime, se->vruntime); =20 - if (se) { - if (!curr) - vruntime =3D se->vruntime; - else - vruntime =3D min_vruntime(vruntime, se->vruntime); - } + /* no need to update if vruntime is unchanged */ + if (vruntime =3D=3D U64_MAX) + return; =20 /* ensure we never gain time by being placed backwards. */ u64_u32_store(cfs_rq->min_vruntime, --=20 2.40.0