[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20230602071517-mutt-send-email-mst@kernel.org>
Date: Fri, 2 Jun 2023 07:15:26 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Ross Zwisler <zwisler@...omium.org>
Cc: linux-kernel@...r.kernel.org, Ross Zwisler <zwisler@...gle.com>,
Jason Wang <jasowang@...hat.com>,
virtualization@...ts.linux-foundation.org,
linux-trace-kernel@...r.kernel.org,
Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH v2 5/6] tools/virtio: use canonical ftrace path
On Wed, Feb 15, 2023 at 03:33:49PM -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@...gle.com>
queued this too. thanks!
> ---
> tools/virtio/virtio-trace/README | 2 +-
> tools/virtio/virtio-trace/trace-agent.c | 12 ++++++++----
> 2 files changed, 9 insertions(+), 5 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..7e2d9bbf0b84 100644
> --- a/tools/virtio/virtio-trace/trace-agent.c
> +++ b/tools/virtio/virtio-trace/trace-agent.c
> @@ -18,8 +18,9 @@
> #define PIPE_DEF_BUFS 16
> #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"
> +#define TRACEFS "/sys/kernel/tracing"
> +#define DEBUGFS "/sys/kernel/debug/tracing"
> +#define READ_PATH_FMT "%s/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"
>
> @@ -120,9 +121,12 @@ static const char *make_path(int cpu_num, bool this_is_write_path)
> if (this_is_write_path)
> /* write(output) path */
> ret = snprintf(buf, PATH_MAX, WRITE_PATH_FMT, cpu_num);
> - else
> + else {
> /* read(input) path */
> - ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, cpu_num);
> + ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, TRACEFS, cpu_num);
> + if (ret > 0 && access(buf, F_OK) != 0)
> + ret = snprintf(buf, PATH_MAX, READ_PATH_FMT, DEBUGFS, cpu_num);
> + }
>
> if (ret <= 0) {
> pr_err("Failed to generate %s path(CPU#%d):%d\n",
> --
> 2.39.1.637.g21b0678d19-goog
Powered by blists - more mailing lists