aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2010-08-05 10:22:23 -0400
committerJason Wessel <jason.wessel@windriver.com>2010-08-05 10:22:23 -0400
commit19063c776fe745fab11216422cf56489ee83b452 (patch)
treea08994bd7badecc81ac04f4b6c4732986dea8588
parent955b61e597984745fb7d34c75708f6503b6aaeab (diff)
ftrace,kdb: Allow dumping a specific cpu's buffer with ftdump
In systems with more than one processor it is desirable to look at the per cpu trace buffers. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> CC: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r--kernel/trace/trace_kdb.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c
index 44cbda25b0a5..7b8ecd751d93 100644
--- a/kernel/trace/trace_kdb.c
+++ b/kernel/trace/trace_kdb.c
@@ -17,7 +17,7 @@
17#include "trace.h" 17#include "trace.h"
18#include "trace_output.h" 18#include "trace_output.h"
19 19
20static void ftrace_dump_buf(int skip_lines) 20static void ftrace_dump_buf(int skip_lines, long cpu_file)
21{ 21{
22 /* use static because iter can be a bit big for the stack */ 22 /* use static because iter can be a bit big for the stack */
23 static struct trace_iterator iter; 23 static struct trace_iterator iter;
@@ -44,13 +44,20 @@ static void ftrace_dump_buf(int skip_lines)
44 iter.iter_flags |= TRACE_FILE_LAT_FMT; 44 iter.iter_flags |= TRACE_FILE_LAT_FMT;
45 iter.pos = -1; 45 iter.pos = -1;
46 46
47 for_each_tracing_cpu(cpu) { 47 if (cpu_file == TRACE_PIPE_ALL_CPU) {
48 iter.buffer_iter[cpu] = 48 for_each_tracing_cpu(cpu) {
49 iter.buffer_iter[cpu] =
49 ring_buffer_read_prepare(iter.tr->buffer, cpu); 50 ring_buffer_read_prepare(iter.tr->buffer, cpu);
50 ring_buffer_read_start(iter.buffer_iter[cpu]); 51 ring_buffer_read_start(iter.buffer_iter[cpu]);
51 tracing_iter_reset(&iter, cpu); 52 tracing_iter_reset(&iter, cpu);
53 }
54 } else {
55 iter.cpu_file = cpu_file;
56 iter.buffer_iter[cpu_file] =
57 ring_buffer_read_prepare(iter.tr->buffer, cpu_file);
58 ring_buffer_read_start(iter.buffer_iter[cpu_file]);
59 tracing_iter_reset(&iter, cpu_file);
52 } 60 }
53
54 if (!trace_empty(&iter)) 61 if (!trace_empty(&iter))
55 trace_find_next_entry_inc(&iter); 62 trace_find_next_entry_inc(&iter);
56 while (!trace_empty(&iter)) { 63 while (!trace_empty(&iter)) {
@@ -91,9 +98,10 @@ out:
91static int kdb_ftdump(int argc, const char **argv) 98static int kdb_ftdump(int argc, const char **argv)
92{ 99{
93 int skip_lines = 0; 100 int skip_lines = 0;
101 long cpu_file;
94 char *cp; 102 char *cp;
95 103
96 if (argc > 1) 104 if (argc > 2)
97 return KDB_ARGCOUNT; 105 return KDB_ARGCOUNT;
98 106
99 if (argc) { 107 if (argc) {
@@ -102,8 +110,17 @@ static int kdb_ftdump(int argc, const char **argv)
102 skip_lines = 0; 110 skip_lines = 0;
103 } 111 }
104 112
113 if (argc == 2) {
114 cpu_file = simple_strtol(argv[2], &cp, 0);
115 if (*cp || cpu_file >= NR_CPUS || cpu_file < 0 ||
116 !cpu_online(cpu_file))
117 return KDB_BADINT;
118 } else {
119 cpu_file = TRACE_PIPE_ALL_CPU;
120 }
121
105 kdb_trap_printk++; 122 kdb_trap_printk++;
106 ftrace_dump_buf(skip_lines); 123 ftrace_dump_buf(skip_lines, cpu_file);
107 kdb_trap_printk--; 124 kdb_trap_printk--;
108 125
109 return 0; 126 return 0;
@@ -111,8 +128,8 @@ static int kdb_ftdump(int argc, const char **argv)
111 128
112static __init int kdb_ftrace_register(void) 129static __init int kdb_ftrace_register(void)
113{ 130{
114 kdb_register_repeat("ftdump", kdb_ftdump, "", "Dump ftrace log", 131 kdb_register_repeat("ftdump", kdb_ftdump, "[skip_#lines] [cpu]",
115 0, KDB_REPEAT_NONE); 132 "Dump ftrace log", 0, KDB_REPEAT_NONE);
116 return 0; 133 return 0;
117} 134}
118 135