lkml.org 
[lkml]   [2024]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] sched/headers: do not set last_queued to 0 in arrive
Date
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@quicinc.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

\
 
 \ /
  Last update: 2024-03-13 03:40    [W:0.031 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site