Skip to content

Commit

Permalink
trace: assign defaults at register_ftrace_event
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Feb 5, 2009
1 parent 43769f1 commit 268ccda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 0 additions & 2 deletions block/blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
13 changes: 5 additions & 8 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions kernel/trace/trace_branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
13 changes: 11 additions & 2 deletions kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 268ccda

Please sign in to comment.