Skip to content
Snippets Groups Projects
Commit cfcde40e authored by Michael S. Tsirkin's avatar Michael S. Tsirkin
Browse files

ACPI: disable extra P_LVLx access on KVM


As documented by commit b488f021 "ACPI: restore comment justifying
'extra' P_LVLx access", Linux does an extra IO read after entering idle
because on (some) chipsets STPCLK# doesn't get asserted in time
to prevent further instruction processing.

This can never be the case on KVM, and a timer read causes an expensive
VM exit in turn causing useless load on host system. Detect KVM and skip
the read.  TODO: whitelist more hypervisors?

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: kvm@vger.kernel.org
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent c9cb15cc
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/cpuidle.h> #include <linux/cpuidle.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <acpi/processor.h> #include <acpi/processor.h>
#include <linux/kvm_para.h>
/* /*
* Include the apic definitions for x86 to have the APIC timer related defines * Include the apic definitions for x86 to have the APIC timer related defines
...@@ -665,7 +666,8 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx) ...@@ -665,7 +666,8 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx)
/* Dummy wait op - must do something useless after P_LVL2 read /* Dummy wait op - must do something useless after P_LVL2 read
because chipsets cannot guarantee that STPCLK# signal because chipsets cannot guarantee that STPCLK# signal
gets asserted in time to freeze execution properly. */ gets asserted in time to freeze execution properly. */
inl(acpi_gbl_FADT.xpm_timer_block.address); if (!kvm_para_available())
inl(acpi_gbl_FADT.xpm_timer_block.address);
} }
} }
...@@ -687,7 +689,8 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) ...@@ -687,7 +689,8 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
inb(cx->address); inb(cx->address);
/* See comment in acpi_idle_do_entry() */ /* See comment in acpi_idle_do_entry() */
inl(acpi_gbl_FADT.xpm_timer_block.address); if (!kvm_para_available())
inl(acpi_gbl_FADT.xpm_timer_block.address);
} else } else
return -ENODEV; return -ENODEV;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment