linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/x86: Fix open counting event error
@ 2025-04-23  6:47 Luo Gengkun
  2025-04-23 13:51 ` Liang, Kan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Luo Gengkun @ 2025-04-23  6:47 UTC (permalink / raw)
  To: peterz
  Cc: mingo, acme, namhyung, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, kan.liang, tglx, bp, dave.hansen, x86,
	hpa, ravi.bangoria, linux-perf-users, linux-kernel

Perf doesn't work at perf stat for hardware events:

 $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 event is
unexpectedly applied to the counting event.

Fixes: 88ec7eedbbd2 ("perf/x86: Fix low freqency setting issue")
Signed-off-by: Luo Gengkun <luogengkun@huaweicloud.com>
---
 arch/x86/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index 6866cc5acb0b..3a4f031d2f44 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -629,7 +629,7 @@ int x86_pmu_hw_config(struct perf_event *event)
 	if (event->attr.type == event->pmu->type)
 		event->hw.config |= x86_pmu_get_event_config(event);
 
-	if (!event->attr.freq && x86_pmu.limit_period) {
+	if (is_sampling_event(event) && !event->attr.freq && x86_pmu.limit_period) {
 		s64 left = event->attr.sample_period;
 		x86_pmu.limit_period(event, &left);
 		if (left > event->attr.sample_period)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-04-30 14:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23  6:47 [PATCH] perf/x86: Fix open counting event error Luo Gengkun
2025-04-23 13:51 ` Liang, Kan
2025-04-24  6:52 ` Ravi Bangoria
2025-04-24 17:15   ` Liang, Kan
2025-04-25 10:12     ` Ravi Bangoria
2025-04-30 14:12       ` Liang, Kan
2025-04-24 16:20 ` Ingo Molnar
2025-04-24 17:08   ` Liang, Kan
2025-04-24 18:14     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).