Commit a51cc604 authored by Oleg Nesterov's avatar Oleg Nesterov

uprobes/tracing: Introduce uprobe_{trace,perf}_print() helpers

Extract the output code from uprobe_trace_func() and uprobe_perf_func()
into the new helpers, they will be used by ->ret_handler() too. We also
add the unused "unsigned long func" argument in advance, to simplify the
next changes.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Tested-by: default avatarAnton Arapov <anton@redhat.com>
parent 457d1772
...@@ -497,8 +497,8 @@ static const struct file_operations uprobe_profile_ops = { ...@@ -497,8 +497,8 @@ static const struct file_operations uprobe_profile_ops = {
.release = seq_release, .release = seq_release,
}; };
/* uprobe handler */ static void uprobe_trace_print(struct trace_uprobe *tu,
static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs) unsigned long func, struct pt_regs *regs)
{ {
struct uprobe_trace_entry_head *entry; struct uprobe_trace_entry_head *entry;
struct ring_buffer_event *event; struct ring_buffer_event *event;
...@@ -511,7 +511,7 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs) ...@@ -511,7 +511,7 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
event = trace_current_buffer_lock_reserve(&buffer, call->event.type, event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
size, 0, 0); size, 0, 0);
if (!event) if (!event)
return 0; return;
entry = ring_buffer_event_data(event); entry = ring_buffer_event_data(event);
entry->vaddr[0] = instruction_pointer(regs); entry->vaddr[0] = instruction_pointer(regs);
...@@ -521,7 +521,12 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs) ...@@ -521,7 +521,12 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
if (!filter_current_check_discard(buffer, call, entry, event)) if (!filter_current_check_discard(buffer, call, entry, event))
trace_buffer_unlock_commit(buffer, event, 0, 0); trace_buffer_unlock_commit(buffer, event, 0, 0);
}
/* uprobe handler */
static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
{
uprobe_trace_print(tu, 0, regs);
return 0; return 0;
} }
...@@ -754,8 +759,8 @@ static bool uprobe_perf_filter(struct uprobe_consumer *uc, ...@@ -754,8 +759,8 @@ static bool uprobe_perf_filter(struct uprobe_consumer *uc,
return ret; return ret;
} }
/* uprobe profile handler */ static void uprobe_perf_print(struct trace_uprobe *tu,
static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs) unsigned long func, struct pt_regs *regs)
{ {
struct ftrace_event_call *call = &tu->call; struct ftrace_event_call *call = &tu->call;
struct uprobe_trace_entry_head *entry; struct uprobe_trace_entry_head *entry;
...@@ -764,13 +769,10 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs) ...@@ -764,13 +769,10 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
void *data; void *data;
int size, rctx, i; int size, rctx, i;
if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
return UPROBE_HANDLER_REMOVE;
size = SIZEOF_TRACE_ENTRY(false); size = SIZEOF_TRACE_ENTRY(false);
size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32); size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough")) if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
return 0; return;
preempt_disable(); preempt_disable();
entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx);
...@@ -787,6 +789,15 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs) ...@@ -787,6 +789,15 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
perf_trace_buf_submit(entry, size, rctx, ip, 1, regs, head, NULL); perf_trace_buf_submit(entry, size, rctx, ip, 1, regs, head, NULL);
out: out:
preempt_enable(); preempt_enable();
}
/* uprobe profile handler */
static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
{
if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
return UPROBE_HANDLER_REMOVE;
uprobe_perf_print(tu, 0, regs);
return 0; return 0;
} }
#endif /* CONFIG_PERF_EVENTS */ #endif /* CONFIG_PERF_EVENTS */
......
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