uprobes/perf: Teach trace_uprobe/perf code to use UPROBE_HANDLER_REMOVE
authorOleg Nesterov <oleg@redhat.com>
Mon, 4 Feb 2013 16:48:34 +0000 (17:48 +0100)
committerOleg Nesterov <oleg@redhat.com>
Fri, 8 Feb 2013 17:28:07 +0000 (18:28 +0100)
commitf42d24a1d20d2e72d1e5d48930f18b138dfad117
tree10696fc2f0a21d60a7fb1581efecd172435f0408
parent31ba334836c0ac0039084859f14a5b96858493dc
uprobes/perf: Teach trace_uprobe/perf code to use UPROBE_HANDLER_REMOVE

Change uprobe_trace_func() and uprobe_perf_func() to return "int". Change
uprobe_dispatcher() to return "trace_ret | perf_ret" although this is not
needed, currently TP_FLAG_TRACE/TP_FLAG_PROFILE are mutually exclusive.

The only functional change is that uprobe_perf_func() checks the filtering
too and returns UPROBE_HANDLER_REMOVE if nobody wants to trace current.

Testing:

# perf probe -x /lib/libc.so.6 syscall

# perf record -e probe_libc:syscall -i perl -e 'fork; syscall -1 for 1..10; wait'

# perf report --show-total-period
100.00%            10     perl  libc-2.8.so    [.] syscall

Before this patch:

# cat /sys/kernel/debug/tracing/uprobe_profile
/lib/libc.so.6 syscall 20

A child process doesn't have a counter, but still it hits this breakoint
"copied" by dup_mmap().

After the patch:

# cat /sys/kernel/debug/tracing/uprobe_profile
/lib/libc.so.6 syscall 11

The child process hits this int3 only once and does unapply_uprobe().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
kernel/trace/trace_uprobe.c