intel / intel/numatop

Guessing at failure: Fail to setup perf (probably permission denied)!

Open
#62 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
212
Forks
50
Avg merge
54m
Merged PRs (30d)
1

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.