rdmsr 时序是否取决于寄存器读取?

Bee*_*ope 4 performance x86 x86-64 intel

执行 a 所需的时间是否在rdmsr很大程度上取决于寄存器读取?

And*_*bel 5

Yes, the time can depend significantly on the register. Here are a few examples (as measured on an Intel Core i7-8700K):

  • Reading register E8H (IA32_APERF) requires about 91 core cycles.
  • Reading register 1A0 (IA32_MISC_ENABLE) typically requires between ~500 and ~550 core cycles.
  • Reading register 19CH (IA32_THERM_STATUS) typically requires between ~900 and ~1050 core cycles.
  • Reading register 198H (IA32_PERF_STATUS) typically requires between ~5300 and ~5700 core cycles.

Here are the nanoBench commands I used for the measurements:

sudo ./kernel-nanoBench.sh -asm "rdmsr" -asm_init "mov RCX, 0xE8"    
sudo ./kernel-nanoBench.sh -asm "rdmsr" -asm_init "mov RCX, 0x1A0"
sudo ./kernel-nanoBench.sh -asm "rdmsr" -asm_init "mov RCX, 0x19C"
sudo ./kernel-nanoBench.sh -asm "rdmsr" -asm_init "mov RCX, 0x198"
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的史诗般的回答。我对 0x198 MSR_PERF_STATUS 特别感兴趣,事实上这个非常慢:使用“nanoBench”的“核心周期:3577.96”。我在 i7-6700HQ 上的其他 MRS 上得到了与您类似的时序。 (2认同)