From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 09/13 -next] tracing/fgraph: Add max_graph_depth to limit function_graph depth
Date: Mon, 21 Jan 2013 16:14:12 -0500 [thread overview]
Message-ID: <20130121211728.725030853@goodmis.org> (raw)
In-Reply-To: 20130121211403.337052956@goodmis.org
[-- Attachment #1: 0009-tracing-fgraph-Add-max_graph_depth-to-limit-function.patch --]
[-- Type: text/plain, Size: 3121 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
Add the file max_graph_depth to the debug tracing directory that lets
the user define the depth of the function graph.
A very useful operation is to set the depth to 1. Then it traces only
the first function that is called when entering the kernel. This can
be used to determine what system operations interrupt a process.
For example, to work on NOHZ processes (single tasks running without
a timer tick), if any interrupt goes off and preempts that task, this
code will show it happening.
# cd /sys/kernel/debug/tracing
# echo 1 > max_graph_depth
# echo function_graph > current_tracer
# cat per_cpu/cpu/<cpu-of-process>/trace
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_functions_graph.c | 60 ++++++++++++++++++++++++++++++++--
1 file changed, 58 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 4edb4b7..7008d2e 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -47,6 +47,8 @@ struct fgraph_data {
#define TRACE_GRAPH_PRINT_ABS_TIME 0x20
#define TRACE_GRAPH_PRINT_IRQS 0x40
+static unsigned int max_depth;
+
static struct tracer_opt trace_opts[] = {
/* Display overruns? (for self-debug purpose) */
{ TRACER_OPT(funcgraph-overrun, TRACE_GRAPH_PRINT_OVERRUN) },
@@ -250,8 +252,9 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
return 0;
/* trace it when it is-nested-in or is a function enabled. */
- if (!(trace->depth || ftrace_graph_addr(trace->func)) ||
- ftrace_graph_ignore_irqs())
+ if ((!(trace->depth || ftrace_graph_addr(trace->func)) ||
+ ftrace_graph_ignore_irqs()) ||
+ (max_depth && trace->depth >= max_depth))
return 0;
local_irq_save(flags);
@@ -1457,6 +1460,59 @@ static struct tracer graph_trace __read_mostly = {
#endif
};
+
+static ssize_t
+graph_depth_write(struct file *filp, const char __user *ubuf, size_t cnt,
+ loff_t *ppos)
+{
+ unsigned long val;
+ int ret;
+
+ ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
+ if (ret)
+ return ret;
+
+ max_depth = val;
+
+ *ppos += cnt;
+
+ return cnt;
+}
+
+static ssize_t
+graph_depth_read(struct file *filp, char __user *ubuf, size_t cnt,
+ loff_t *ppos)
+{
+ char buf[15]; /* More than enough to hold UINT_MAX + "\n"*/
+ int n;
+
+ n = sprintf(buf, "%d\n", max_depth);
+
+ return simple_read_from_buffer(ubuf, cnt, ppos, buf, n);
+}
+
+static const struct file_operations graph_depth_fops = {
+ .open = tracing_open_generic,
+ .write = graph_depth_write,
+ .read = graph_depth_read,
+ .llseek = generic_file_llseek,
+};
+
+static __init int init_graph_debugfs(void)
+{
+ struct dentry *d_tracer;
+
+ d_tracer = tracing_init_dentry();
+ if (!d_tracer)
+ return 0;
+
+ trace_create_file("max_graph_depth", 0644, d_tracer,
+ NULL, &graph_depth_fops);
+
+ return 0;
+}
+fs_initcall(init_graph_debugfs);
+
static __init int init_graph_trace(void)
{
max_bytes_for_cpu = snprintf(NULL, 0, "%d", nr_cpu_ids - 1);
--
1.7.10.4
next prev parent reply other threads:[~2013-01-21 21:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-21 21:14 [PATCH 00/13 -next] [For linux-next] tracing: Review of changes Steven Rostedt
2013-01-21 21:14 ` [PATCH 01/13 -next] tracing: Fix sparse warning with is_signed_type() macro Steven Rostedt
2013-01-21 21:14 ` [PATCH 02/13 -next] ring-buffer: Remove unnecessary recusive call in rb_advance_iter() Steven Rostedt
2013-01-21 21:14 ` [PATCH 03/13 -next] tracing: Use this_cpu_ptr per-cpu helper Steven Rostedt
2013-01-21 21:14 ` [PATCH 04/13 -next] tracing: Verify target file before registering a uprobe event Steven Rostedt
2013-01-21 21:14 ` [PATCH 05/13 -next] tracing/syscalls: Make local functions static Steven Rostedt
2013-01-21 21:14 ` [PATCH 06/13 -next] tracing: Add checks if tr->buffer is NULL in tracing_reset{_online_cpus} Steven Rostedt
2013-01-21 21:14 ` [PATCH 07/13 -next] tracing: Remove unneeded check of max_tr->buffer before tracing_reset Steven Rostedt
2013-01-21 21:14 ` [PATCH 08/13 -next] tracing/lockdep: Disable lockdep first in entering NMI Steven Rostedt
2013-01-21 21:14 ` Steven Rostedt [this message]
2013-01-21 21:14 ` [PATCH 10/13 -next] ftrace: Move ARCH_SUPPORTS_FTRACE_SAVE_REGS in Kconfig Steven Rostedt
2013-01-21 21:14 ` [PATCH 11/13 -next] kprobes/x86: Move ftrace-based kprobe code into kprobes-ftrace.c Steven Rostedt
2013-01-21 21:14 ` [PATCH 12/13 -next] kprobes/x86: Move kprobes stuff under arch/x86/kernel/kprobes/ Steven Rostedt
2013-01-21 21:14 ` [PATCH 13/13 -next] tracing: Remove the extra 4 bytes of padding in events Steven Rostedt
2013-01-21 23:13 ` Arjan van de Ven
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=20130121211728.725030853@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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