don't use fast rdpmc counter reads in attach or syswide scenarios #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With perf_event we can use fast rdpmc reads for low-overhead counter access. This only works in self-monitoring situations where the thread being measured is in the same process context and same CPU as PAPI. This means it cannot generally be used in the attach case, or if trying to do system-wide measurements (granularity anything other than PAPI_GRN_THR).
Ideally the Linux kernel would notice the request to use rdpmc in inappropriate circumstances and cause the mmap() read to fail and fallback to using the read() syscall. However for various reasons the kernel devs did not want to support this, so it's up to PAPI to avoid using rdpmc in cases where Linux will silently fail and allow rdpmc to return invalid counter values.
This should fix the "attach_cpu_sys_validate" test failure.