-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: fix panic when CPU is offline #1503
Conversation
Hi @Ghostbaby, thank you for submitting your PR. |
Hi @mejedi, I added some details to the PR description. |
Hi @Ghostbaby Thanks for providing more context. Your panic indicates, that it is an issue with the perf reader. Can you also reproduce the issue with a minimal example, like in https://github.com/cilium/ebpf/blob/main/examples/tracepoint_in_go/ ? As I don't know of a KY10 SP1.1 system, I tried to reproduce the issue on a EC2 arm64 instance, but was not able to do so. If a CPU is offline during the creation of the perf event, we actually add Lines 219 to 225 in f2b2f6d
So my assumption is, that some CPUs are offline when you run the program. I will look more into this. |
Hi @florianl, Thank you for your review. # ./tracepoint_in_go
nCPU: 64
cpu: 16,err: can't create perf event: no such device
cpu: 17,err: can't create perf event: no such device
cpu: 18,err: can't create perf event: no such device
cpu: 19,err: can't create perf event: no such device
cpu: 20,err: can't create perf event: no such device
cpu: 21,err: can't create perf event: no such device
cpu: 22,err: can't create perf event: no such device
cpu: 23,err: can't create perf event: no such device
cpu: 24,err: can't create perf event: no such device
cpu: 25,err: can't create perf event: no such device
cpu: 26,err: can't create perf event: no such device
cpu: 27,err: can't create perf event: no such device
cpu: 28,err: can't create perf event: no such device
cpu: 29,err: can't create perf event: no such device
cpu: 30,err: can't create perf event: no such device
cpu: 31,err: can't create perf event: no such device
cpu: 32,err: can't create perf event: no such device
cpu: 33,err: can't create perf event: no such device
cpu: 34,err: can't create perf event: no such device
cpu: 35,err: can't create perf event: no such device
cpu: 36,err: can't create perf event: no such device
cpu: 37,err: can't create perf event: no such device
cpu: 38,err: can't create perf event: no such device
cpu: 39,err: can't create perf event: no such device
cpu: 40,err: can't create perf event: no such device
cpu: 41,err: can't create perf event: no such device
cpu: 42,err: can't create perf event: no such device
cpu: 43,err: can't create perf event: no such device
cpu: 44,err: can't create perf event: no such device
cpu: 45,err: can't create perf event: no such device
cpu: 46,err: can't create perf event: no such device
cpu: 47,err: can't create perf event: no such device
cpu: 48,err: can't create perf event: no such device
cpu: 49,err: can't create perf event: no such device
cpu: 50,err: can't create perf event: no such device
cpu: 51,err: can't create perf event: no such device
cpu: 52,err: can't create perf event: no such device
cpu: 53,err: can't create perf event: no such device
cpu: 54,err: can't create perf event: no such device
cpu: 55,err: can't create perf event: no such device
cpu: 56,err: can't create perf event: no such device
cpu: 57,err: can't create perf event: no such device
cpu: 58,err: can't create perf event: no such device
cpu: 59,err: can't create perf event: no such device
cpu: 60,err: can't create perf event: no such device
cpu: 61,err: can't create perf event: no such device
cpu: 62,err: can't create perf event: no such device
cpu: 63,err: can't create perf event: no such device
2024/07/05 17:35:43 Waiting for events..
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x19a778]
goroutine 1 [running]:
github.com/cilium/ebpf/perf.(*Reader).ReadInto(0x40001a0000, 0x40001af668)
/Users/zhuhuijun/go/src/github.com/cilium/ebpf/perf/reader.go:392 +0x6c8
github.com/cilium/ebpf/perf.(*Reader).Read(0x40001a0000)
/Users/zhuhuijun/go/src/github.com/cilium/ebpf/perf/reader.go:340 +0x48
main.main()
/Users/zhuhuijun/go/src/github.com/cilium/ebpf/examples/tracepoint_in_go/main.go:108 +0x106c After I added some debug info, I found that the # grep -i "Cpus_allowed" /proc/self/status
Cpus_allowed: ffffffff,ffffffff
Cpus_allowed_list: 0-63 |
@Ghostbaby thank you for provifing further details. Please share |
Hi @mejedi,Here are the query results. # cat /sys/devices/system/cpu/possible
0-63
# cat /sys/devices/system/cpu/online
0-15 and, Linux os enabled CPU hot plugin # grep CONFIG_HOTPLUG_CPU /boot/config-$(uname -r)
CONFIG_HOTPLUG_CPU=y looks like map MaxEntries init default value in here: Lines 137 to 150 in f2b2f6d
|
a1e5309
to
92b7a1c
Compare
I think this was introduced in #1429, specifically 75bce38 I think a simple The code as written will not work because |
Signed-off-by: zhuhuijun <zhuhuijunzhj@gmail.com>
Hi @brycekahle @mejedi @florianl , Thanks for your review, I have updated the code to skip the process when ring is nil. |
Thanks for the triage and digging out the culprit everyone! |
Code
eBPF code
GO code
header pkg: headers_fake.tar.gz
Reproducing
Build
Error
ebpf/perf/reader.go
Line 389 in f2b2f6d