forked from Freescale/linux-fslc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tracing/kprobes: expose maxactive for kretprobe in kprobe_events
When a kretprobe is installed on a kernel function, there is a maximum limit of how many calls in parallel it can catch (aka "maxactive"). A kernel module could call register_kretprobe() and initialize maxactive (see example in samples/kprobes/kretprobe_example.c). But that is not exposed to userspace and it is currently not possible to choose maxactive when writing to /sys/kernel/debug/tracing/kprobe_events The default maxactive can be as low as 1 on single-core with a non-preemptive kernel. This is too low and we need to increase it not only for recursive functions, but for functions that sleep or resched. This patch updates the format of the command that can be written to kprobe_events so that maxactive can be optionally specified. I need this for a bpf program attached to the kretprobe of inet_csk_accept, which can sleep for a long time. This patch includes a basic selftest: > # ./ftracetest -v test.d/kprobe/ > === Ftrace unit tests === > [1] Kprobe dynamic event - adding and removing [PASS] > [2] Kprobe dynamic event - busy event check [PASS] > [3] Kprobe dynamic event with arguments [PASS] > [4] Kprobes event arguments with types [PASS] > [5] Kprobe dynamic event with function tracer [PASS] > [6] Kretprobe dynamic event with arguments [PASS] > [7] Kretprobe dynamic event with maxactive [PASS] > > # of passed: 7 > # of failed: 0 > # of unresolved: 0 > # of untested: 0 > # of unsupported: 0 > # of xfailed: 0 > # of undefined(test bug): 0 BugLink: iovisor/bcc#1072 Link: http://lkml.kernel.org/r/[email protected] Acked-by: Masami Hiramatsu <[email protected]> Signed-off-by: Alban Crequy <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
- Loading branch information
Showing
3 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_maxactive.tc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh | ||
# description: Kretprobe dynamic event with maxactive | ||
|
||
[ -f kprobe_events ] || exit_unsupported # this is configurable | ||
|
||
echo > kprobe_events | ||
|
||
# Test if we successfully reject unknown messages | ||
if echo 'a:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi | ||
|
||
# Test if we successfully reject too big maxactive | ||
if echo 'r1000000:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi | ||
|
||
# Test if we successfully reject unparsable numbers for maxactive | ||
if echo 'r10fuzz:myprobeaccept inet_csk_accept' > kprobe_events; then false; else true; fi | ||
|
||
# Test for kretprobe with event name without maxactive | ||
echo 'r:myprobeaccept inet_csk_accept' > kprobe_events | ||
grep myprobeaccept kprobe_events | ||
test -d events/kprobes/myprobeaccept | ||
echo '-:myprobeaccept' >> kprobe_events | ||
|
||
# Test for kretprobe with event name with a small maxactive | ||
echo 'r10:myprobeaccept inet_csk_accept' > kprobe_events | ||
grep myprobeaccept kprobe_events | ||
test -d events/kprobes/myprobeaccept | ||
echo '-:myprobeaccept' >> kprobe_events | ||
|
||
# Test for kretprobe without event name without maxactive | ||
echo 'r inet_csk_accept' > kprobe_events | ||
grep inet_csk_accept kprobe_events | ||
echo > kprobe_events | ||
|
||
# Test for kretprobe without event name with a small maxactive | ||
echo 'r10 inet_csk_accept' > kprobe_events | ||
grep inet_csk_accept kprobe_events | ||
echo > kprobe_events | ||
|
||
clear_trace |