Skip to content

Commit

Permalink
uprobes/perf: Avoid perf_trace_buf_prepare/submit if ->perf_events is…
Browse files Browse the repository at this point in the history
… empty

perf_trace_buf_prepare() + perf_trace_buf_submit() make no sense
if this task/CPU has no active counters. Change uprobe_perf_print()
to return if hlist_empty(call->perf_events).

Note: this is not uprobe-specific, we can change other users too.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
  • Loading branch information
Oleg Nesterov committed Apr 15, 2013
1 parent 32520b2 commit 515619f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/trace/trace_uprobe.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,10 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
return;

preempt_disable();
head = this_cpu_ptr(call->perf_events);
if (hlist_empty(head))
goto out;

entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
if (!entry)
goto out;
Expand All @@ -836,7 +840,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
for (i = 0; i < tu->nr_args; i++)
call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset);

head = this_cpu_ptr(call->perf_events);
perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
out:
preempt_enable();
Expand Down

0 comments on commit 515619f

Please sign in to comment.