diff mbox series

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

Message ID 20230130181915.1113313-8-zwisler@google.com (mailing list archive)
State Superseded
Headers show
Series use canonical ftrace path whenever possible | expand

Commit Message

Ross Zwisler Jan. 30, 2023, 6:19 p.m. UTC
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@google.com>
---
 tools/virtio/virtio-trace/README        | 2 +-
 tools/virtio/virtio-trace/trace-agent.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Michael S. Tsirkin Jan. 30, 2023, 7:26 p.m. UTC | #1
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@google.com>
> ---
>  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?

>  #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
Ross Zwisler Feb. 1, 2023, 10:07 p.m. UTC | #2
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@google.com>
> > ---
> >  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
>
diff mbox series

Patch

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"
 #define WRITE_PATH_FMT		"/dev/virtio-ports/trace-path-cpu%d"
 #define CTL_PATH		"/dev/virtio-ports/agent-ctl-path"