mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 09:12:07 +00:00
tracing: switch to kernel_clone()
The old _do_fork() helper is removed in favor of the new kernel_clone() helper. The latter adheres to naming conventions for kernel internal syscall helpers. Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Cc: Alexandre Chartre <alexandre.chartre@oracle.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Xiao Yang <yangx.jy@cn.fujitsu.com> Cc: Tom Zanussi <zanussi@kernel.org> Cc: linux-doc@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Link: https://lore.kernel.org/r/20200819104655.436656-11-christian.brauner@ubuntu.com
This commit is contained in:
parent
f30897c17d
commit
eea11285da
@ -1495,7 +1495,7 @@ Extended error information
|
||||
#
|
||||
|
||||
{ stacktrace:
|
||||
_do_fork+0x18e/0x330
|
||||
kernel_clone+0x18e/0x330
|
||||
kernel_thread+0x29/0x30
|
||||
kthreadd+0x154/0x1b0
|
||||
ret_from_fork+0x3f/0x70
|
||||
@ -1588,7 +1588,7 @@ Extended error information
|
||||
SYSC_sendto+0xef/0x170
|
||||
} hitcount: 88
|
||||
{ stacktrace:
|
||||
_do_fork+0x18e/0x330
|
||||
kernel_clone+0x18e/0x330
|
||||
SyS_clone+0x19/0x20
|
||||
entry_SYSCALL_64_fastpath+0x12/0x6a
|
||||
} hitcount: 244
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
* usage: insmod kretprobe_example.ko func=<func_name>
|
||||
*
|
||||
* If no func_name is specified, _do_fork is instrumented
|
||||
* If no func_name is specified, kernel_clone is instrumented
|
||||
*
|
||||
* For more information on theory of operation of kretprobes, see
|
||||
* Documentation/staging/kprobes.rst
|
||||
@ -26,7 +26,7 @@
|
||||
#include <linux/limits.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
static char func_name[NAME_MAX] = "_do_fork";
|
||||
static char func_name[NAME_MAX] = "kernel_clone";
|
||||
module_param_string(func, func_name, NAME_MAX, S_IRUGO);
|
||||
MODULE_PARM_DESC(func, "Function to kretprobe; this module will report the"
|
||||
" function's execution time");
|
||||
|
@ -6,7 +6,7 @@
|
||||
echo 0 > events/enable
|
||||
echo > dynamic_events
|
||||
|
||||
PLACE=_do_fork
|
||||
PLACE=kernel_clone
|
||||
|
||||
echo "p:myevent1 $PLACE" >> dynamic_events
|
||||
echo "r:myevent2 $PLACE" >> dynamic_events
|
||||
|
@ -6,7 +6,7 @@
|
||||
echo 0 > events/enable
|
||||
echo > dynamic_events
|
||||
|
||||
PLACE=_do_fork
|
||||
PLACE=kernel_clone
|
||||
|
||||
setup_events() {
|
||||
echo "p:myevent1 $PLACE" >> dynamic_events
|
||||
|
@ -6,7 +6,7 @@
|
||||
echo 0 > events/enable
|
||||
echo > dynamic_events
|
||||
|
||||
PLACE=_do_fork
|
||||
PLACE=kernel_clone
|
||||
|
||||
setup_events() {
|
||||
echo "p:myevent1 $PLACE" >> dynamic_events
|
||||
|
@ -4,9 +4,9 @@
|
||||
# requires: set_ftrace_filter
|
||||
# flags: instance
|
||||
|
||||
echo _do_fork:stacktrace >> set_ftrace_filter
|
||||
echo kernel_clone:stacktrace >> set_ftrace_filter
|
||||
|
||||
grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter
|
||||
grep -q "kernel_clone:stacktrace:unlimited" set_ftrace_filter
|
||||
|
||||
(echo "forked"; sleep 1)
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# description: Kprobe dynamic event - adding and removing
|
||||
# requires: kprobe_events
|
||||
|
||||
echo p:myevent _do_fork > kprobe_events
|
||||
echo p:myevent kernel_clone > kprobe_events
|
||||
grep myevent kprobe_events
|
||||
test -d events/kprobes/myevent
|
||||
echo > kprobe_events
|
||||
|
@ -3,7 +3,7 @@
|
||||
# description: Kprobe dynamic event - busy event check
|
||||
# requires: kprobe_events
|
||||
|
||||
echo p:myevent _do_fork > kprobe_events
|
||||
echo p:myevent kernel_clone > kprobe_events
|
||||
test -d events/kprobes/myevent
|
||||
echo 1 > events/kprobes/myevent/enable
|
||||
echo > kprobe_events && exit_fail # this must fail
|
||||
|
@ -3,13 +3,13 @@
|
||||
# description: Kprobe dynamic event with arguments
|
||||
# requires: kprobe_events
|
||||
|
||||
echo 'p:testprobe _do_fork $stack $stack0 +0($stack)' > kprobe_events
|
||||
echo 'p:testprobe kernel_clone $stack $stack0 +0($stack)' > kprobe_events
|
||||
grep testprobe kprobe_events | grep -q 'arg1=\$stack arg2=\$stack0 arg3=+0(\$stack)'
|
||||
test -d events/kprobes/testprobe
|
||||
|
||||
echo 1 > events/kprobes/testprobe/enable
|
||||
( echo "forked")
|
||||
grep testprobe trace | grep '_do_fork' | \
|
||||
grep testprobe trace | grep 'kernel_clone' | \
|
||||
grep -q 'arg1=0x[[:xdigit:]]* arg2=0x[[:xdigit:]]* arg3=0x[[:xdigit:]]*$'
|
||||
|
||||
echo 0 > events/kprobes/testprobe/enable
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
grep -A1 "fetcharg:" README | grep -q "\$comm" || exit_unsupported # this is too old
|
||||
|
||||
echo 'p:testprobe _do_fork comm=$comm ' > kprobe_events
|
||||
echo 'p:testprobe kernel_clone comm=$comm ' > kprobe_events
|
||||
grep testprobe kprobe_events | grep -q 'comm=$comm'
|
||||
test -d events/kprobes/testprobe
|
||||
|
||||
|
@ -30,13 +30,13 @@ esac
|
||||
: "Test get argument (1)"
|
||||
echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events
|
||||
echo 1 > events/kprobes/testprobe/enable
|
||||
echo "p:test _do_fork" >> kprobe_events
|
||||
echo "p:test kernel_clone" >> kprobe_events
|
||||
grep -qe "testprobe.* arg1=\"test\"" trace
|
||||
|
||||
echo 0 > events/kprobes/testprobe/enable
|
||||
: "Test get argument (2)"
|
||||
echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events
|
||||
echo 1 > events/kprobes/testprobe/enable
|
||||
echo "p:test _do_fork" >> kprobe_events
|
||||
echo "p:test kernel_clone" >> kprobe_events
|
||||
grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace
|
||||
|
||||
|
@ -14,12 +14,12 @@ elif ! grep "$SYMBOL\$" /proc/kallsyms; then
|
||||
fi
|
||||
|
||||
: "Test get basic types symbol argument"
|
||||
echo "p:testprobe_u _do_fork arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events
|
||||
echo "p:testprobe_s _do_fork arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events
|
||||
echo "p:testprobe_u kernel_clone arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events
|
||||
echo "p:testprobe_s kernel_clone arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events
|
||||
if grep -q "x8/16/32/64" README; then
|
||||
echo "p:testprobe_x _do_fork arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events
|
||||
echo "p:testprobe_x kernel_clone arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events
|
||||
fi
|
||||
echo "p:testprobe_bf _do_fork arg1=@linux_proc_banner:b8@4/32" >> kprobe_events
|
||||
echo "p:testprobe_bf kernel_clone arg1=@linux_proc_banner:b8@4/32" >> kprobe_events
|
||||
echo 1 > events/kprobes/enable
|
||||
(echo "forked")
|
||||
echo 0 > events/kprobes/enable
|
||||
@ -27,7 +27,7 @@ grep "testprobe_[usx]:.* arg1=.* arg2=.* arg3=.* arg4=.*" trace
|
||||
grep "testprobe_bf:.* arg1=.*" trace
|
||||
|
||||
: "Test get string symbol argument"
|
||||
echo "p:testprobe_str _do_fork arg1=@linux_proc_banner:string" > kprobe_events
|
||||
echo "p:testprobe_str kernel_clone arg1=@linux_proc_banner:string" > kprobe_events
|
||||
echo 1 > events/kprobes/enable
|
||||
(echo "forked")
|
||||
echo 0 > events/kprobes/enable
|
||||
|
@ -4,7 +4,7 @@
|
||||
# requires: kprobe_events "x8/16/32/64":README
|
||||
|
||||
gen_event() { # Bitsize
|
||||
echo "p:testprobe _do_fork \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
|
||||
echo "p:testprobe kernel_clone \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
|
||||
}
|
||||
|
||||
check_types() { # s-type u-type x-type bf-type width
|
||||
|
@ -5,29 +5,29 @@
|
||||
|
||||
# prepare
|
||||
echo nop > current_tracer
|
||||
echo _do_fork > set_ftrace_filter
|
||||
echo 'p:testprobe _do_fork' > kprobe_events
|
||||
echo kernel_clone > set_ftrace_filter
|
||||
echo 'p:testprobe kernel_clone' > kprobe_events
|
||||
|
||||
# kprobe on / ftrace off
|
||||
echo 1 > events/kprobes/testprobe/enable
|
||||
echo > trace
|
||||
( echo "forked")
|
||||
grep testprobe trace
|
||||
! grep '_do_fork <-' trace
|
||||
! grep 'kernel_clone <-' trace
|
||||
|
||||
# kprobe on / ftrace on
|
||||
echo function > current_tracer
|
||||
echo > trace
|
||||
( echo "forked")
|
||||
grep testprobe trace
|
||||
grep '_do_fork <-' trace
|
||||
grep 'kernel_clone <-' trace
|
||||
|
||||
# kprobe off / ftrace on
|
||||
echo 0 > events/kprobes/testprobe/enable
|
||||
echo > trace
|
||||
( echo "forked")
|
||||
! grep testprobe trace
|
||||
grep '_do_fork <-' trace
|
||||
grep 'kernel_clone <-' trace
|
||||
|
||||
# kprobe on / ftrace on
|
||||
echo 1 > events/kprobes/testprobe/enable
|
||||
@ -35,11 +35,11 @@ echo function > current_tracer
|
||||
echo > trace
|
||||
( echo "forked")
|
||||
grep testprobe trace
|
||||
grep '_do_fork <-' trace
|
||||
grep 'kernel_clone <-' trace
|
||||
|
||||
# kprobe on / ftrace off
|
||||
echo nop > current_tracer
|
||||
echo > trace
|
||||
( echo "forked")
|
||||
grep testprobe trace
|
||||
! grep '_do_fork <-' trace
|
||||
! grep 'kernel_clone <-' trace
|
||||
|
@ -4,7 +4,7 @@
|
||||
# requires: kprobe_events "Create/append/":README
|
||||
|
||||
# Choose 2 symbols for target
|
||||
SYM1=_do_fork
|
||||
SYM1=kernel_clone
|
||||
SYM2=do_exit
|
||||
EVENT_NAME=kprobes/testevent
|
||||
|
||||
|
@ -86,15 +86,15 @@ esac
|
||||
|
||||
# multiprobe errors
|
||||
if grep -q "Create/append/" README && grep -q "imm-value" README; then
|
||||
echo 'p:kprobes/testevent _do_fork' > kprobe_events
|
||||
echo 'p:kprobes/testevent kernel_clone' > kprobe_events
|
||||
check_error '^r:kprobes/testevent do_exit' # DIFF_PROBE_TYPE
|
||||
|
||||
# Explicitly use printf "%s" to not interpret \1
|
||||
printf "%s" 'p:kprobes/testevent _do_fork abcd=\1' > kprobe_events
|
||||
check_error 'p:kprobes/testevent _do_fork ^bcd=\1' # DIFF_ARG_TYPE
|
||||
check_error 'p:kprobes/testevent _do_fork ^abcd=\1:u8' # DIFF_ARG_TYPE
|
||||
check_error 'p:kprobes/testevent _do_fork ^abcd=\"foo"' # DIFF_ARG_TYPE
|
||||
check_error '^p:kprobes/testevent _do_fork abcd=\1' # SAME_PROBE
|
||||
printf "%s" 'p:kprobes/testevent kernel_clone abcd=\1' > kprobe_events
|
||||
check_error 'p:kprobes/testevent kernel_clone ^bcd=\1' # DIFF_ARG_TYPE
|
||||
check_error 'p:kprobes/testevent kernel_clone ^abcd=\1:u8' # DIFF_ARG_TYPE
|
||||
check_error 'p:kprobes/testevent kernel_clone ^abcd=\"foo"' # DIFF_ARG_TYPE
|
||||
check_error '^p:kprobes/testevent kernel_clone abcd=\1' # SAME_PROBE
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -4,14 +4,14 @@
|
||||
# requires: kprobe_events
|
||||
|
||||
# Add new kretprobe event
|
||||
echo 'r:testprobe2 _do_fork $retval' > kprobe_events
|
||||
echo 'r:testprobe2 kernel_clone $retval' > kprobe_events
|
||||
grep testprobe2 kprobe_events | grep -q 'arg1=\$retval'
|
||||
test -d events/kprobes/testprobe2
|
||||
|
||||
echo 1 > events/kprobes/testprobe2/enable
|
||||
( echo "forked")
|
||||
|
||||
cat trace | grep testprobe2 | grep -q '<- _do_fork'
|
||||
cat trace | grep testprobe2 | grep -q '<- kernel_clone'
|
||||
|
||||
echo 0 > events/kprobes/testprobe2/enable
|
||||
echo '-:testprobe2' >> kprobe_events
|
||||
|
@ -4,7 +4,7 @@
|
||||
# requires: kprobe_events
|
||||
|
||||
! grep -q 'myevent' kprobe_profile
|
||||
echo p:myevent _do_fork > kprobe_events
|
||||
echo p:myevent kernel_clone > kprobe_events
|
||||
grep -q 'myevent[[:space:]]*0[[:space:]]*0$' kprobe_profile
|
||||
echo 1 > events/kprobes/myevent/enable
|
||||
( echo "forked" )
|
||||
|
Loading…
Reference in New Issue
Block a user