* [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first
@ 2025-09-15 13:42 Quentin Monnet
2025-09-15 13:53 ` Daniel Borkmann
2025-09-15 17:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Quentin Monnet @ 2025-09-15 13:42 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
Cc: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Steven Rostedt, bpf, Quentin Monnet
With "bpftool prog tracelog", bpftool prints messages from the trace
pipe. To do so, it first needs to find the tracefs mount point to open
the pipe. Bpftool looks at a few "default" locations, including
/sys/kernel/debug/tracing and /sys/kernel/tracing.
Some of these locations, namely /tracing and /trace, are not standard.
They are in the list because some users used to hardcode the tracing
directory to short names; but we have no compelling reason to look at
these locations. If we fail to find the tracefs at the default
locations, we have an additional step to find it by parsing /proc/mounts
anyway, so it's safe to remove these entries from the list of default
locations to check.
Additionally, Alexei reports that looking for the tracefs at
/sys/kernel/debug/tracing may automatically mount the file system under
that location, and generate a kernel log message telling that
auto-mounting there is deprecated. To avoid this message, let's swap the
order for checking the potential mount points: try /sys/kernel/tracing
first, which should be the standard location nowadays. The kernel log
message may still appear if the tracefs is not mounted on
/sys/kernel/tracing when we run bpftool.
Reported-by: Alexei Starovoitov <ast@kernel.org>
Closes: https://lore.kernel.org/r/CAADnVQLcMi5YQhZKsU4z3S2uVUAGu_62C33G2Zx_ruG3uXa-Ug@mail.gmail.com/
Signed-off-by: Quentin Monnet <qmo@kernel.org>
---
v2: Remove outdated comment entirely
---
tools/bpf/bpftool/tracelog.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/tools/bpf/bpftool/tracelog.c b/tools/bpf/bpftool/tracelog.c
index 31d806e3bdaa..573a8d99f009 100644
--- a/tools/bpf/bpftool/tracelog.c
+++ b/tools/bpf/bpftool/tracelog.c
@@ -57,10 +57,8 @@ find_tracefs_mnt_single(unsigned long magic, char *mnt, const char *mntpt)
static bool get_tracefs_pipe(char *mnt)
{
static const char * const known_mnts[] = {
- "/sys/kernel/debug/tracing",
"/sys/kernel/tracing",
- "/tracing",
- "/trace",
+ "/sys/kernel/debug/tracing",
};
const char *pipe_name = "/trace_pipe";
const char *fstype = "tracefs";
@@ -95,12 +93,7 @@ static bool get_tracefs_pipe(char *mnt)
return false;
p_info("could not find tracefs, attempting to mount it now");
- /* Most of the time, tracefs is automatically mounted by debugfs at
- * /sys/kernel/debug/tracing when we try to access it. If we could not
- * find it, it is likely that debugfs is not mounted. Let's give one
- * attempt at mounting just tracefs at /sys/kernel/tracing.
- */
- strcpy(mnt, known_mnts[1]);
+ strcpy(mnt, known_mnts[0]);
if (mount_tracefs(mnt))
return false;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first
2025-09-15 13:42 [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first Quentin Monnet
@ 2025-09-15 13:53 ` Daniel Borkmann
2025-09-15 17:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2025-09-15 13:53 UTC (permalink / raw)
To: Quentin Monnet, Alexei Starovoitov, Andrii Nakryiko
Cc: Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
Steven Rostedt, bpf
On 9/15/25 3:42 PM, Quentin Monnet wrote:
> With "bpftool prog tracelog", bpftool prints messages from the trace
> pipe. To do so, it first needs to find the tracefs mount point to open
> the pipe. Bpftool looks at a few "default" locations, including
> /sys/kernel/debug/tracing and /sys/kernel/tracing.
>
> Some of these locations, namely /tracing and /trace, are not standard.
> They are in the list because some users used to hardcode the tracing
> directory to short names; but we have no compelling reason to look at
> these locations. If we fail to find the tracefs at the default
> locations, we have an additional step to find it by parsing /proc/mounts
> anyway, so it's safe to remove these entries from the list of default
> locations to check.
>
> Additionally, Alexei reports that looking for the tracefs at
> /sys/kernel/debug/tracing may automatically mount the file system under
> that location, and generate a kernel log message telling that
> auto-mounting there is deprecated. To avoid this message, let's swap the
> order for checking the potential mount points: try /sys/kernel/tracing
> first, which should be the standard location nowadays. The kernel log
> message may still appear if the tracefs is not mounted on
> /sys/kernel/tracing when we run bpftool.
>
> Reported-by: Alexei Starovoitov <ast@kernel.org>
> Closes: https://lore.kernel.org/r/CAADnVQLcMi5YQhZKsU4z3S2uVUAGu_62C33G2Zx_ruG3uXa-Ug@mail.gmail.com/
> Signed-off-by: Quentin Monnet <qmo@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first
2025-09-15 13:42 [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first Quentin Monnet
2025-09-15 13:53 ` Daniel Borkmann
@ 2025-09-15 17:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-15 17:20 UTC (permalink / raw)
To: Quentin Monnet
Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, rostedt, bpf
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 15 Sep 2025 14:42:09 +0100 you wrote:
> With "bpftool prog tracelog", bpftool prints messages from the trace
> pipe. To do so, it first needs to find the tracefs mount point to open
> the pipe. Bpftool looks at a few "default" locations, including
> /sys/kernel/debug/tracing and /sys/kernel/tracing.
>
> Some of these locations, namely /tracing and /trace, are not standard.
> They are in the list because some users used to hardcode the tracing
> directory to short names; but we have no compelling reason to look at
> these locations. If we fail to find the tracefs at the default
> locations, we have an additional step to find it by parsing /proc/mounts
> anyway, so it's safe to remove these entries from the list of default
> locations to check.
>
> [...]
Here is the summary with links:
- [bpf-next,v2] bpftool: Search for tracefs at /sys/kernel/tracing first
https://git.kernel.org/bpf/bpf-next/c/32d376610bdf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-15 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 13:42 [PATCH bpf-next v2] bpftool: Search for tracefs at /sys/kernel/tracing first Quentin Monnet
2025-09-15 13:53 ` Daniel Borkmann
2025-09-15 17:20 ` patchwork-bot+netdevbpf
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.