aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-08-18 21:58:48 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-08-18 21:58:48 -0400
commit5dfeb30713b36a50240b7097f4c259613325040f (patch)
tree3b10801a50716867937287c78d01c45f8956dd95
parent2abe40f1f18372b7a4b764e9d4fe783d0cee789f (diff)
trace-cmd: Record CPU trace stats before disable all
The disable_all() function is called before we print out the per cpu buffer stats. But the disable_all() function also resets those same stats so the output is useless. Instead of printing out the stats while tracing is still active (although tracing_on is off), record the stats into individual per cpu trace_seq buffers and then still print when all has been disabled. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-record.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/trace-record.c b/trace-record.c
index 62758e8..45439f4 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -1426,8 +1426,6 @@ static void start_threads(void)
1426{ 1426{
1427 int i; 1427 int i;
1428 1428
1429 cpu_count = count_cpus();
1430
1431 if (host) 1429 if (host)
1432 setup_network(); 1430 setup_network();
1433 1431
@@ -1905,7 +1903,7 @@ void trace_record (int argc, char **argv)
1905 struct event_list *event; 1903 struct event_list *event;
1906 struct event_list *last_event; 1904 struct event_list *last_event;
1907 struct tracecmd_event_list *list; 1905 struct tracecmd_event_list *list;
1908 struct trace_seq s; 1906 struct trace_seq *s;
1909 char *date2ts = NULL; 1907 char *date2ts = NULL;
1910 int record_all = 0; 1908 int record_all = 0;
1911 int disable = 0; 1909 int disable = 0;
@@ -1921,6 +1919,8 @@ void trace_record (int argc, char **argv)
1921 1919
1922 int c; 1920 int c;
1923 1921
1922 cpu_count = count_cpus();
1923
1924 if ((record = (strcmp(argv[1], "record") == 0))) 1924 if ((record = (strcmp(argv[1], "record") == 0)))
1925 ; /* do nothing */ 1925 ; /* do nothing */
1926 else if (strcmp(argv[1], "start") == 0) 1926 else if (strcmp(argv[1], "start") == 0)
@@ -2184,6 +2184,8 @@ void trace_record (int argc, char **argv)
2184 2184
2185 set_options(); 2185 set_options();
2186 2186
2187 s = malloc_or_die(sizeof(*s) * cpu_count);
2188
2187 if (record || extract) { 2189 if (record || extract) {
2188 signal(SIGINT, finish); 2190 signal(SIGINT, finish);
2189 if (!latency) 2191 if (!latency)
@@ -2219,6 +2221,11 @@ void trace_record (int argc, char **argv)
2219 2221
2220 stop_threads(); 2222 stop_threads();
2221 2223
2224 for (cpu = 0; cpu < cpu_count; cpu++) {
2225 trace_seq_init(&s[cpu]);
2226 trace_seq_printf(&s[cpu], "CPU: %d\n", cpu);
2227 tracecmd_stat_cpu(&s[cpu], cpu);
2228 }
2222 2229
2223 if (!keep) 2230 if (!keep)
2224 disable_all(); 2231 disable_all();
@@ -2227,14 +2234,12 @@ void trace_record (int argc, char **argv)
2227 " Note: \"entries\" are the entries left in the kernel ring buffer and are not\n" 2234 " Note: \"entries\" are the entries left in the kernel ring buffer and are not\n"
2228 " recorded in the trace data. They should all be zero.\n\n"); 2235 " recorded in the trace data. They should all be zero.\n\n");
2229 for (cpu = 0; cpu < cpu_count; cpu++) { 2236 for (cpu = 0; cpu < cpu_count; cpu++) {
2230 trace_seq_init(&s); 2237 trace_seq_do_printf(&s[cpu]);
2231 trace_seq_printf(&s, "CPU: %d\n", cpu); 2238 trace_seq_destroy(&s[cpu]);
2232 tracecmd_stat_cpu(&s, cpu);
2233 trace_seq_do_printf(&s);
2234 trace_seq_destroy(&s);
2235 printf("\n"); 2239 printf("\n");
2236 } 2240 }
2237 2241
2242
2238 /* extract records the date after extraction */ 2243 /* extract records the date after extraction */
2239 if (extract && date) 2244 if (extract && date)
2240 date2ts = get_date_to_ts(); 2245 date2ts = get_date_to_ts();