crosvm/x86_64
ZhaoLiu 0c2ce08ca1 x86_64: Preparation for ITMT scheduling in Guest
With Intel Turbo Boost Max Technology 3.0, (ITMT),  the maximum turbo
frequencies of some cores in a CPU package may be higher than for the
other cores in the same package. In that case, make the scheduler prefer
to run tasks on the CPUs with higher max turbo frequencies, to achieve
better performance.

When vCPUs 1:1 map to pCPUs, ITMT scheduling feature can benefit
performance of Guest. So when user sets `--itmt`, crosvm will check if
`--host-cpu-topology` is set or if `--cpu-affinity` is set for 1:1
mapping.

In kernel, ITMT scheduling feature depends on intel_pstate driver and
ACPI CPPC support.

To setup intel_pstate driver and pass CPPC capability check, we need
emulate related MSRs in userspace:

- MSR_HWP_CAPABILITIES and MSR_TURBO_RATIO_LIMIT: intel_pstate driver
  only needs to read. So we passthrough them to Guest. But please note,
  to be compatible with the configuration in initramfs, use `FromCPU0`
  Temporarily.

- MSR_PM_ENABLE and MSR_HWP_REQUEST: they are MSRs to control HWP.
  When intel_pstate driver is initializing, the driver will close/open
  HWP by writing into MSR_PM_ENABLE, and the driver also needs to set
  performance policy by writing some hints into MSR_HWP_REQUEST.
  Note that we don't want Guest's behavior to affect the performance
  control of the host, so use 'emulate' handler for them.

- MSR_PLATFORM_INFO: this MSR is emulated in kernel with a fault value
  by default. intel_pstate doesn't want this fault value, so we ask
  this MSR to exit to userspace and give it a real value.

- MSR_IA32_PERF_CTL: intel_pstate driver use this MSR to set the min
  pstate in the initialization. So use 'emulate' handler for this MSR.

Since of `FromCPU0` setting of MSR_HWP_CAPABILITIES, ITMT scheduling
will set the same priority for each core so optimization will not work.

BUG=b:225375705
TEST=Set `--itmt` and check /proc/sys/kernel/sched_itmt_enabled

Change-Id: Icfa85ffa15c3b977c3b62a1f8a379c4c2f5fc49d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575511
Commit-Queue: Zhao Liu <zhao1.liu@intel.corp-partner.google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-25 08:21:16 +00:00
..
src x86_64: Preparation for ITMT scheduling in Guest 2022-04-25 08:21:16 +00:00
Cargo.toml crosvm: Support MSR emulation 2022-04-25 07:50:55 +00:00