Re: [PATCH bpf-next v2] selftests/bpf: port test_ftrace.sh to test_progs
From: Alexis Lothoré
Date: Thu Nov 05 2026 - 12:15:48 EST
Hi Jiri,
On Wed Nov 4, 2026 at 12:40 PM CET, Jiri Olsa wrote:
> On Wed, Nov 04, 2026 at 10:59:33AM +0100, Alexis Lothoré (eBPF Foundation) wrote:
>> Commit ff205766dbbe ("ftrace: Fix function_graph tracer interaction with
>> BPF trampoline") made sure that trampolines generated for tracing
>> programs did not collide with the function graph when we are returning
>> from the hooked function. The series bringing this commit also came with
>> a new test ensuring that the kernel does not crash when executing BPF
>> programs handled by trampolines while the function graph trace is
>> enabled, but this test is a standalone shell script, hence not executed
>> in CI.
[...]
> lgtm, it might be worth to add something like this also for
> tracing-multi (maybe also kprobe-multi) and run some tests
> with function or function_graph enabled
Sure, I can take a look and follow-up with this. I guess it can be a
separate series, unless I'm told that it should be added in a v3.
Alexis
> Reviewed-by: Jiri Olsa <jolsa@xxxxxxxxxx>
>
> jirka
>
> SNIP
>
>> +void test_modify_return_graph(void)
>> +{
>> + char instance[MAX_INSTANCE_PATH_LEN];
>> + char *ftrace_dir;
>> + int ret;
>> +
>> + ftrace_dir = access(TRACE_FTRACE_DEFAULT, F_OK) ? TRACEFS_IN_DEBUGFS :
>> + TRACEFS_DEFAULT;
>> +
>> + ret = snprintf(instance, MAX_INSTANCE_PATH_LEN,
>> + "%s/instances/bpf-XXXXXX", ftrace_dir);
>> + if (ret < 0)
>> + return;
>> +
>> + if (!ASSERT_OK_PTR(mkdtemp(instance), "mkdtemp"))
>> + return;
>> +
>> + SYS(out, "echo 'bpf_modify_return_test*' > %s/set_ftrace_filter",
>> + instance);
>
> nit, no need for new line
>
>> + SYS(out, "echo function_graph > %s/current_tracer", instance);
>> +
>> + test_modify_return();
>> +
>> + SYS(out, "grep -q bpf_modify_return_test2 %s/trace", instance);
>> +out:
>> + ASSERT_OK(rmdir(instance), "rmdir");
>> +}
>> diff --git a/tools/testing/selftests/bpf/test_ftrace.sh b/tools/testing/selftests/bpf/test_ftrace.sh
>> deleted file mode 100755
>> index f5109eb0e951..000000000000
>> --- a/tools/testing/selftests/bpf/test_ftrace.sh
>> +++ /dev/null
>> @@ -1,44 +0,0 @@
>> -#!/bin/bash
>> -
>> -if [[ -e /sys/kernel/tracing/trace ]]; then
>> - TR=/sys/kernel/tracing/
>> -else
>> - TR=/sys/kernel/debug/tracing/
>> -fi
>> -
>> -clear_trace() { # reset trace output
>> - echo > $TR/trace
>> -}
>> -
>> -disable_tracing() { # stop trace recording
>> - echo 0 > $TR/tracing_on
>> -}
>> -
>> -enable_tracing() { # start trace recording
>> - echo 1 > $TR/tracing_on
>> -}
>> -
>> -reset_tracer() { # reset the current tracer
>> - echo nop > $TR/current_tracer
>> -}
>> -
>> -disable_tracing
>> -clear_trace
>> -
>> -echo "" > $TR/set_ftrace_filter
>> -echo '*printk* *console* *wake* *serial* *lock*' > $TR/set_ftrace_notrace
>> -
>> -echo "bpf_prog_test*" > $TR/set_graph_function
>> -echo "" > $TR/set_graph_notrace
>> -
>> -echo function_graph > $TR/current_tracer
>> -
>> -enable_tracing
>> -./test_progs -t fentry
>> -./test_progs -t fexit
>> -disable_tracing
>> -clear_trace
>> -
>> -reset_tracer
>> -
>> -exit 0
>>
>> ---
>> base-commit: b0e67f50519538b1b4c6364edc7811f482703f75
>> change-id: 20261027-ftrace_in_test_progs-d5f70a2330ac
>>
>> Best regards,
>> --
>> Alexis Lothoré (eBPF Foundation) <alexis.lothore@xxxxxxxxxxx>
>>
--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com