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

About the support for the instruction RDPMC #223

Closed
U1tra1isk opened this issue Sep 2, 2024 · 1 comment
Closed

About the support for the instruction RDPMC #223

U1tra1isk opened this issue Sep 2, 2024 · 1 comment
Assignees

Comments

@U1tra1isk
Copy link

U1tra1isk commented Sep 2, 2024

I am wonderring whether the RDPMC instrcution is supported in recent generations of CPU. My CPU is i9-10980XE and I use Debian 12.6. I run a test program using the cpuid instruction and find that the RDPMC is not supported. The test code given by ChatGPT is shown below

#include <stdio.h>
#include <cpuid.h>

void check_rdpmc_support() {
    unsigned int eax, ebx, ecx, edx;
    __cpuid(0xA, eax, ebx, ecx, edx);
    if (edx & (1 << 23)) {
        printf("RDPMC is supported\n");
    } else {
        printf("RDPMC is not supported\n");
    }
}

int main() {
    check_rdpmc_support();
    return 0;
}

It turns out to be not supported.

The most primitive problem is that I want to monitoring the performance of a circle. I tried RDMSR instruction at first, but as RDMSR needs privilege 0 and the cost of using system call is unaffordable. Also, system call also introduce unpredictable extra cost itself. This also happens on the Perf, so I turn to RDPMC. As ChatGpt says, it can be used on privilege 3, but I have never make it successfully. The test program above also indicates the RDPMC is not supported in my machine. So I am wondering whether it can be used at privilege 3. If we can use it at privilege 3, then which CPU support it in recent generations (10-14 generation)?

@edwarddavidbaker edwarddavidbaker self-assigned this Sep 24, 2024
@edwarddavidbaker
Copy link
Contributor

Thanks for opening an issue. For a RDPMC reference please review https://github.com/andikleen/pmu-tools/blob/master/jevents/rdpmc.c . Depending on your Linux distribution you may also need to set /sys/devices/cpu/rdpmc to allow user space access. The RDPMC instruction is still available on recent generations.

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

No branches or pull requests

2 participants