[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202401031216+0800-wangjinchao@xfusion.com>
Date: Wed, 3 Jan 2024 12:18:31 +0800
From: Wang Jinchao <wangjinchao@...sion.com>
To: Ingo Molnar <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>, Vincent Guittot
<vincent.guittot@...aro.org>, Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>, Mel
Gorman <mgorman@...e.de>, Daniel Bristot de Oliveira <bristot@...hat.com>,
Valentin Schneider <vschneid@...hat.com>, <linux-kernel@...r.kernel.org>
CC: <stone.xulei@...sion.com>, <wangjinchao@...sion.com>
Subject: [PATCH] sched/fair: Optimize min_vruntime update on unchanged
vruntime
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 <wangjinchao@...sion.com>
---
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 = __pick_first_entity(cfs_rq);
struct sched_entity *curr = cfs_rq->curr;
- u64 vruntime = cfs_rq->min_vruntime;
+ u64 vruntime = U64_MAX;
- if (curr) {
- if (curr->on_rq)
- vruntime = curr->vruntime;
- else
- curr = NULL;
- }
+ if (curr && curr->on_rq)
+ vruntime = curr->vruntime;
+ if (se)
+ vruntime = min_vruntime(vruntime, se->vruntime);
- if (se) {
- if (!curr)
- vruntime = se->vruntime;
- else
- vruntime = min_vruntime(vruntime, se->vruntime);
- }
+ /* no need to update if vruntime is unchanged */
+ if (vruntime == U64_MAX)
+ return;
/* ensure we never gain time by being placed backwards. */
u64_u32_store(cfs_rq->min_vruntime,
--
2.40.0
Powered by blists - more mailing lists