[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAN37VV5bn6XiO0ykX8-WJLNE8447r7=zU1hy=KU+Z4RcoYtMOA@mail.gmail.com>
Date: Mon, 9 Feb 2026 17:26:07 +0530
From: Mayuresh Chitale <mchitale@...tanamicro.com>
To: Eric Lin <eric.lin@...ive.com>
Cc: Anup Patel <apatel@...tanamicro.com>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt <palmer@...belt.com>,
Greg KH <gregkh@...uxfoundation.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Ian Rogers <irogers@...gle.com>,
Mark Rutland <mark.rutland@....com>, devicetree@...r.kernel.org,
Alexandre Ghiti <alex@...ti.fr>, Atish Patra <atish.patra@...ux.dev>,
Peter Zijlstra <peterz@...radead.org>, Anup Patel <anup@...infault.org>,
Adrian Hunter <adrian.hunter@...el.com>, linux-kernel@...r.kernel.org,
Ingo Molnar <mingo@...hat.com>, Jiri Olsa <jolsa@...nel.org>,
Mayuresh Chitale <mchitale@...il.com>, Namhyung Kim <namhyung@...nel.org>,
linux-riscv@...ts.infradead.org, Andrew Jones <ajones@...tanamicro.com>,
Liang Kan <kan.liang@...ux.intel.com>
Subject: Re: [PATCH v2 11/12] perf tools: Initial support for RISC-V trace decoder
Hi Eric,
On Fri, Feb 6, 2026 at 6:25 PM Eric Lin <eric.lin@...ive.com> wrote:
>
> Hi Anup,
>
> On Sat, Nov 1, 2025 at 11:45 PM Anup Patel <apatel@...tanamicro.com> wrote:
> >
> > From: Mayuresh Chitale <mchitale@...tanamicro.com>
> >
> > Add bare bones support for RISC-V trace decoder so that the data received
> > from the hardware by the RISC-V trace perf driver can be written to the
> > perf record output file.
> >
> > Co-developed-by: Anup Patel <apatel@...tanamicro.com>
> > Signed-off-by: Anup Patel <apatel@...tanamicro.com>
> > Signed-off-by: Mayuresh Chitale <mchitale@...tanamicro.com>
> > ---
> > tools/perf/util/Build | 1 +
> > tools/perf/util/auxtrace.c | 3 +
> > tools/perf/util/rvtrace-decoder.c | 91 +++++++++++++++++++++++++++++++
> > tools/perf/util/rvtrace.h | 2 +
> > 4 files changed, 97 insertions(+)
> > create mode 100644 tools/perf/util/rvtrace-decoder.c
> >
> > diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> > index 4be313cd115a..f736cea51fd8 100644
> > --- a/tools/perf/util/Build
> > +++ b/tools/perf/util/Build
> > @@ -145,6 +145,7 @@ perf-util-$(CONFIG_AUXTRACE) += cs-etm.o
> > perf-util-$(CONFIG_AUXTRACE) += cs-etm-decoder/
> > endif
> > perf-util-$(CONFIG_AUXTRACE) += cs-etm-base.o
> > +perf-util-$(CONFIG_AUXTRACE) += rvtrace-decoder.o
> >
> > perf-util-y += parse-branch-options.o
> > perf-util-y += dump-insn.o
> > diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
> > index c905563e0d8a..299991d5d305 100644
> > --- a/tools/perf/util/auxtrace.c
> > +++ b/tools/perf/util/auxtrace.c
> > @@ -54,6 +54,7 @@
> > #include "arm-spe.h"
> > #include "hisi-ptt.h"
> > #include "s390-cpumsf.h"
> > +#include "rvtrace.h"
> > #include "util/mmap.h"
> > #include "powerpc-vpadtl.h"
> >
> > @@ -1395,6 +1396,8 @@ int perf_event__process_auxtrace_info(struct perf_session *session,
> > err = powerpc_vpadtl_process_auxtrace_info(event, session);
> > break;
> > case PERF_AUXTRACE_RISCV_TRACE:
> > + err = rvtrace__process_auxtrace_info(event, session);
> > + break;
> > case PERF_AUXTRACE_UNKNOWN:
> > default:
> > return -EINVAL;
> > diff --git a/tools/perf/util/rvtrace-decoder.c b/tools/perf/util/rvtrace-decoder.c
> > new file mode 100644
> > index 000000000000..58db5ca62c1a
> > --- /dev/null
> > +++ b/tools/perf/util/rvtrace-decoder.c
> > @@ -0,0 +1,91 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * RISC-V trace Decoder
> > + */
> > +
> > +#include <errno.h>
> > +#include <inttypes.h>
> > +#include "evlist.h"
> > +#include <internal/lib.h>
> > +#include "rvtrace.h"
> > +
> > +struct rvtrace_decoder {
> > + struct auxtrace auxtrace;
> > + u32 auxtrace_type;
> > + struct perf_session *session;
> > + struct machine *machine;
> > + u32 pmu_type;
> > +};
> > +
> > +static int rvtrace_process_event(struct perf_session *session __maybe_unused,
> > + union perf_event *event __maybe_unused,
> > + struct perf_sample *sample __maybe_unused,
> > + const struct perf_tool *tool __maybe_unused)
> > +{
> > + return 0;
> > +}
> > +
> > +static int rvtrace_process_auxtrace_event(struct perf_session *session __maybe_unused,
> > + union perf_event *event __maybe_unused,
> > + const struct perf_tool *tool __maybe_unused)
> > +{
> > + return 0;
> > +}
> > +
> > +static int rvtrace_flush(struct perf_session *session __maybe_unused,
> > + const struct perf_tool *tool __maybe_unused)
> > +{
> > + return 0;
> > +}
> > +
> > +static void rvtrace_free_events(struct perf_session *session __maybe_unused)
> > +{
> > +}
> > +
> > +static void rvtrace_free(struct perf_session *session)
> > +{
> > + struct rvtrace_decoder *ptr = container_of(session->auxtrace, struct rvtrace_decoder,
> > + auxtrace);
> > +
> > + session->auxtrace = NULL;
> > + free(ptr);
> > +}
> > +
> > +static bool rvtrace_evsel_is_auxtrace(struct perf_session *session,
> > + struct evsel *evsel)
> > +{
> > + struct rvtrace_decoder *ptr = container_of(session->auxtrace,
> > + struct rvtrace_decoder, auxtrace);
> > +
> > + return evsel->core.attr.type == ptr->pmu_type;
> > +}
> > +
> > +int rvtrace__process_auxtrace_info(union perf_event *event,
> > + struct perf_session *session)
> > +{
> > + struct perf_record_auxtrace_info *auxtrace_info = &event->auxtrace_info;
> > + struct rvtrace_decoder *ptr;
> > +
> > + if (auxtrace_info->header.size < RVTRACE_AUXTRACE_PRIV_SIZE +
> > + sizeof(struct perf_record_auxtrace_info))
> > + return -EINVAL;
> > +
> > + ptr = zalloc(sizeof(*ptr));
> > + if (!ptr)
> > + return -ENOMEM;
> > +
> > + ptr->session = session;
> > + ptr->machine = &session->machines.host;
> > + ptr->auxtrace_type = auxtrace_info->type;
> > + ptr->pmu_type = auxtrace_info->priv[0];
> > +
> > + ptr->auxtrace.process_event = rvtrace_process_event;
> > + ptr->auxtrace.process_auxtrace_event = rvtrace_process_auxtrace_event;
> > + ptr->auxtrace.flush_events = rvtrace_flush;
> > + ptr->auxtrace.free_events = rvtrace_free_events;
> > + ptr->auxtrace.free = rvtrace_free;
> > + ptr->auxtrace.evsel_is_auxtrace = rvtrace_evsel_is_auxtrace;
> > + session->auxtrace = &ptr->auxtrace;
> > +
> > + return 0;
> > +}
> > diff --git a/tools/perf/util/rvtrace.h b/tools/perf/util/rvtrace.h
> > index 93c041db8660..fdf2e5866c85 100644
> > --- a/tools/perf/util/rvtrace.h
> > +++ b/tools/perf/util/rvtrace.h
> > @@ -15,4 +15,6 @@
> >
> > #define RVTRACE_AUXTRACE_PRIV_SIZE sizeof(u64)
> >
> > +int rvtrace__process_auxtrace_info(union perf_event *event, struct perf_session *session);
> > +struct auxtrace_record *rvtrace_record_init(int *err);
>
> It looks like the implementation of `rvtrace_recording_init` in the
> auxtrace.c file is static (private), and the arguments don't match
> this declaration.
> Should we remove "static" from auxtrace.c and update this prototype
> to: "struct auxtrace_record *rvtrace_recording_init(int *err, struct
> perf_pmu *rvtrace_pmu);"?
>
> Or should we simply remove this declaration from the header? Thanks.
The declaration should be removed from the header.
>
> Regards,
> Eric Lin,
>
> > #endif
> > --
> > 2.43.0
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@...ts.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv
Powered by blists - more mailing lists