[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240217005738.3744121-17-atishp@rivosinc.com>
Date: Fri, 16 Feb 2024 16:57:34 -0800
From: Atish Patra <atishp@...osinc.com>
To: linux-kernel@...r.kernel.org
Cc: Atish Patra <atishp@...osinc.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Alexandre Ghiti <alexghiti@...osinc.com>,
Andrew Jones <ajones@...tanamicro.com>,
Anup Patel <anup@...infault.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Atish Patra <atishp@...shpatra.org>,
Christian Brauner <brauner@...nel.org>,
Clément Léger <cleger@...osinc.com>,
Conor Dooley <conor@...nel.org>,
devicetree@...r.kernel.org,
Evan Green <evan@...osinc.com>,
Guo Ren <guoren@...nel.org>,
Heiko Stuebner <heiko@...ech.de>,
Ian Rogers <irogers@...gle.com>,
Ingo Molnar <mingo@...hat.com>,
James Clark <james.clark@....com>,
Jing Zhang <renyu.zj@...ux.alibaba.com>,
Jiri Olsa <jolsa@...nel.org>,
Ji Sheng Teoh <jisheng.teoh@...rfivetech.com>,
John Garry <john.g.garry@...cle.com>,
Jonathan Corbet <corbet@....net>,
Kan Liang <kan.liang@...ux.intel.com>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
kvm-riscv@...ts.infradead.org,
kvm@...r.kernel.org,
Ley Foon Tan <leyfoon.tan@...rfivetech.com>,
linux-doc@...r.kernel.org,
linux-perf-users@...r.kernel.org,
linux-riscv@...ts.infradead.org,
Mark Rutland <mark.rutland@....com>,
Namhyung Kim <namhyung@...nel.org>,
Palmer Dabbelt <palmer@...belt.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Peter Zijlstra <peterz@...radead.org>,
Rob Herring <robh+dt@...nel.org>,
Samuel Holland <samuel.holland@...ive.com>,
Weilin Wang <weilin.wang@...el.com>,
Will Deacon <will@...nel.org>,
kaiwenxue1@...il.com,
Yang Jihong <yangjihong1@...wei.com>
Subject: [PATCH RFC 16/20] tools/perf: Pass the Counter constraint values in the pmu events
RISC-V doesn't have any standard event to counter mapping discovery
mechanism in the ISA. The ISA defines 29 programmable counters and
platforms can choose to implement any number of them and map any
events to any counters. Thus, the perf tool need to inform the driver
about the counter mapping of each events.
The current perf infrastructure only parses the 'Counter' constraints
in metrics. This patch extends that to pass in the pmu events so that
any driver can retrieve those values via perf attributes if defined
accordingly.
Signed-off-by: Atish Patra <atishp@...osinc.com>
---
tools/perf/pmu-events/jevents.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py
index 30934a490109..f1e320077695 100755
--- a/tools/perf/pmu-events/jevents.py
+++ b/tools/perf/pmu-events/jevents.py
@@ -278,6 +278,11 @@ class JsonEvent:
return fixed[name.lower()]
return event
+ def counter_list_to_bitmask(counterlist):
+ counter_ids = list(map(int, counterlist.split(',')))
+ bitmask = sum(1 << pos for pos in counter_ids)
+ return bitmask
+
def unit_to_pmu(unit: str) -> Optional[str]:
"""Convert a JSON Unit to Linux PMU name."""
if not unit:
@@ -401,6 +406,10 @@ class JsonEvent:
else:
raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std)
+ if self.counter:
+ bitmask = counter_list_to_bitmask(self.counter)
+ event += f',counterid_mask={bitmask:#x}'
+
self.event = real_event(self.name, event)
def __repr__(self) -> str:
--
2.34.1
Powered by blists - more mailing lists