Skip to content

Commit 1a97fea

Browse files
Luo GengkunIngo Molnar
authored andcommitted
perf/x86: Fix non-sampling (counting) events on certain x86 platforms
Perf doesn't work at perf stat for hardware events on certain x86 platforms: $perf stat -- sleep 1 Performance counter stats for 'sleep 1': 16.44 msec task-clock # 0.016 CPUs utilized 2 context-switches # 121.691 /sec 0 cpu-migrations # 0.000 /sec 54 page-faults # 3.286 K/sec <not supported> cycles <not supported> instructions <not supported> branches <not supported> branch-misses The reason is that the check in x86_pmu_hw_config() for sampling events is unexpectedly applied to counting events as well. It should only impact x86 platforms with limit_period used for non-PEBS events. For Intel platforms, it should only impact some older platforms, e.g., HSW, BDW and NHM. Fixes: 88ec7ee ("perf/x86: Fix low freqency setting issue") Signed-off-by: Luo Gengkun <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Kan Liang <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0db6138 commit 1a97fea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/events/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ int x86_pmu_hw_config(struct perf_event *event)
629629
if (event->attr.type == event->pmu->type)
630630
event->hw.config |= x86_pmu_get_event_config(event);
631631

632-
if (!event->attr.freq && x86_pmu.limit_period) {
632+
if (is_sampling_event(event) && !event->attr.freq && x86_pmu.limit_period) {
633633
s64 left = event->attr.sample_period;
634634
x86_pmu.limit_period(event, &left);
635635
if (left > event->attr.sample_period)

0 commit comments

Comments
 (0)