1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

selftests/ftrace: Update fprobe test to check enabled_functions file

A few bugs were found in the fprobe accounting logic along with it using
the function graph infrastructure. Update the fprobe selftest to catch
those bugs in case they or something similar shows up in the future.

The test now checks the enabled_functions file which shows all the
functions attached to ftrace or fgraph. When enabling a fprobe, make sure
that its corresponding function is also added to that file. Also add two
more fprobes to enable to make sure that the fprobe logic works properly
with multiple probes.

Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Link: https://lore.kernel.org/20250220202055.733001756@goodmis.org
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Tested-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt 2025-02-20 15:20:14 -05:00 committed by Steven Rostedt (Google)
parent ca26554a14
commit e85c5e9792

View file

@ -7,12 +7,38 @@ echo 0 > events/enable
echo > dynamic_events
PLACE=$FUNCTION_FORK
PLACE2="kmem_cache_free"
PLACE3="schedule_timeout"
echo "f:myevent1 $PLACE" >> dynamic_events
# Make sure the event is attached and is the only one
grep -q $PLACE enabled_functions
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 1 ]; then
exit_fail
fi
echo "f:myevent2 $PLACE%return" >> dynamic_events
# It should till be the only attached function
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 1 ]; then
exit_fail
fi
# add another event
echo "f:myevent3 $PLACE2" >> dynamic_events
grep -q $PLACE2 enabled_functions
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 2 ]; then
exit_fail
fi
grep -q myevent1 dynamic_events
grep -q myevent2 dynamic_events
grep -q myevent3 dynamic_events
test -d events/fprobes/myevent1
test -d events/fprobes/myevent2
@ -21,6 +47,34 @@ echo "-:myevent2" >> dynamic_events
grep -q myevent1 dynamic_events
! grep -q myevent2 dynamic_events
# should still have 2 left
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 2 ]; then
exit_fail
fi
echo > dynamic_events
# Should have none left
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 0 ]; then
exit_fail
fi
echo "f:myevent4 $PLACE" >> dynamic_events
# Should only have one enabled
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 1 ]; then
exit_fail
fi
echo > dynamic_events
# Should have none left
cnt=`cat enabled_functions | wc -l`
if [ $cnt -ne 0 ]; then
exit_fail
fi
clear_trace