aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>2011-06-27 03:26:44 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-07-15 15:10:58 -0400
commit1538f888f1e793de04e0f90372352ac1b05833cf (patch)
tree42c064993df39faf3f285e276f588fc2518016f2 /kernel
parent7143f168e2aa4bc7f8a8bcfe46d8dc52f7be869a (diff)
tracing/kprobes: Merge trace probe enable/disable functions
Merge redundant enable/disable functions into enable_trace_probe() and disable_trace_probe(). Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: yrl.pp-manager.tt@hitachi.com Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Link: http://lkml.kernel.org/r/20110627072644.6528.26910.stgit@fedora15 [ converted kprobe selftest to use enable_trace_probe ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/trace_kprobe.c92
1 files changed, 36 insertions, 56 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 14b88ed65bb7..3be50c52d080 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -683,6 +683,34 @@ static struct trace_probe *find_trace_probe(const char *event,
683 return NULL; 683 return NULL;
684} 684}
685 685
686/* Enable trace_probe - @flag must be TP_FLAG_TRACE or TP_FLAG_PROFILE */
687static int enable_trace_probe(struct trace_probe *tp, int flag)
688{
689 int ret = 0;
690
691 tp->flags |= flag;
692 if (tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE)) {
693 if (trace_probe_is_return(tp))
694 ret = enable_kretprobe(&tp->rp);
695 else
696 ret = enable_kprobe(&tp->rp.kp);
697 }
698
699 return ret;
700}
701
702/* Disable trace_probe - @flag must be TP_FLAG_TRACE or TP_FLAG_PROFILE */
703static void disable_trace_probe(struct trace_probe *tp, int flag)
704{
705 tp->flags &= ~flag;
706 if (!(tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE))) {
707 if (trace_probe_is_return(tp))
708 disable_kretprobe(&tp->rp);
709 else
710 disable_kprobe(&tp->rp.kp);
711 }
712}
713
686/* Unregister a trace_probe and probe_event: call with locking probe_lock */ 714/* Unregister a trace_probe and probe_event: call with locking probe_lock */
687static void unregister_trace_probe(struct trace_probe *tp) 715static void unregister_trace_probe(struct trace_probe *tp)
688{ 716{
@@ -1514,30 +1542,6 @@ partial:
1514 return TRACE_TYPE_PARTIAL_LINE; 1542 return TRACE_TYPE_PARTIAL_LINE;
1515} 1543}
1516 1544
1517static int probe_event_enable(struct ftrace_event_call *call)
1518{
1519 struct trace_probe *tp = (struct trace_probe *)call->data;
1520
1521 tp->flags |= TP_FLAG_TRACE;
1522 if (trace_probe_is_return(tp))
1523 return enable_kretprobe(&tp->rp);
1524 else
1525 return enable_kprobe(&tp->rp.kp);
1526}
1527
1528static void probe_event_disable(struct ftrace_event_call *call)
1529{
1530 struct trace_probe *tp = (struct trace_probe *)call->data;
1531
1532 tp->flags &= ~TP_FLAG_TRACE;
1533 if (!(tp->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE))) {
1534 if (trace_probe_is_return(tp))
1535 disable_kretprobe(&tp->rp);
1536 else
1537 disable_kprobe(&tp->rp.kp);
1538 }
1539}
1540
1541#undef DEFINE_FIELD 1545#undef DEFINE_FIELD
1542#define DEFINE_FIELD(type, item, name, is_signed) \ 1546#define DEFINE_FIELD(type, item, name, is_signed) \
1543 do { \ 1547 do { \
@@ -1716,49 +1720,25 @@ static __kprobes void kretprobe_perf_func(struct kretprobe_instance *ri,
1716 head = this_cpu_ptr(call->perf_events); 1720 head = this_cpu_ptr(call->perf_events);
1717 perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head); 1721 perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head);
1718} 1722}
1719
1720static int probe_perf_enable(struct ftrace_event_call *call)
1721{
1722 struct trace_probe *tp = (struct trace_probe *)call->data;
1723
1724 tp->flags |= TP_FLAG_PROFILE;
1725
1726 if (trace_probe_is_return(tp))
1727 return enable_kretprobe(&tp->rp);
1728 else
1729 return enable_kprobe(&tp->rp.kp);
1730}
1731
1732static void probe_perf_disable(struct ftrace_event_call *call)
1733{
1734 struct trace_probe *tp = (struct trace_probe *)call->data;
1735
1736 tp->flags &= ~TP_FLAG_PROFILE;
1737
1738 if (!(tp->flags & TP_FLAG_TRACE)) {
1739 if (trace_probe_is_return(tp))
1740 disable_kretprobe(&tp->rp);
1741 else
1742 disable_kprobe(&tp->rp.kp);
1743 }
1744}
1745#endif /* CONFIG_PERF_EVENTS */ 1723#endif /* CONFIG_PERF_EVENTS */
1746 1724
1747static __kprobes 1725static __kprobes
1748int kprobe_register(struct ftrace_event_call *event, enum trace_reg type) 1726int kprobe_register(struct ftrace_event_call *event, enum trace_reg type)
1749{ 1727{
1728 struct trace_probe *tp = (struct trace_probe *)event->data;
1729
1750 switch (type) { 1730 switch (type) {
1751 case TRACE_REG_REGISTER: 1731 case TRACE_REG_REGISTER:
1752 return probe_event_enable(event); 1732 return enable_trace_probe(tp, TP_FLAG_TRACE);
1753 case TRACE_REG_UNREGISTER: 1733 case TRACE_REG_UNREGISTER:
1754 probe_event_disable(event); 1734 disable_trace_probe(tp, TP_FLAG_TRACE);
1755 return 0; 1735 return 0;
1756 1736
1757#ifdef CONFIG_PERF_EVENTS 1737#ifdef CONFIG_PERF_EVENTS
1758 case TRACE_REG_PERF_REGISTER: 1738 case TRACE_REG_PERF_REGISTER:
1759 return probe_perf_enable(event); 1739 return enable_trace_probe(tp, TP_FLAG_PROFILE);
1760 case TRACE_REG_PERF_UNREGISTER: 1740 case TRACE_REG_PERF_UNREGISTER:
1761 probe_perf_disable(event); 1741 disable_trace_probe(tp, TP_FLAG_PROFILE);
1762 return 0; 1742 return 0;
1763#endif 1743#endif
1764 } 1744 }
@@ -1905,7 +1885,7 @@ static __init int kprobe_trace_self_tests_init(void)
1905 pr_warning("error on getting new probe.\n"); 1885 pr_warning("error on getting new probe.\n");
1906 warn++; 1886 warn++;
1907 } else 1887 } else
1908 probe_event_enable(&tp->call); 1888 enable_trace_probe(tp, TP_FLAG_TRACE);
1909 } 1889 }
1910 1890
1911 ret = command_trace_probe("r:testprobe2 kprobe_trace_selftest_target " 1891 ret = command_trace_probe("r:testprobe2 kprobe_trace_selftest_target "
@@ -1920,7 +1900,7 @@ static __init int kprobe_trace_self_tests_init(void)
1920 pr_warning("error on getting new probe.\n"); 1900 pr_warning("error on getting new probe.\n");
1921 warn++; 1901 warn++;
1922 } else 1902 } else
1923 probe_event_enable(&tp->call); 1903 enable_trace_probe(tp, TP_FLAG_TRACE);
1924 } 1904 }
1925 1905
1926 if (warn) 1906 if (warn)