Skip to content

Commit 22333af

Browse files
kimphillamdgregkh
authored andcommitted
perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT flag
[ Upstream commit f967140 ] Enable the sampling check in kernel/events/core.c::perf_event_open(), which returns the more appropriate -EOPNOTSUPP. BEFORE: $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true Error: The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (l3_request_g1.caching_l3_cache_accesses). /bin/dmesg | grep -i perf may provide additional information. With nothing relevant in dmesg. AFTER: $ sudo perf record -a -e instructions,l3_request_g1.caching_l3_cache_accesses true Error: l3_request_g1.caching_l3_cache_accesses: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat' Fixes: c43ca50 ("perf/x86/amd: Add support for AMD NB and L2I "uncore" counters") Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 135075a commit 22333af

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

arch/x86/events/amd/uncore.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,18 @@ static int amd_uncore_event_init(struct perf_event *event)
185185

186186
/*
187187
* NB and Last level cache counters (MSRs) are shared across all cores
188-
* that share the same NB / Last level cache. Interrupts can be directed
189-
* to a single target core, however, event counts generated by processes
190-
* running on other cores cannot be masked out. So we do not support
191-
* sampling and per-thread events.
188+
* that share the same NB / Last level cache. On family 16h and below,
189+
* Interrupts can be directed to a single target core, however, event
190+
* counts generated by processes running on other cores cannot be masked
191+
* out. So we do not support sampling and per-thread events via
192+
* CAP_NO_INTERRUPT, and we do not enable counter overflow interrupts:
192193
*/
193-
if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
194-
return -EINVAL;
195194

196195
/* NB and Last level cache counters do not have usr/os/guest/host bits */
197196
if (event->attr.exclude_user || event->attr.exclude_kernel ||
198197
event->attr.exclude_host || event->attr.exclude_guest)
199198
return -EINVAL;
200199

201-
/* and we do not enable counter overflow interrupts */
202200
hwc->config = event->attr.config & AMD64_RAW_EVENT_MASK_NB;
203201
hwc->idx = -1;
204202

@@ -275,6 +273,7 @@ static struct pmu amd_nb_pmu = {
275273
.start = amd_uncore_start,
276274
.stop = amd_uncore_stop,
277275
.read = amd_uncore_read,
276+
.capabilities = PERF_PMU_CAP_NO_INTERRUPT,
278277
};
279278

280279
static struct pmu amd_llc_pmu = {
@@ -287,6 +286,7 @@ static struct pmu amd_llc_pmu = {
287286
.start = amd_uncore_start,
288287
.stop = amd_uncore_stop,
289288
.read = amd_uncore_read,
289+
.capabilities = PERF_PMU_CAP_NO_INTERRUPT,
290290
};
291291

292292
static struct amd_uncore *amd_uncore_alloc(unsigned int cpu)

0 commit comments

Comments
 (0)