Skip to contentSkip to conversation

perf stat dumps core when CPU offline

DISCUSSION Thomas Richter 2 participants 3 messages Dec 3, 2025

lore
Share & tools
lore
#0 lore raw

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

Signature · 9 lines
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
#1 lore raw
Quoted 20 lines · Thomas Richter

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
#
Quoted 3 lines

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/[email protected]/
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

Quoted 12 lines

--
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

#2 lore raw
Quoted 48 lines · Ian Rogers
Quoted 20 lines · Thomas Richter

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
#
Quoted 3 lines

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/[email protected]/
lands this will be resolved.

Quoted 5 lines

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/[email protected]/

Thanks,
Ian

Quoted 15 lines

Thanks,
Ian

Quoted 12 lines

--
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