linux/tools/perf/arch
Zide Chen 0824af00a8 perf topdown: Don't require config1==0 for a slots event
arch_is_topdown_slots() requires config1 == 0, so it misidentified
"cpu/slots,metrics_clear=1/" as not being the slots event, and an
additional slots event gets inserted, which fails event scheduling
since the group now needs two fixed counter 3.

  $ perf stat -e "{cpu/slots,metrics_clear=1/,cpu/topdown-retiring/}" -- sleep 1
  WARNING: events were regrouped to match PMUs
       <not counted>      slots
     <not supported>      cpu/slots,metrics_clear=1/
       <not counted>      cpu/topdown-retiring/

Drop the config1 == 0 check from arch_is_topdown_slots(). This is
safe: config1 has no bearing on the event's identifying config value
(TOPDOWN_SLOTS, 0x0400).

The attr.type == PERF_TYPE_RAW check is what actually matters: only the
core PMU is registered with PERF_TYPE_RAW, and on x86, 0x400 is
guaranteed to be slots event on core CPU.

arch_is_topdown_metrics() keeps its own config1 == 0 check, since
genuine metrics events have no "metrics_clear" and config1 remains 0.

Add a test verifying that an explicit "slots,metrics_clear=1" event in
a group does not trigger an extra slots event injection.

Fixes: 5b546de9cc ("perf topdown: Use attribute to see an event is a topdown metic or slots")
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
[ Add missing stdio.h and string.h as noticed by Sashiko ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-18 17:18:25 -03:00
..
alpha perf build: Remove Makefile.syscalls 2025-03-20 22:58:20 -07:00
arm perf tools updates for v7.3 2026-08-22 08:47:50 -07:00
arm64 perf evlist: Add reference count checking 2026-06-30 10:17:11 -07:00
csky/include perf regs: Remove __weak attributive arch__xxx_reg_mask() functions 2026-02-06 12:16:09 -03:00
loongarch perf unwind-libunwind: Make libunwind register reading cross platform 2026-05-15 16:18:36 -03:00
mips arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
parisc perf build: Remove Makefile.syscalls 2025-03-20 22:58:20 -07:00
powerpc arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
riscv perf riscv: fix register name strings 2026-06-10 16:54:41 -03:00
s390 arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
sh arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
sparc arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
x86 perf topdown: Don't require config1==0 for a slots event 2026-09-18 17:18:25 -03:00
xtensa arch: hookup fchroot() system call 2026-07-27 17:18:00 +02:00
Build perf util: Make util its own library 2024-06-26 11:07:42 -07:00
common.c perf arch common: Use perf_env e_machine rather than arch 2026-06-03 16:48:23 -03:00
common.h perf annotate: Own objdump_path and disassembler_style strings 2023-04-04 09:39:56 -03:00