Perf events consume one file descriptor per thread. Make sure the current limit is the highest possible.
| 164 | // Perf events consume one file descriptor per thread. |
| 165 | // Make sure the current limit is the highest possible. |
| 166 | static void adjustFDLimit() { |
| 167 | struct rlimit rlim; |
| 168 | if (getrlimit(RLIMIT_NOFILE, &rlim) == 0 && rlim.rlim_cur < rlim.rlim_max) { |
| 169 | rlim.rlim_cur = rlim.rlim_max; |
| 170 | setrlimit(RLIMIT_NOFILE, &rlim); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // Workaround for the kernel bug: PERF_EVENT_IOC_REFRESH can hang |
| 175 | // the entire system on Linux 6.16.x and 6.17.x. |