Re: [PATCH 7/9] tools/virtio: use canonical ftrace path

From: Ross Zwisler
Date: Wed Feb 01 2023 - 17:07:42 EST


On Mon, Jan 30, 2023 at 02:26:43PM -0500, Michael S. Tsirkin wrote:
> On Mon, Jan 30, 2023 at 11:19:13AM -0700, Ross Zwisler wrote:
> > The canonical location for the tracefs filesystem is at /sys/kernel/tracing.
> >
> > But, from Documentation/trace/ftrace.rst:
> >
> > Before 4.1, all ftrace tracing control files were within the debugfs
> > file system, which is typically located at /sys/kernel/debug/tracing.
> > For backward compatibility, when mounting the debugfs file system,
> > the tracefs file system will be automatically mounted at:
> >
> > /sys/kernel/debug/tracing
> >
> > A few spots in tools/virtio still refer to this older debugfs
> > path, so let's update them to avoid confusion.
> >
> > Signed-off-by: Ross Zwisler <zwisler@xxxxxxxxxx>
> > ---
> > tools/virtio/virtio-trace/README | 2 +-
> > tools/virtio/virtio-trace/trace-agent.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/virtio/virtio-trace/README b/tools/virtio/virtio-trace/README
> > index b64845b823ab..cea29a2a4c0a 100644
> > --- a/tools/virtio/virtio-trace/README
> > +++ b/tools/virtio/virtio-trace/README
> > @@ -95,7 +95,7 @@ Run
> >
> > 1) Enable ftrace in the guest
> > <Example>
> > - # echo 1 > /sys/kernel/debug/tracing/events/sched/enable
> > + # echo 1 > /sys/kernel/tracing/events/sched/enable
> >
> > 2) Run trace agent in the guest
> > This agent must be operated as root.
> > diff --git a/tools/virtio/virtio-trace/trace-agent.c b/tools/virtio/virtio-trace/trace-agent.c
> > index cdfe77c2b4c8..805942d02e9f 100644
> > --- a/tools/virtio/virtio-trace/trace-agent.c
> > +++ b/tools/virtio/virtio-trace/trace-agent.c
> > @@ -19,7 +19,7 @@
> > #define PIPE_MIN_SIZE (PAGE_SIZE*PIPE_DEF_BUFS)
> > #define PIPE_MAX_SIZE (1024*1024)
> > #define READ_PATH_FMT \
> > - "/sys/kernel/debug/tracing/per_cpu/cpu%d/trace_pipe_raw"
> > + "/sys/kernel/tracing/per_cpu/cpu%d/trace_pipe_raw"
>
> Should we try both old and new path then?

Sure, I think it makes sense to have all the comments & documentation point
only to the preferred location, but I think for tools it makes sense to check
both places so that we don't see field regressions. This is what the BPF code
does:

https://elixir.bootlin.com/linux/latest/source/tools/bpf/bpftool/tracelog.c#L98

I'll add a check and fallback to this tool & send out v2. Thanks for the
review.

> > #define WRITE_PATH_FMT "/dev/virtio-ports/trace-path-cpu%d"
> > #define CTL_PATH "/dev/virtio-ports/agent-ctl-path"
> >
> > --
> > 2.39.1.456.gfc5497dd1b-goog
>