aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-03-30 13:02:12 -0400
committerOleg Nesterov <oleg@redhat.com>2013-04-13 09:32:01 -0400
commita51cc6041773dd88ff35608f54274bfd6ac68652 (patch)
treeb7969268db40338d42c29d8ffb1787041d7d6760 /kernel
parent457d1772f1c1bcf37b2ae7fc8f1d6f303d1d5cf9 (diff)
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: Oleg Nesterov <oleg@redhat.com> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com> Tested-by: Anton Arapov <anton@redhat.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_uprobe.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 49b400368bfd..0c0f0a7d4ff1 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -497,8 +497,8 @@ static const struct file_operations uprobe_profile_ops = {
497 .release = seq_release, 497 .release = seq_release,
498}; 498};
499 499
500/* uprobe handler */ 500static void uprobe_trace_print(struct trace_uprobe *tu,
501static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs) 501 unsigned long func, struct pt_regs *regs)
502{ 502{
503 struct uprobe_trace_entry_head *entry; 503 struct uprobe_trace_entry_head *entry;
504 struct ring_buffer_event *event; 504 struct ring_buffer_event *event;
@@ -511,7 +511,7 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
511 event = trace_current_buffer_lock_reserve(&buffer, call->event.type, 511 event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
512 size, 0, 0); 512 size, 0, 0);
513 if (!event) 513 if (!event)
514 return 0; 514 return;
515 515
516 entry = ring_buffer_event_data(event); 516 entry = ring_buffer_event_data(event);
517 entry->vaddr[0] = instruction_pointer(regs); 517 entry->vaddr[0] = instruction_pointer(regs);
@@ -521,7 +521,12 @@ static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
521 521
522 if (!filter_current_check_discard(buffer, call, entry, event)) 522 if (!filter_current_check_discard(buffer, call, entry, event))
523 trace_buffer_unlock_commit(buffer, event, 0, 0); 523 trace_buffer_unlock_commit(buffer, event, 0, 0);
524}
524 525
526/* uprobe handler */
527static int uprobe_trace_func(struct trace_uprobe *tu, struct pt_regs *regs)
528{
529 uprobe_trace_print(tu, 0, regs);
525 return 0; 530 return 0;
526} 531}
527 532
@@ -754,8 +759,8 @@ static bool uprobe_perf_filter(struct uprobe_consumer *uc,
754 return ret; 759 return ret;
755} 760}
756 761
757/* uprobe profile handler */ 762static void uprobe_perf_print(struct trace_uprobe *tu,
758static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs) 763 unsigned long func, struct pt_regs *regs)
759{ 764{
760 struct ftrace_event_call *call = &tu->call; 765 struct ftrace_event_call *call = &tu->call;
761 struct uprobe_trace_entry_head *entry; 766 struct uprobe_trace_entry_head *entry;
@@ -764,13 +769,10 @@ static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
764 void *data; 769 void *data;
765 int size, rctx, i; 770 int size, rctx, i;
766 771
767 if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
768 return UPROBE_HANDLER_REMOVE;
769
770 size = SIZEOF_TRACE_ENTRY(false); 772 size = SIZEOF_TRACE_ENTRY(false);
771 size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32); 773 size = ALIGN(size + tu->size + sizeof(u32), sizeof(u64)) - sizeof(u32);
772 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough")) 774 if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE, "profile buffer not large enough"))
773 return 0; 775 return;
774 776
775 preempt_disable(); 777 preempt_disable();
776 entry = perf_trace_buf_prepare(size, call->event.type, regs, &rctx); 778 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 perf_trace_buf_submit(entry, size, rctx, ip, 1, regs, head, NULL); 789 perf_trace_buf_submit(entry, size, rctx, ip, 1, regs, head, NULL);
788 out: 790 out:
789 preempt_enable(); 791 preempt_enable();
792}
793
794/* uprobe profile handler */
795static int uprobe_perf_func(struct trace_uprobe *tu, struct pt_regs *regs)
796{
797 if (!uprobe_perf_filter(&tu->consumer, 0, current->mm))
798 return UPROBE_HANDLER_REMOVE;
799
800 uprobe_perf_print(tu, 0, regs);
790 return 0; 801 return 0;
791} 802}
792#endif /* CONFIG_PERF_EVENTS */ 803#endif /* CONFIG_PERF_EVENTS */