[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240313023920.3338035-1-quic_yingangl@quicinc.com>
Date: Wed, 13 Mar 2024 10:39:20 +0800
From: Kassey Li <quic_yingangl@...cinc.com>
To: <mingo@...hat.com>, <peterz@...radead.org>, <linux-kernel@...r.kernel.org>
CC: <quic_yingangl@...cinc.com>
Subject: [PATCH] sched/headers: do not set last_queued to 0 in arrive
The pcount accounting for Task A missed in the step 4:
1. Task A enqueued
2. Task A arrive and hit CPU
3. Task B arrive and hit CPU, preempted Task A, Task A is still in rq
as TASK_RUNNING
4. Task A arrive and hit CPU again.
This change leaves enqueue/dequeue on last_queued only, and
correct the pcount accounting.
Signed-off-by: Kassey Li <quic_yingangl@...cinc.com>
---
kernel/sched/stats.h | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index 38f3698f5e5b..3decd2261875 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -229,8 +229,17 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t)
return;
now = rq_clock(rq);
- delta = now - t->sched_info.last_queued;
- t->sched_info.last_queued = 0;
+
+ /*
+ * last_arrival > last_queued means a task in the rq, it is not the
+ * first time hits the CPU.
+ */
+
+ if(unlikely(t->sched_info.last_arrival > t->sched_info.last_queued))
+ delta = now - t->sched_info.last_arrival;
+ else
+ delta = now - t->sched_info.last_queued;
+
t->sched_info.run_delay += delta;
t->sched_info.last_arrival = now;
t->sched_info.pcount++;
--
2.25.1
Powered by blists - more mailing lists