Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't use fast rdpmc counter reads in attach or syswide scenarios #39

Merged
merged 1 commit into from
Jul 3, 2023

Conversation

deater
Copy link
Contributor

@deater deater commented Jun 28, 2023

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.

@gcongiu gcongiu requested review from gcongiu and jagode June 29, 2023 07:07
Copy link
Contributor

@gcongiu gcongiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@gcongiu
Copy link
Contributor

gcongiu commented Jun 29, 2023

Addresses same problem as spack/spack#38574

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.
@gcongiu gcongiu merged commit 1109043 into icl-utk-edu:master Jul 3, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants