linux/tools
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
..
accounting
arch perf headers: Sync perf_event.h/perf_regs.h with the kernel headers 2026-09-14 15:32:52 -03:00
bootconfig Bootconfig updates for v7.3: 2026-08-25 08:59:09 -07:00
bpf perf tools updates for v7.3 2026-08-22 08:47:50 -07:00
build tools build: Fix timerfd feature detection with clang 2026-09-12 17:22:18 -03:00
certs
cgroup
counter
crypto
debugging
dma
docs doc tools: fix 'path' typos 2026-08-11 10:43:16 -06:00
firewire
firmware
gpio
hv
iio
include perf headers: Sync perf_event.h/perf_regs.h with the kernel headers 2026-09-14 15:32:52 -03:00
kvm/kvm_stat
laptop
leds
lib perf record: Fix unhandled POLLHUP on non_perf_event descriptors 2026-09-17 12:27:34 -03:00
memory-model
mm mm.git review status for master..mm-nonmm-stable 2026-08-23 08:07:11 -07:00
net Including fixes from Bluetooth, IPSec and Netfilter. 2026-08-27 13:53:43 -07:00
objtool Rust fixes for v7.3 2026-08-30 09:47:39 -07:00
pcmcia
perf perf topdown: Don't require config1==0 for a slots event 2026-09-18 17:18:25 -03:00
platform/x86/amd
power
rcu
sched
sched_ext sched_ext: Check bpf_timer_start return values in scx_qmap 2026-08-31 06:47:39 -10:00
scripts perf tools updates for v7.3 2026-08-22 08:47:50 -07:00
sound
spi
testing bpf-fixes 2026-09-06 13:49:44 -07:00
thermal
time
tracing
unittests
usb
verification verification/rvgen: Use .old instead of .bak for kunit backup files 2026-08-25 13:56:53 +02:00
virtio tools/virtio: Fix control typo in trace agent comment 2026-08-19 06:38:48 -04:00
wmi
workqueue tools/workqueue/wq_dump.py: Support backward compatibility for wq->attrs rename 2026-08-31 10:17:08 -10:00
writeback
Makefile