为什么ryzen上的p-state状态MSR没有变化?

Jes*_*ter 10 linux hardware cpu power-saving amd-processor

我试图检测我的CPU的当前p状态.我注意到p-state状态MSR(C001_0063)总是在我的ryzen 1700x系统上返回2,即使核心显然不在该状态.我认为它曾经用于我的主板附带的初始BIOS(v0403),但是不能再下载了1.

我的CPU超频2到3.8GHz.我曾经cpufreq-set修复速度并cpufreq-info验证:

analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 4294.55 ms.
  hardware limits: 2.20 GHz - 3.80 GHz
  available frequency steps: 3.80 GHz, 2.20 GHz
  available cpufreq governors: ondemand, conservative, performance, schedutil
  current policy: frequency should be within 3.80 GHz and 3.80 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 3.80 GHz (asserted by call to hardware).
Run Code Online (Sandbox Code Playgroud)

以下是一个小测试程序,显示核心#0的寄存器值,以及相对于P0状态的有效速度.需要root权限.对我来说,它经常pstate: 2, speed: 99%在负载下打印.

#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char** argv)
{
    uint64_t aperf_old = 0;
    uint64_t mperf_old = 0;
    int fd;

    fd = open("/dev/cpu/0/msr", O_RDONLY);
    uint64_t pstate_limits;
    pread(fd, &pstate_limits, sizeof(pstate_limits), 0xC0010061);
    printf("pstate ranges: %d to %d\n", (int)(pstate_limits & 0x07), (int)((pstate_limits >> 4) & 0x07));

    for(;;)
    {
        uint64_t pstate;
        uint64_t pstate_req;
        uint64_t aperf;
        uint64_t mperf;
        pread(fd, &pstate_req, sizeof(pstate_req), 0xC0010062);
        pread(fd, &pstate, sizeof(pstate), 0xC0010063);
        pread(fd, &aperf, sizeof(aperf), 0x000000E8);
        pread(fd, &mperf, sizeof(mperf), 0x000000E7);
        printf("pstate: %d, requested: %d", (int)(pstate & 0x07), (int)(pstate_req & 0x07));
        if (mperf_old != 0 && mperf_old != mperf)
        {
            printf(", speed: %d%%", (int)(100 * (aperf - aperf_old) / (mperf - mperf_old)));
        }
        putchar('\n');
        mperf_old = mperf;
        aperf_old = aperf;
        sleep(1);
    }
}
Run Code Online (Sandbox Code Playgroud)

类似的方法用于我的FX-8350.我究竟做错了什么?测试结果也欢迎.

系统信息:

  • Cpu:ryzen 1700x,P0&P1为3.8GHz 3,P2为2.2GHz
  • 主板:华硕Prime X370-A,BIOS 3401
  • 操作系统:debian 7.1,内核4.9.0

更新:我已更改代码以打印请求的pstate,并且该寄存器正在按预期更改.实际的CPU速度也在发生变化,各种基准测试证实了这一点.


1由于某些不明原因,bios备份功能被禁用,因此在更新之前我无法复制.

2当我有机会时,我会在默认情况下进行测试.

3不知道为什么它是重复的.

小智 0

可能没有关系,但我听说有些人已经成功地将他们的 Ryzen 7 替换为 AMD,因为 p 状态导致 Unix 或类 Unix 系统中的系统稳定性问题。尽管从对此事的评论来看,尤其是来自华擎论坛的评论指出了驱动程序/固件问题,但我在其他地方读到AMD可能对早期批次的芯片承担一些责任。也就是说,根据我对 P 和 C 状态的了解,某些状态是操作系统或主机垂直化环境所请求的。那么补丁可以从内部完成吗?