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>,
Peter Zijlstra <peterz@infradead.org>,
Arjan van de Ven <arjan@infradead.org>,
Dave Hansen <dave@linux.vnet.ibm.com>,
containers@lists.osdl.org, Eric Biederman <ebiederm@xmission.com>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
"Serge E. Hallyn" <serue@us.ibm.com>,
Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 3/3] ftrace: trace single pid for function graph tracer
Date: Wed, 03 Dec 2008 15:36:59 -0500 [thread overview]
Message-ID: <20081203203829.362295724@goodmis.org> (raw)
In-Reply-To: 20081203203656.776893226@goodmis.org
[-- Attachment #1: 0003-ftrace-trace-single-pid-for-function-graph-tracer.patch --]
[-- Type: text/plain, Size: 1953 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Impact: New feature
This patch makes the changes to set_ftrace_pid apply to the function
graph tracer.
# echo $$ > /debugfs/tracing/set_ftrace_pid
# echo function_graph > /debugfs/tracing/current_tracer
Will cause only the current task to be traced. Note, the trace flags are
also inherited by child processes, so the children of the shell
will also be traced.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
kernel/trace/ftrace.c | 2 +-
kernel/trace/trace.c | 3 +++
kernel/trace/trace.h | 10 ++++++++++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c5049f5..57592a9 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -48,7 +48,7 @@ int ftrace_enabled __read_mostly;
static int last_ftrace_enabled;
/* set when tracing only a pid */
-static int ftrace_pid_trace = -1;
+int ftrace_pid_trace = -1;
/* Quick disabling of function tracer. */
int function_trace_stop;
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 710b39a..1bd9574 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1209,6 +1209,9 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
int cpu;
int pc;
+ if (!ftrace_trace_task(current))
+ return 0;
+
if (!ftrace_graph_addr(trace->func))
return 0;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 41f026b..95fff37 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -541,6 +541,16 @@ print_graph_function(struct trace_iterator *iter)
}
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+extern int ftrace_pid_trace;
+
+static inline int ftrace_trace_task(struct task_struct *task)
+{
+ if (ftrace_pid_trace < 0)
+ return 1;
+
+ return test_tsk_trace_trace(task);
+}
+
/*
* trace_iterator_flags is an enumeration that defines bit
* positions into trace_flags that controls the output.
--
1.5.6.5
--
next prev parent reply other threads:[~2008-12-03 20:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-03 20:36 [PATCH 0/3] ftrace: updates for tip Steven Rostedt
2008-12-03 20:36 ` [PATCH 1/3] ftrace: graph of a single function Steven Rostedt
2008-12-03 21:07 ` Andrew Morton
2008-12-03 21:10 ` Steven Rostedt
2008-12-03 21:32 ` Andrew Morton
2008-12-03 21:36 ` Steven Rostedt
2008-12-04 8:39 ` Ingo Molnar
2008-12-03 21:08 ` Andrew Morton
2008-12-03 21:11 ` Steven Rostedt
2008-12-04 8:41 ` Ingo Molnar
2008-12-04 8:43 ` Peter Zijlstra
2008-12-15 9:21 ` Andy Whitcroft
2008-12-04 6:24 ` [PATCH 1/1] ftrace: avoid duplicated function when writing set_graph_function Liming Wang
2008-12-04 8:42 ` Ingo Molnar
2008-12-03 20:36 ` [PATCH 2/3] ftrace: use task struct trace flag to filter on pid Steven Rostedt
2008-12-03 22:34 ` Eric W. Biederman
2008-12-03 20:36 ` Steven Rostedt [this message]
2008-12-03 20:49 ` [PATCH 3/3] ftrace: trace single pid for function graph tracer Andrew Morton
2008-12-03 20:52 ` Steven Rostedt
2008-12-03 23:36 ` Eric W. Biederman
2008-12-04 2:29 ` Steven Rostedt
2008-12-04 4:22 ` Eric W. Biederman
2008-12-04 4:32 ` Steven Rostedt
2008-12-04 8:19 ` [PATCH 0/3] ftrace: updates for tip Ingo Molnar
2008-12-04 8:35 ` Ingo Molnar
2008-12-04 13:30 ` Steven Rostedt
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=20081203203829.362295724@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=arjan@infradead.org \
--cc=containers@lists.osdl.org \
--cc=dave@linux.vnet.ibm.com \
--cc=ebiederm@xmission.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=serue@us.ibm.com \
--cc=srostedt@redhat.com \
--cc=sukadev@linux.vnet.ibm.com \
/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