Linux Perf Users
 help / color / mirror / Atom feed
* perf stat dumps core when CPU offline
@ 2025-12-03 13:20 Thomas Richter
  2025-12-03 17:47 ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Richter @ 2025-12-03 13:20 UTC (permalink / raw)
  To: linux-perf-use.; +Cc: Jan Polensky

Hi all,

Is this a known issue? Trying to do a perf stat on a CPU which is offline.

# echo 1 > /sys/devices/system/cpu/cpu1/online
# perf stat -C1 -e cycles -- true

 Performance counter stats for 'CPU(s) 1':

           123,965      cycles                                                                

       0.000356838 seconds time elapsed

# echo 0 > /sys/devices/system/cpu/cpu1/online
# perf stat -C1 -e cycles -- true
WARNING: A requested CPU in '1' is not supported by PMU 'cpum_cf' (CPUs 0,2-7) for event 'cycles'
Segmentation fault         (core dumped) perf stat -C1 -e cycles -- true
# 

This happens on linux-next and linux.

Thanks a lot
-- 
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH

Vorsitzender des Aufsichtsrats: Wolfgang Wendt

Geschäftsführung: David Faller

Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294


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

* Re: perf stat dumps core when CPU offline
  2025-12-03 13:20 perf stat dumps core when CPU offline Thomas Richter
@ 2025-12-03 17:47 ` Ian Rogers
  2025-12-03 21:51   ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2025-12-03 17:47 UTC (permalink / raw)
  To: Thomas Richter; +Cc: linux-perf-use., Jan Polensky

On Wed, Dec 3, 2025 at 5:20 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
>
> Hi all,
>
> Is this a known issue? Trying to do a perf stat on a CPU which is offline.
>
> # echo 1 > /sys/devices/system/cpu/cpu1/online
> # perf stat -C1 -e cycles -- true
>
>  Performance counter stats for 'CPU(s) 1':
>
>            123,965      cycles
>
>        0.000356838 seconds time elapsed
>
> # echo 0 > /sys/devices/system/cpu/cpu1/online
> # perf stat -C1 -e cycles -- true
> WARNING: A requested CPU in '1' is not supported by PMU 'cpum_cf' (CPUs 0,2-7) for event 'cycles'
> Segmentation fault         (core dumped) perf stat -C1 -e cycles -- true
> #
>
> This happens on linux-next and linux.
>
> Thanks a lot

Hi Thomas,

sorry for the issue! I ran a similar test and got the segmentation
fault. gdb showed the issue was similar to a bug with `perf stat
--null` and testing those fixes gave me:
```
$ cat /sys/devices/system/cpu/cpu8/online
0
$ perf stat -C8 -e cycles -- true
WARNING: A requested CPU in '8' is not supported by PMU 'cpu' (CPUs
0-7) for event 'cycles'
Error:
No supported events found.
The sys_perf_event_open() syscall returned with 0 (Success) for event
(cpu/unknown-hardware/).
"dmesg | grep -i perf" may provide additional information.
```

Not a great error message but hopefully when:
https://lore.kernel.org/lkml/20251201230904.290733-1-irogers@google.com/
lands this will be resolved.

I think we can test this behavior as the only thing required is a CPU
that's not in the cpumask, any very large numbered CPU will do that. I
also think the error message of "Success" is confusing, we should
probably just drop that message if the errno is 0. I'll add these two
patches to that existing series.

Thanks,
Ian

> --
> Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> --
> IBM Deutschland Research & Development GmbH
>
> Vorsitzender des Aufsichtsrats: Wolfgang Wendt
>
> Geschäftsführung: David Faller
>
> Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
>
>

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

* Re: perf stat dumps core when CPU offline
  2025-12-03 17:47 ` Ian Rogers
@ 2025-12-03 21:51   ` Ian Rogers
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-12-03 21:51 UTC (permalink / raw)
  To: Thomas Richter; +Cc: linux-perf-use., Jan Polensky

On Wed, Dec 3, 2025 at 9:47 AM Ian Rogers <irogers@google.com> wrote:
>
> On Wed, Dec 3, 2025 at 5:20 AM Thomas Richter <tmricht@linux.ibm.com> wrote:
> >
> > Hi all,
> >
> > Is this a known issue? Trying to do a perf stat on a CPU which is offline.
> >
> > # echo 1 > /sys/devices/system/cpu/cpu1/online
> > # perf stat -C1 -e cycles -- true
> >
> >  Performance counter stats for 'CPU(s) 1':
> >
> >            123,965      cycles
> >
> >        0.000356838 seconds time elapsed
> >
> > # echo 0 > /sys/devices/system/cpu/cpu1/online
> > # perf stat -C1 -e cycles -- true
> > WARNING: A requested CPU in '1' is not supported by PMU 'cpum_cf' (CPUs 0,2-7) for event 'cycles'
> > Segmentation fault         (core dumped) perf stat -C1 -e cycles -- true
> > #
> >
> > This happens on linux-next and linux.
> >
> > Thanks a lot
>
> Hi Thomas,
>
> sorry for the issue! I ran a similar test and got the segmentation
> fault. gdb showed the issue was similar to a bug with `perf stat
> --null` and testing those fixes gave me:
> ```
> $ cat /sys/devices/system/cpu/cpu8/online
> 0
> $ perf stat -C8 -e cycles -- true
> WARNING: A requested CPU in '8' is not supported by PMU 'cpu' (CPUs
> 0-7) for event 'cycles'
> Error:
> No supported events found.
> The sys_perf_event_open() syscall returned with 0 (Success) for event
> (cpu/unknown-hardware/).
> "dmesg | grep -i perf" may provide additional information.
> ```
>
> Not a great error message but hopefully when:
> https://lore.kernel.org/lkml/20251201230904.290733-1-irogers@google.com/
> lands this will be resolved.
>
> I think we can test this behavior as the only thing required is a CPU
> that's not in the cpumask, any very large numbered CPU will do that. I
> also think the error message of "Success" is confusing, we should
> probably just drop that message if the errno is 0. I'll add these two
> patches to that existing series.

Patches to fix, test and error message clean up added in:
https://lore.kernel.org/lkml/20251203214706.112174-1-irogers@google.com/

Thanks,
Ian

> Thanks,
> Ian
>
> > --
> > Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
> > --
> > IBM Deutschland Research & Development GmbH
> >
> > Vorsitzender des Aufsichtsrats: Wolfgang Wendt
> >
> > Geschäftsführung: David Faller
> >
> > Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
> >
> >

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

end of thread, other threads:[~2025-12-03 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 13:20 perf stat dumps core when CPU offline Thomas Richter
2025-12-03 17:47 ` Ian Rogers
2025-12-03 21:51   ` Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox