martinus / nanobench

Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20
https://nanobench.ankerl.com
MIT License
1.43k stars 82 forks source link

syscall failing #106

Open mortenfc opened 9 months ago

mortenfc commented 9 months ago

I added this to debug the syscall

auto fd = static_cast(syscall(__NR_perf_event_open, &pea, pid, cpu, mFd, flags)); std::cout << "errno after syscall: " << errno << std::endl; if (-1 == fd) { perror("Error occurred"); return false; }

And I get

errno after syscall: 22 Error occurred: Invalid argument errno after syscall: 2 Error occurred: No such file or directory

Why?

mortenfc commented 9 months ago

It turns out my vm did not have virtualized performance counters enabled, so only the SW events are working. I can't enable those performance counters for some CPU/bios reason. It would be good to print an error if HW performance counters can't be measured.