From: Arun Sharma <asharma@fb.com>
To: linux-kernel@vger.kernel.org
Cc: Arun Sharma <asharma@fb.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@infradead.org>,
Andrew Vagin <avagin@openvz.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] trace: reset sleep/block start time on task switch
Date: Thu, 19 Jan 2012 18:20:20 -0800 [thread overview]
Message-ID: <1327026020-32376-1-git-send-email-asharma@fb.com> (raw)
Without this patch, the first sample we get on a
task might be bad because of a stale sleep_start
value that wasn't reset at the last task switch
because the tracepoint was not active.
The problem can be worked around via perf record
--filter "sleeptime < some-large-number" in practice
and it's not clear if the added code to the context
switch path is worth it.
I'm posting this patch regardless, just in case
more people start noticing this and start wondering
where the bogus numbers came from.
Signed-off-by: Arun Sharma <asharma@fb.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Andrew Vagin <avagin@openvz.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org
---
include/trace/events/sched.h | 3 ---
kernel/sched/core.c | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 6ba596b..814cdf1 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -378,9 +378,6 @@ static inline u64 trace_get_sleeptime(struct task_struct *tsk)
block = tsk->se.statistics.block_start;
sleep = tsk->se.statistics.sleep_start;
- tsk->se.statistics.block_start = 0;
- tsk->se.statistics.sleep_start = 0;
-
return block ? block : sleep ? sleep : 0;
#else
return 0;
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 457c881..6349cee 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1937,7 +1937,10 @@ static void finish_task_switch(struct rq *rq, struct task_struct *prev)
local_irq_enable();
#endif /* __ARCH_WANT_INTERRUPTS_ON_CTXSW */
finish_lock_switch(rq, prev);
+
trace_sched_stat_sleeptime(current, rq->clock);
+ current->se.statistics.block_start = 0;
+ current->se.statistics.sleep_start = 0;
fire_sched_in_preempt_notifiers(current);
if (mm)
--
1.7.4
next reply other threads:[~2012-01-20 2:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-20 2:20 Arun Sharma [this message]
2012-01-23 11:34 ` Peter Zijlstra
2012-01-23 18:41 ` Arun Sharma
2012-01-23 21:03 ` Peter Zijlstra
2012-01-23 23:02 ` Arun Sharma
2012-01-24 14:27 ` Peter Zijlstra
2012-01-24 21:46 ` Arun Sharma
2012-01-25 9:20 ` Frederic Weisbecker
2012-01-25 19:50 ` Arun Sharma
2012-01-25 20:15 ` Steven Rostedt
2012-01-25 22:29 ` Arun Sharma
2012-01-26 2:27 ` Frederic Weisbecker
2012-01-26 19:13 ` Arun Sharma
2012-01-26 2:21 ` Frederic Weisbecker
2012-02-10 18:43 ` Peter Zijlstra
2012-02-10 20:07 ` Arun Sharma
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=1327026020-32376-1-git-send-email-asharma@fb.com \
--to=asharma@fb.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=avagin@openvz.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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
Powered by JetHome