From: Jiri Olsa <olsajiri@gmail.com>
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: ebpf@linuxfoundation.org,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Emil Tsalapatis <emil@etsalapatis.com>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v2] selftests/bpf: port test_ftrace.sh to test_progs
Date: Wed, 4 Nov 2026 12:40:45 +0100 [thread overview]
Message-ID: <ausZvdHfmevg3mMZ@krava> (raw)
In-Reply-To: <20261104-ftrace_in_test_progs-v2-1-45363230d228@bootlin.com>
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.
>
> Convert the script to the test_progs runner so it can be executed
> automatically by the CI infrastructure. There are two main options to
> port this test:
> - just enable ftrace during some existing trampoline-related tests
> (eg: fentry/fexit tests)
> - create a dedicated, minimal test with function graph
>
> The new test adopts the latter approach, with a smaller scope to keep
> execution time reasonable, while reusing an existing
> fentry/fexit/fmod_ret test. Despite the few asserts in the new test, the
> actual goal is to make sure that the kernel does not crash because of
> some incorrect stack frame skipping when both the function graph and
> tracing programs are running.
>
> ftrace is configured through a dedicated ftrace instance which is
> dropped at the end of the test.
>
> With the new test integrated into test_progs, drop test_ftrace.sh.
>
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
> ---
> Hello,
> this is v2 of a small series aiming to port the test_ftrace.sh script
> (testing that trampolines and function graph behave correctly when both
> are enabled) into the test_progs framework. The test is heavily
> simplified following Alexei's review and suggestions.
> ---
> Changes in v2:
> - use a ftrace instance rather than global ftrace
> - drop fgraph filters
> - drop custom ftrace helpers in favor of direct manipulation in test
> - drop custom bpf prog, reuse test_modify_return directly
> - move test in existing test file (modify_return.c)
> - make the test parallel (drop serial_)
> - Link to v1: https://patch.msgid.link/20261030-ftrace_in_test_progs-v1-0-aa50c5dd1ccc@bootlin.com
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
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
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@bootlin.com>
>
next prev parent reply other threads:[~2026-11-04 11:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 9:59 [PATCH bpf-next v2] selftests/bpf: port test_ftrace.sh to test_progs Alexis Lothoré (eBPF Foundation)
2026-11-04 11:40 ` Jiri Olsa [this message]
2026-11-05 17:04 ` Alexis Lothoré
2026-11-04 18:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ausZvdHfmevg3mMZ@krava \
--to=olsajiri@gmail.com \
--cc=alexis.lothore@bootlin.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ebpf@linuxfoundation.org \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.