Re: [PATCH bpf-next 0/2] selftests/bpf: port test_ftrace.sh into test_progs
From: Alexei Starovoitov
Date: Sat Oct 31 2026 - 18:54:30 EST
On Fri, Oct 30, 2026 at 11:50 AM Alexis Lothoré (eBPF Foundation) <alexis.lothore@xxxxxxxxxxx> wrote:
> - commit 1 brings a few new helpers to manipulate ftrace from test_progs
> - commit 2 performs the actual porting
[...]
> 5 files changed, 412 insertions(+), 46 deletions(-)
This is quite heavy for a port of a 44 line script.
Lets use a tracing instance. function_graph works in instances.
An instance has its own set_ftrace_filter, current_tracer and ring
buffer. rmdir undoes all of it.
What goes away:
series tracing instance
------------------------------ ------------------------------
global tracefs files files of the instance
save and restore, patch 1 rmdir
serial_ not needed
all functions are patched only the filtered functions
new progs progs/modify_return.c as is
modify_return has fentry, fmod_ret and fexit on the same function
and checks the return values.
The removal of test_ftrace.sh stays.
Instead of patches 1 and 2:
diff --git a/tools/testing/selftests/bpf/prog_tests/modify_return.c b/tools/testing/selftests/bpf/prog_tests/modify_return.c
--- a/tools/testing/selftests/bpf/prog_tests/modify_return.c
+++ b/tools/testing/selftests/bpf/prog_tests/modify_return.c
@@ -61,3 +61,28 @@ void test_modify_return(void)
0 /* want_side_effect */,
-EINVAL * 2 /* want_ret */);
}
+
+/*
+ * The same test while function_graph traces the same functions.
+ * A tracing instance has its own filter, tracer and ring buffer.
+ * rmdir() undoes all of it.
+ */
+void test_modify_return_fgraph(void)
+{
+ char dir[128];
+
+ snprintf(dir, sizeof(dir), "%s/instances/bpf-XXXXXX",
+ access("/sys/kernel/tracing/trace", F_OK) ?
+ "/sys/kernel/debug/tracing" : "/sys/kernel/tracing");
+ if (!ASSERT_OK_PTR(mkdtemp(dir), "mkdtemp"))
+ return;
+
+ SYS(out, "echo 'bpf_modify_return_test*' > %s/set_ftrace_filter", dir);
+ SYS(out, "echo function_graph > %s/current_tracer", dir);
+
+ test_modify_return();
+
+ SYS(out, "grep -q bpf_modify_return_test2 %s/trace", dir);
+out:
+ ASSERT_OK(rmdir(dir), "rmdir");
+}
pw-bot: cr