[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YJu8s0f7Cc78GEWN@hirez.programming.kicks-ass.net>
Date: Wed, 12 May 2021 13:32:03 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Mel Gorman <mgorman@...e.de>
Cc: tglx@...utronix.de, mingo@...nel.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org, dietmar.eggemann@....com,
rostedt@...dmis.org, bsegall@...gle.com, bristot@...hat.com,
bsingharora@...il.com, pbonzini@...hat.com, maz@...nel.org,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
riel@...riel.com, hannes@...xchg.org
Subject: Re: [PATCH 3/6] sched: Simplify sched_info_on()
On Wed, May 12, 2021 at 12:10:40PM +0100, Mel Gorman wrote:
> As delta is !0 iff t->sched_info.last_queued, why not this?
>
> diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
> index 33ffd41935ba..37e33c0eeb7c 100644
> --- a/kernel/sched/stats.h
> +++ b/kernel/sched/stats.h
> @@ -158,15 +158,14 @@ static inline void psi_sched_switch(struct task_struct *prev,
> */
> static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
> {
> - unsigned long long delta = 0;
> -
> if (t->sched_info.last_queued) {
> + unsigned long long delta;
> +
> delta = rq_clock(rq) - t->sched_info.last_queued;
> t->sched_info.last_queued = 0;
> + t->sched_info.run_delay += delta;
> + rq_sched_info_dequeue(rq, delta);
> }
> - t->sched_info.run_delay += delta;
> -
> - rq_sched_info_dequeue(rq, delta);
> }
Right.. clearly I missed the obvious there.. Lemme go add another patch
on top of the lot.
Something like this I suppose.
---
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 33ffd41935ba..111072ee9663 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -160,10 +160,11 @@ static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
{
unsigned long long delta = 0;
- if (t->sched_info.last_queued) {
- delta = rq_clock(rq) - t->sched_info.last_queued;
- t->sched_info.last_queued = 0;
- }
+ if (!t->sched_info.last_queued)
+ return;
+
+ delta = rq_clock(rq) - t->sched_info.last_queued;
+ t->sched_info.last_queued = 0;
t->sched_info.run_delay += delta;
rq_sched_info_dequeue(rq, delta);
@@ -176,12 +177,14 @@ static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
*/
static void sched_info_arrive(struct rq *rq, struct task_struct *t)
{
- unsigned long long now = rq_clock(rq), delta = 0;
+ unsigned long long now, delta = 0;
- if (t->sched_info.last_queued) {
- delta = now - t->sched_info.last_queued;
- t->sched_info.last_queued = 0;
- }
+ if (!t->sched_info.last_queued)
+ return;
+
+ now = rq_clock(rq);
+ delta = now - t->sched_info.last_queued;
+ t->sched_info.last_queued = 0;
t->sched_info.run_delay += delta;
t->sched_info.last_arrival = now;
t->sched_info.pcount++;
Powered by blists - more mailing lists