diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-02-04 17:16:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-05 08:35:46 -0500 |
commit | 268ccda0cb4d1292029d07ee3dbd07117baf6ecb (patch) | |
tree | 7683e02758d3f768ad21414abf39b00773e87940 /kernel | |
parent | 43769f10b4826376cbf4ce17af74a5b4e8dc4fcd (diff) |
trace: assign defaults at register_ftrace_event
Impact: simplification of tracers
As all tracers are doing this we might as well do it in
register_ftrace_event and save one branch each time we call these
callbacks.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 13 | ||||
-rw-r--r-- | kernel/trace/trace_branch.c | 3 | ||||
-rw-r--r-- | kernel/trace/trace_output.c | 13 |
3 files changed, 16 insertions, 13 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index fd51cf0b94c7..a5e4c0af9bb0 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -1412,7 +1412,7 @@ static enum print_line_t print_lat_fmt(struct trace_iterator *iter) | |||
1412 | goto partial; | 1412 | goto partial; |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | if (event && event->latency_trace) | 1415 | if (event) |
1416 | return event->latency_trace(iter, sym_flags); | 1416 | return event->latency_trace(iter, sym_flags); |
1417 | 1417 | ||
1418 | if (!trace_seq_printf(s, "Unknown type %d\n", entry->type)) | 1418 | if (!trace_seq_printf(s, "Unknown type %d\n", entry->type)) |
@@ -1441,7 +1441,7 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter) | |||
1441 | goto partial; | 1441 | goto partial; |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | if (event && event->trace) | 1444 | if (event) |
1445 | return event->trace(iter, sym_flags); | 1445 | return event->trace(iter, sym_flags); |
1446 | 1446 | ||
1447 | if (!trace_seq_printf(s, "Unknown type %d\n", entry->type)) | 1447 | if (!trace_seq_printf(s, "Unknown type %d\n", entry->type)) |
@@ -1467,7 +1467,7 @@ static enum print_line_t print_raw_fmt(struct trace_iterator *iter) | |||
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | event = ftrace_find_event(entry->type); | 1469 | event = ftrace_find_event(entry->type); |
1470 | if (event && event->raw) | 1470 | if (event) |
1471 | return event->raw(iter, 0); | 1471 | return event->raw(iter, 0); |
1472 | 1472 | ||
1473 | if (!trace_seq_printf(s, "%d ?\n", entry->type)) | 1473 | if (!trace_seq_printf(s, "%d ?\n", entry->type)) |
@@ -1494,7 +1494,7 @@ static enum print_line_t print_hex_fmt(struct trace_iterator *iter) | |||
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | event = ftrace_find_event(entry->type); | 1496 | event = ftrace_find_event(entry->type); |
1497 | if (event && event->hex) { | 1497 | if (event) { |
1498 | enum print_line_t ret = event->hex(iter, 0); | 1498 | enum print_line_t ret = event->hex(iter, 0); |
1499 | if (ret != TRACE_TYPE_HANDLED) | 1499 | if (ret != TRACE_TYPE_HANDLED) |
1500 | return ret; | 1500 | return ret; |
@@ -1536,10 +1536,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter) | |||
1536 | } | 1536 | } |
1537 | 1537 | ||
1538 | event = ftrace_find_event(entry->type); | 1538 | event = ftrace_find_event(entry->type); |
1539 | if (event && event->binary) | 1539 | return event ? event->binary(iter, 0) : TRACE_TYPE_HANDLED; |
1540 | return event->binary(iter, 0); | ||
1541 | |||
1542 | return TRACE_TYPE_HANDLED; | ||
1543 | } | 1540 | } |
1544 | 1541 | ||
1545 | static int trace_empty(struct trace_iterator *iter) | 1542 | static int trace_empty(struct trace_iterator *iter) |
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c index 7ac72a44b2d3..297deb202b68 100644 --- a/kernel/trace/trace_branch.c +++ b/kernel/trace/trace_branch.c | |||
@@ -182,9 +182,6 @@ static struct trace_event trace_branch_event = { | |||
182 | .type = TRACE_BRANCH, | 182 | .type = TRACE_BRANCH, |
183 | .trace = trace_branch_print, | 183 | .trace = trace_branch_print, |
184 | .latency_trace = trace_branch_print, | 184 | .latency_trace = trace_branch_print, |
185 | .raw = trace_nop_print, | ||
186 | .hex = trace_nop_print, | ||
187 | .binary = trace_nop_print, | ||
188 | }; | 185 | }; |
189 | 186 | ||
190 | static struct tracer branch_trace __read_mostly = | 187 | static struct tracer branch_trace __read_mostly = |
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index b7380eee9fa1..b6e99af79214 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c | |||
@@ -435,6 +435,17 @@ int register_ftrace_event(struct trace_event *event) | |||
435 | if (ftrace_find_event(event->type)) | 435 | if (ftrace_find_event(event->type)) |
436 | goto out; | 436 | goto out; |
437 | 437 | ||
438 | if (event->trace == NULL) | ||
439 | event->trace = trace_nop_print; | ||
440 | if (event->latency_trace == NULL) | ||
441 | event->latency_trace = trace_nop_print; | ||
442 | if (event->raw == NULL) | ||
443 | event->raw = trace_nop_print; | ||
444 | if (event->hex == NULL) | ||
445 | event->hex = trace_nop_print; | ||
446 | if (event->binary == NULL) | ||
447 | event->binary = trace_nop_print; | ||
448 | |||
438 | key = event->type & (EVENT_HASHSIZE - 1); | 449 | key = event->type & (EVENT_HASHSIZE - 1); |
439 | 450 | ||
440 | hlist_add_head_rcu(&event->node, &event_hash[key]); | 451 | hlist_add_head_rcu(&event->node, &event_hash[key]); |
@@ -874,8 +885,6 @@ static struct trace_event trace_print_event = { | |||
874 | .trace = trace_print_print, | 885 | .trace = trace_print_print, |
875 | .latency_trace = trace_print_print, | 886 | .latency_trace = trace_print_print, |
876 | .raw = trace_print_raw, | 887 | .raw = trace_print_raw, |
877 | .hex = trace_nop_print, | ||
878 | .binary = trace_nop_print, | ||
879 | }; | 888 | }; |
880 | 889 | ||
881 | static struct trace_event *events[] __initdata = { | 890 | static struct trace_event *events[] __initdata = { |