diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2008-11-26 00:16:27 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-26 00:52:57 -0500 |
commit | 437f24fb897d409a9978eb71ecfaf279dcd94acd (patch) | |
tree | 6d84f5f7f3000c5560000c8c29a3af4494ffd0f7 | |
parent | 660c7f9be96321fc80026d76411bd15e6f418a72 (diff) |
ftrace: add cpu annotation for function graph tracer
Impact: enhancement for function graph tracer
When run on a SMP box, the function graph tracer is confusing because
it shows the different CPUS as changes in the trace.
This patch adds the annotation of 'CPU[###]' where ### is a three digit
number. The output will look similar to this:
CPU[001] dput() {
CPU[000] } 726
CPU[001] } 487
CPU[000] do_softirq() {
CPU[001] } 2221
CPU[000] __do_softirq() {
CPU[000] __local_bh_disable() {
CPU[001] unroll_tree_refs() {
CPU[000] } 569
CPU[001] } 501
CPU[000] rcu_process_callbacks() {
CPU[001] kfree() {
What makes this nice is that now you can grep the file and produce
readable format for a particular CPU.
# cat /debug/tracing/trace > /tmp/trace
# grep '^CPU\[000\]' /tmp/trace > /tmp/trace0
# grep '^CPU\[001\]' /tmp/trace > /tmp/trace1
Will give you:
# head /tmp/trace0
CPU[000] ------------8<---------- thread sshd-3899 ------------8<----------
CPU[000] inotify_dentry_parent_queue_event() {
CPU[000] } 2531
CPU[000] inotify_inode_queue_event() {
CPU[000] } 505
CPU[000] } 69626
CPU[000] } 73089
CPU[000] audit_syscall_exit() {
CPU[000] path_put() {
CPU[000] dput() {
# head /tmp/trace1
CPU[001] ------------8<---------- thread pcscd-3446 ------------8<----------
CPU[001] } 4186
CPU[001] dput() {
CPU[001] } 543
CPU[001] vfs_permission() {
CPU[001] inode_permission() {
CPU[001] shmem_permission() {
CPU[001] generic_permission() {
CPU[001] } 501
CPU[001] } 2205
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/trace/trace_functions_graph.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index bbb81e7b6c4..d31d695174a 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c | |||
@@ -28,7 +28,7 @@ static struct tracer_flags tracer_flags = { | |||
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* pid on the last trace processed */ | 30 | /* pid on the last trace processed */ |
31 | static pid_t last_pid = -1; | 31 | static pid_t last_pid[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 }; |
32 | 32 | ||
33 | static int graph_trace_init(struct trace_array *tr) | 33 | static int graph_trace_init(struct trace_array *tr) |
34 | { | 34 | { |
@@ -53,29 +53,34 @@ static void graph_trace_reset(struct trace_array *tr) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | /* If the pid changed since the last trace, output this event */ | 55 | /* If the pid changed since the last trace, output this event */ |
56 | static int verif_pid(struct trace_seq *s, pid_t pid) | 56 | static int verif_pid(struct trace_seq *s, pid_t pid, int cpu) |
57 | { | 57 | { |
58 | char *comm; | 58 | char *comm; |
59 | 59 | ||
60 | if (last_pid != -1 && last_pid == pid) | 60 | if (last_pid[cpu] != -1 && last_pid[cpu] == pid) |
61 | return 1; | 61 | return 1; |
62 | 62 | ||
63 | last_pid = pid; | 63 | last_pid[cpu] = pid; |
64 | comm = trace_find_cmdline(pid); | 64 | comm = trace_find_cmdline(pid); |
65 | 65 | ||
66 | return trace_seq_printf(s, "\n------------8<---------- thread %s-%d" | 66 | return trace_seq_printf(s, "\nCPU[%03d]" |
67 | " ------------8<---------- thread %s-%d" | ||
67 | " ------------8<----------\n\n", | 68 | " ------------8<----------\n\n", |
68 | comm, pid); | 69 | cpu, comm, pid); |
69 | } | 70 | } |
70 | 71 | ||
71 | static enum print_line_t | 72 | static enum print_line_t |
72 | print_graph_entry(struct ftrace_graph_ent *call, struct trace_seq *s, | 73 | print_graph_entry(struct ftrace_graph_ent *call, struct trace_seq *s, |
73 | struct trace_entry *ent) | 74 | struct trace_entry *ent, int cpu) |
74 | { | 75 | { |
75 | int i; | 76 | int i; |
76 | int ret; | 77 | int ret; |
77 | 78 | ||
78 | if (!verif_pid(s, ent->pid)) | 79 | if (!verif_pid(s, ent->pid, cpu)) |
80 | return TRACE_TYPE_PARTIAL_LINE; | ||
81 | |||
82 | ret = trace_seq_printf(s, "CPU[%03d] ", cpu); | ||
83 | if (!ret) | ||
79 | return TRACE_TYPE_PARTIAL_LINE; | 84 | return TRACE_TYPE_PARTIAL_LINE; |
80 | 85 | ||
81 | for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { | 86 | for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) { |
@@ -96,12 +101,16 @@ print_graph_entry(struct ftrace_graph_ent *call, struct trace_seq *s, | |||
96 | 101 | ||
97 | static enum print_line_t | 102 | static enum print_line_t |
98 | print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, | 103 | print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, |
99 | struct trace_entry *ent) | 104 | struct trace_entry *ent, int cpu) |
100 | { | 105 | { |
101 | int i; | 106 | int i; |
102 | int ret; | 107 | int ret; |
103 | 108 | ||
104 | if (!verif_pid(s, ent->pid)) | 109 | if (!verif_pid(s, ent->pid, cpu)) |
110 | return TRACE_TYPE_PARTIAL_LINE; | ||
111 | |||
112 | ret = trace_seq_printf(s, "CPU[%03d] ", cpu); | ||
113 | if (!ret) | ||
105 | return TRACE_TYPE_PARTIAL_LINE; | 114 | return TRACE_TYPE_PARTIAL_LINE; |
106 | 115 | ||
107 | for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { | 116 | for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) { |
@@ -137,12 +146,13 @@ print_graph_function(struct trace_iterator *iter) | |||
137 | case TRACE_GRAPH_ENT: { | 146 | case TRACE_GRAPH_ENT: { |
138 | struct ftrace_graph_ent_entry *field; | 147 | struct ftrace_graph_ent_entry *field; |
139 | trace_assign_type(field, entry); | 148 | trace_assign_type(field, entry); |
140 | return print_graph_entry(&field->graph_ent, s, entry); | 149 | return print_graph_entry(&field->graph_ent, s, entry, |
150 | iter->cpu); | ||
141 | } | 151 | } |
142 | case TRACE_GRAPH_RET: { | 152 | case TRACE_GRAPH_RET: { |
143 | struct ftrace_graph_ret_entry *field; | 153 | struct ftrace_graph_ret_entry *field; |
144 | trace_assign_type(field, entry); | 154 | trace_assign_type(field, entry); |
145 | return print_graph_return(&field->ret, s, entry); | 155 | return print_graph_return(&field->ret, s, entry, iter->cpu); |
146 | } | 156 | } |
147 | default: | 157 | default: |
148 | return TRACE_TYPE_UNHANDLED; | 158 | return TRACE_TYPE_UNHANDLED; |