summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-02-04 20:16:39 -0200
committerIngo Molnar <mingo@elte.hu>2009-02-05 14:35:46 +0100
commit268ccda0cb4d1292029d07ee3dbd07117baf6ecb (patch)
tree7683e02758d3f768ad21414abf39b00773e87940
parent43769f10b4826376cbf4ce17af74a5b4e8dc4fcd (diff)
downloadlinux-3.10-268ccda0cb4d1292029d07ee3dbd07117baf6ecb.tar.gz
linux-3.10-268ccda0cb4d1292029d07ee3dbd07117baf6ecb.tar.bz2
linux-3.10-268ccda0cb4d1292029d07ee3dbd07117baf6ecb.zip
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>
-rw-r--r--block/blktrace.c2
-rw-r--r--kernel/trace/trace.c13
-rw-r--r--kernel/trace/trace_branch.c3
-rw-r--r--kernel/trace/trace_output.c13
4 files changed, 16 insertions, 15 deletions
diff --git a/block/blktrace.c b/block/blktrace.c
index c7698d1617a..1ebd068061e 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -1243,8 +1243,6 @@ static struct trace_event trace_blk_event = {
.type = TRACE_BLK,
.trace = blk_trace_event_print,
.latency_trace = blk_trace_event_print,
- .raw = trace_nop_print,
- .hex = trace_nop_print,
.binary = blk_trace_event_print_binary,
};
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index fd51cf0b94c..a5e4c0af9bb 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)
goto partial;
}
- if (event && event->latency_trace)
+ if (event)
return event->latency_trace(iter, sym_flags);
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)
goto partial;
}
- if (event && event->trace)
+ if (event)
return event->trace(iter, sym_flags);
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)
}
event = ftrace_find_event(entry->type);
- if (event && event->raw)
+ if (event)
return event->raw(iter, 0);
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)
}
event = ftrace_find_event(entry->type);
- if (event && event->hex) {
+ if (event) {
enum print_line_t ret = event->hex(iter, 0);
if (ret != TRACE_TYPE_HANDLED)
return ret;
@@ -1536,10 +1536,7 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
}
event = ftrace_find_event(entry->type);
- if (event && event->binary)
- return event->binary(iter, 0);
-
- return TRACE_TYPE_HANDLED;
+ return event ? event->binary(iter, 0) : TRACE_TYPE_HANDLED;
}
static int trace_empty(struct trace_iterator *iter)
diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
index 7ac72a44b2d..297deb202b6 100644
--- a/kernel/trace/trace_branch.c
+++ b/kernel/trace/trace_branch.c
@@ -182,9 +182,6 @@ static struct trace_event trace_branch_event = {
.type = TRACE_BRANCH,
.trace = trace_branch_print,
.latency_trace = trace_branch_print,
- .raw = trace_nop_print,
- .hex = trace_nop_print,
- .binary = trace_nop_print,
};
static struct tracer branch_trace __read_mostly =
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index b7380eee9fa..b6e99af7921 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)
if (ftrace_find_event(event->type))
goto out;
+ if (event->trace == NULL)
+ event->trace = trace_nop_print;
+ if (event->latency_trace == NULL)
+ event->latency_trace = trace_nop_print;
+ if (event->raw == NULL)
+ event->raw = trace_nop_print;
+ if (event->hex == NULL)
+ event->hex = trace_nop_print;
+ if (event->binary == NULL)
+ event->binary = trace_nop_print;
+
key = event->type & (EVENT_HASHSIZE - 1);
hlist_add_head_rcu(&event->node, &event_hash[key]);
@@ -874,8 +885,6 @@ static struct trace_event trace_print_event = {
.trace = trace_print_print,
.latency_trace = trace_print_print,
.raw = trace_print_raw,
- .hex = trace_nop_print,
- .binary = trace_nop_print,
};
static struct trace_event *events[] __initdata = {