aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-09-11 14:24:13 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-09-11 14:24:13 -0400
commitf81c972d27c36729e65d4a815e3d7b782a540bad (patch)
treecc3ad7478f09e47914ffa9b5b9d9c1a7b990c60b
parent637e7e864103a7a68c1ce43ada27dfc25c0d113f (diff)
tracing: consolidate code between trace_output.c and trace_function_graph.c
Both trace_output.c and trace_function_graph.c do basically the same thing to handle the printing of the latency-format. This patch moves the code into one function that both can use. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace_functions_graph.c26
-rw-r--r--kernel/trace/trace_output.c30
-rw-r--r--kernel/trace/trace_output.h2
3 files changed, 28 insertions, 30 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 48af49374384..61f166707a08 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -367,32 +367,10 @@ print_graph_proc(struct trace_seq *s, pid_t pid)
367static enum print_line_t 367static enum print_line_t
368print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry) 368print_graph_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
369{ 369{
370 int hardirq, softirq; 370 if (!trace_seq_putc(s, ' '))
371 int ret;
372
373 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
374 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
375
376 if (!trace_seq_printf(s, " %c%c%c",
377 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
378 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
379 'X' : '.',
380 (entry->flags & TRACE_FLAG_NEED_RESCHED) ?
381 'N' : '.',
382 (hardirq && softirq) ? 'H' :
383 hardirq ? 'h' : softirq ? 's' : '.'))
384 return 0;
385
386 if (entry->lock_depth < 0)
387 ret = trace_seq_putc(s, '.');
388 else
389 ret = trace_seq_printf(s, "%d", entry->lock_depth);
390 if (!ret)
391 return 0; 371 return 0;
392 372
393 if (entry->preempt_count) 373 return trace_print_lat_fmt(s, entry);
394 return trace_seq_printf(s, "%x", entry->preempt_count);
395 return trace_seq_puts(s, ".");
396} 374}
397 375
398/* If the pid changed since the last trace, output this event */ 376/* If the pid changed since the last trace, output this event */
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 29a370a45582..f572f44c6e1e 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -460,19 +460,23 @@ seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
460 return ret; 460 return ret;
461} 461}
462 462
463static int 463/**
464lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu) 464 * trace_print_lat_fmt - print the irq, preempt and lockdep fields
465 * @s: trace seq struct to write to
466 * @entry: The trace entry field from the ring buffer
467 *
468 * Prints the generic fields of irqs off, in hard or softirq, preempt
469 * count and lock depth.
470 */
471int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
465{ 472{
466 int hardirq, softirq; 473 int hardirq, softirq;
467 char comm[TASK_COMM_LEN];
468 int ret; 474 int ret;
469 475
470 trace_find_cmdline(entry->pid, comm);
471 hardirq = entry->flags & TRACE_FLAG_HARDIRQ; 476 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
472 softirq = entry->flags & TRACE_FLAG_SOFTIRQ; 477 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
473 478
474 if (!trace_seq_printf(s, "%8.8s-%-5d %3d%c%c%c", 479 if (!trace_seq_printf(s, "%c%c%c",
475 comm, entry->pid, cpu,
476 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' : 480 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
477 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 481 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ?
478 'X' : '.', 482 'X' : '.',
@@ -494,6 +498,20 @@ lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
494 return trace_seq_putc(s, '.'); 498 return trace_seq_putc(s, '.');
495} 499}
496 500
501static int
502lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
503{
504 char comm[TASK_COMM_LEN];
505
506 trace_find_cmdline(entry->pid, comm);
507
508 if (!trace_seq_printf(s, "%8.8s-%-5d %3d",
509 comm, entry->pid, cpu))
510 return 0;
511
512 return trace_print_lat_fmt(s, entry);
513}
514
497static unsigned long preempt_mark_thresh = 100; 515static unsigned long preempt_mark_thresh = 100;
498 516
499static int 517static int
diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h
index d38bec4a9c30..9d91c72ba38b 100644
--- a/kernel/trace/trace_output.h
+++ b/kernel/trace/trace_output.h
@@ -26,6 +26,8 @@ extern struct trace_event *ftrace_find_event(int type);
26 26
27extern enum print_line_t trace_nop_print(struct trace_iterator *iter, 27extern enum print_line_t trace_nop_print(struct trace_iterator *iter,
28 int flags); 28 int flags);
29extern int
30trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry);
29 31
30/* used by module unregistering */ 32/* used by module unregistering */
31extern int __unregister_ftrace_event(struct trace_event *event); 33extern int __unregister_ftrace_event(struct trace_event *event);