-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
It would be great if you didn't try to guess why it failed to set up perf and instead actually use the return value from the function that failed. Here, I'm starting as root:
# numatop
NumaTOP is starting ...
Fail to setup perf (probably permission denied)!
Some time spent with strace -f and I discovered:
[pid 465193] perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER5, config=PERF_COUNT_HW_INSTRUCTIONS, ...}, -1, 143, 1020, 0) = 1023
[pid 465193] ioctl(1023, PERF_EVENT_IOC_SET_OUTPUT, 1020) = 0
[pid 465193] perf_event_open({type=PERF_TYPE_RAW, size=PERF_ATTR_SIZE_VER5, config=0x5301bb, ...}, -1, 143, 1020, 0) = -1 EMFILE (Too many open files)
Clearly in this case the correct fix was to increase the file limit with ulimit -n (was 1024, 2048 worked).
Given there are many reasons why perf_event_open(2) can fail, it would be helpful to not guess and use perror(3) or something.
Thank you!
Metadata
Metadata
Assignees
Labels
No labels