Page MenuHomeFreeBSD

Use correct idle routine on AMD
ClosedPublic

Authored by gallatin on Nov 4 2024, 10:25 PM.
Tags
None
Referenced Files
F106177403: D47444.diff
Thu, Dec 26, 4:19 PM
Unknown Object (File)
Thu, Dec 12, 1:02 AM
Unknown Object (File)
Sun, Dec 8, 11:43 PM
Unknown Object (File)
Tue, Dec 3, 7:14 PM
Unknown Object (File)
Wed, Nov 27, 5:16 AM
Unknown Object (File)
Nov 26 2024, 1:18 AM
Unknown Object (File)
Nov 25 2024, 10:47 PM
Unknown Object (File)
Nov 21 2024, 12:09 PM
Subscribers

Details

Summary

We have been incorrectly choosing the "hlt" idle method on modern AMD EPYC servers for C1 idle. This is because AMD also uses the Functional Fixed Hardware interface. Due to not parsing the table properly for AMD, and due to a weird quirk where the mwait latency for C1 is mis-interpreted as the latency for hlt, we wind up choosing hlt for c1, which has a far wake up higher latency (similar to IO) of roughly 400us on my test system (AMD 7502P).

This patch fixes this by:

  • Looking for AMD in addition to Intel in the FFH
  • Using mwait on AMD when specified in the table, and when CPUid says its supported
  • Fixing a weird issue where we copy the contents of cx_ptr for C1 and when moving to C2, we do not reinitialize cx_ptr. This leads to mwait being selected, and ignoring the specified i/o halt method unless we clear mwait before looking at the table for C2.
Test Plan

On a 7502P, sysctl dev.cpu.0.cx_method should change from C1/hlt C2/io to C1/mwait C2/io

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/acpica/acpi_cpu.c
134

I am curious where this value is defined.

I only aware about Intel 302223-007.pdf which talks only about Intel.

I share kib's curiosity, but it clearly works, so LGTM. Nice find!

This revision is now accepted and ready to land.Nov 5 2024, 7:15 PM
sys/dev/acpica/acpi_cpu.c
134

I found it in the table as "2", and assumed from context it was AMD's vendor id. I then confirmed this with AMD, who said its correct, but not currently documented publicly. I asked them to document it publicly..

It is not only the vendor code, but the whole spec for Processor ACPI vendor-specific fixed functions. It is only Intel which specified something, which is why I only enabled it on Intel.