Commit 515619f2 authored by Oleg Nesterov's avatar Oleg Nesterov

uprobes/perf: Avoid perf_trace_buf_prepare/submit if ->perf_events is 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: default avatarOleg Nesterov <oleg@redhat.com>
parent 32520b2c
...@@ -820,6 +820,10 @@ static void uprobe_perf_print(struct trace_uprobe *tu, ...@@ -820,6 +820,10 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
return; return;
preempt_disable(); 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); entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
if (!entry) if (!entry)
goto out; goto out;
...@@ -836,7 +840,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu, ...@@ -836,7 +840,6 @@ static void uprobe_perf_print(struct trace_uprobe *tu,
for (i = 0; i < tu->nr_args; i++) for (i = 0; i < tu->nr_args; i++)
call_fetch(&tu->args[i].fetch, regs, data + tu->args[i].offset); 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); perf_trace_buf_submit(entry, size, rctx, 0, 1, regs, head, NULL);
out: out:
preempt_enable(); preempt_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment