public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 8/8] tracing: Fix sleep time function profiling
Date: Tue, 27 Apr 2010 21:27:31 -0400	[thread overview]
Message-ID: <20100428013807.530671968@goodmis.org> (raw)
In-Reply-To: 20100428012723.119106602@goodmis.org

[-- Attachment #1: 0008-tracing-Fix-sleep-time-function-profiling.patch --]
[-- Type: text/plain, Size: 1895 bytes --]

From: Steven Rostedt <srostedt@redhat.com>

When sleep_time is off the function profiler ignores the time that a task
is scheduled out. When the task is scheduled out a timestamp is taken.
When the task is scheduled back in, the timestamp is compared to the
current time and the saved calltimes are adjusted accordingly.

But when stopping the function profiler, the sched switch hook that
does this adjustment was stopped before shutting down the tracer.
This allowed some tasks to not get their timestamps set when they
scheduled out. When the function profiler started again, this would
skew the times of the scheduler functions.

This patch moves the stopping of the sched switch to after the function
profiler is stopped. It also ignores zero set calltimes, which may
happen on start up.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 3bcb340..8c9c293 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -666,6 +666,10 @@ static void profile_graph_return(struct ftrace_graph_ret *trace)
 	if (!stat->hash || !ftrace_profile_enabled)
 		goto out;
 
+	/* If the calltime was zero'd ignore it */
+	if (!trace->calltime)
+		goto out;
+
 	calltime = trace->rettime - trace->calltime;
 
 	if (!(trace_flags & TRACE_ITER_GRAPH_TIME)) {
@@ -3357,11 +3361,11 @@ void unregister_ftrace_graph(void)
 		goto out;
 
 	ftrace_graph_active--;
-	unregister_trace_sched_switch(ftrace_graph_probe_sched_switch);
 	ftrace_graph_return = (trace_func_graph_ret_t)ftrace_stub;
 	ftrace_graph_entry = ftrace_graph_entry_stub;
 	ftrace_shutdown(FTRACE_STOP_FUNC_RET);
 	unregister_pm_notifier(&ftrace_suspend_notifier);
+	unregister_trace_sched_switch(ftrace_graph_probe_sched_switch);
 
  out:
 	mutex_unlock(&ftrace_lock);
-- 
1.7.0



  parent reply	other threads:[~2010-04-28  1:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-28  1:27 [PATCH 0/8] [GIT PULL] tracing: various updates Steven Rostedt
2010-04-28  1:27 ` [PATCH 1/8] tracing: Add ftrace events for graph tracer Steven Rostedt
2010-04-28  1:27 ` [PATCH 2/8] tracing: Have graph flags passed in to ouput functions Steven Rostedt
2010-04-28  1:27 ` [PATCH 3/8] tracing: Add graph output support for irqsoff tracer Steven Rostedt
2010-04-28  1:27 ` [PATCH 4/8] ring-buffer: Make non-consuming read less expensive with lots of cpus Steven Rostedt
2010-04-28  1:27 ` [PATCH 5/8] ring-buffer: Make benchmark handle missed events Steven Rostedt
2010-04-28  1:27 ` [PATCH 6/8] tracing: Add documentation for trace commands mod, traceon/traceoff Steven Rostedt
2010-04-28  1:27 ` [PATCH 7/8] tracing: Show sample std dev in function profiling Steven Rostedt
2010-04-28  1:27 ` Steven Rostedt [this message]
2010-04-30  8:00 ` [PATCH 0/8] [GIT PULL] tracing: various updates Ingo Molnar
2010-04-30  9:47   ` Ingo Molnar

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=20100428013807.530671968@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.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