From: Kassey Li <quic_yingangl@quicinc.com>
To: <mingo@redhat.com>, <peterz@infradead.org>,
<linux-kernel@vger.kernel.org>
Cc: <quic_yingangl@quicinc.com>
Subject: [PATCH] sched/headers: do not set last_queued to 0 in arrive
Date: Wed, 13 Mar 2024 10:39:20 +0800 [thread overview]
Message-ID: <20240313023920.3338035-1-quic_yingangl@quicinc.com> (raw)
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
reply other threads:[~2024-03-13 2:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240313023920.3338035-1-quic_yingangl@quicinc.com \
--to=quic_yingangl@quicinc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).