From: qianjun.kernel@gmail.com
To: mingo@redhat.com, peterz@infradead.org,
vincent.guittot@linaro.org, juri.lelli@redhat.com,
linux-kernel@vger.kernel.org
Cc: dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de,
jun qian <qianjun.kernel@gmail.com>,
Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH 1/1] sched/fair: Fix the wrong sched_stat_wait time
Date: Wed, 30 Sep 2020 10:47:12 +0800 [thread overview]
Message-ID: <20200930024712.88258-1-qianjun.kernel@gmail.com> (raw)
From: jun qian <qianjun.kernel@gmail.com>
When the sched_schedstat changes from 0 to 1, some sched se maybe
already in the runqueue, the se->statistics.wait_start will be 0.
So it will let the (rq_of(cfs_rq)) - se->statistics.wait_start)
wrong. We need to avoid this scenario.
Signed-off-by: jun qian <qianjun.kernel@gmail.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
kernel/sched/fair.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 658aa7a..dd7c3bb 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -908,6 +908,14 @@ static void update_curr_fair(struct rq *rq)
if (!schedstat_enabled())
return;
+ /*
+ * When the sched_schedstat changes from 0 to 1, some sched se maybe
+ * already in the runqueue, the se->statistics.wait_start will be 0.
+ * So it will let the delta wrong. We need to avoid this scenario.
+ */
+ if (unlikely(!schedstat_val(se->statistics.wait_start)))
+ return;
+
delta = rq_clock(rq_of(cfs_rq)) - schedstat_val(se->statistics.wait_start);
if (entity_is_task(se)) {
--
1.8.3.1
next reply other threads:[~2020-09-30 2:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 2:47 qianjun.kernel [this message]
2020-09-30 8:19 ` [PATCH 1/1] sched/fair: Fix the wrong sched_stat_wait time Peter Zijlstra
2020-09-30 9:16 ` jun qian
2020-09-30 9:57 ` Peter Zijlstra
2020-09-30 13:08 ` jun qian
2020-10-09 9:33 ` jun qian
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=20200930024712.88258-1-qianjun.kernel@gmail.com \
--to=qianjun.kernel@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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