From: "tip-bot2 for jun qian" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: jun qian <qianjun.kernel@gmail.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Yafang Shao <laoar.shao@gmail.com>, x86 <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [tip: sched/core] sched/fair: Improve the accuracy of sched_stat_wait statistics
Date: Thu, 29 Oct 2020 10:51:52 -0000 [thread overview]
Message-ID: <160396871261.397.9603442969201125395.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20201015064846.19809-1-qianjun.kernel@gmail.com>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: b9c88f752268383beff0d56e50d52b8ae62a02f8
Gitweb: https://git.kernel.org/tip/b9c88f752268383beff0d56e50d52b8ae62a02f8
Author: jun qian <qianjun.kernel@gmail.com>
AuthorDate: Thu, 15 Oct 2020 14:48:46 +08:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 29 Oct 2020 11:00:28 +01:00
sched/fair: Improve the accuracy of sched_stat_wait statistics
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: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Yafang Shao <laoar.shao@gmail.com>
Link: https://lkml.kernel.org/r/20201015064846.19809-1-qianjun.kernel@gmail.com
---
kernel/sched/fair.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 290f9e3..b9368d1 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -906,6 +906,15 @@ update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se)
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)) {
prev parent reply other threads:[~2020-10-29 10:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 6:48 [PATCH 1/1] Sched/fair: Improve the accuracy of sched_stat_wait statistics qianjun.kernel
2020-10-15 11:02 ` Peter Zijlstra
2020-10-29 10:51 ` tip-bot2 for jun qian [this message]
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=160396871261.397.9603442969201125395.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=laoar.shao@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=qianjun.kernel@gmail.com \
--cc=x86@kernel.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).