public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm-vmx: add module parameter to avoid trapping HLT instructions (v2)
@ 2010-12-02 13:59 Anthony Liguori
  2010-12-02 14:39 ` lidong chen
                   ` (2 more replies)
  0 siblings, 3 replies; 69+ messages in thread
From: Anthony Liguori @ 2010-12-02 13:59 UTC (permalink / raw)
  To: kvm
  Cc: Avi Kivity, Marcelo Tosatti, Chris Wright, Srivatsa Vaddagiri,
	Anthony Liguori

In certain use-cases, we want to allocate guests fixed time slices where idle
guest cycles leave the machine idling.  There are many approaches to achieve
this but the most direct is to simply avoid trapping the HLT instruction which
lets the guest directly execute the instruction putting the processor to sleep.

Introduce this as a module-level option for kvm-vmx.ko since if you do this
for one guest, you probably want to do it for all.  A similar option is possible
for AMD but I don't have easy access to AMD test hardware.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
v1 -> v2
 - Rename parameter to yield_on_hlt
 - Remove __read_mostly

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index caa967e..d8310e4 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -69,6 +69,9 @@ module_param(emulate_invalid_guest_state, bool, S_IRUGO);
 static int __read_mostly vmm_exclusive = 1;
 module_param(vmm_exclusive, bool, S_IRUGO);
 
+static int yield_on_hlt = 1;
+module_param(yield_on_hlt, bool, S_IRUGO);
+
 #define KVM_GUEST_CR0_MASK_UNRESTRICTED_GUEST				\
 	(X86_CR0_WP | X86_CR0_NE | X86_CR0_NW | X86_CR0_CD)
 #define KVM_GUEST_CR0_MASK						\
@@ -1419,7 +1422,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
 				&_pin_based_exec_control) < 0)
 		return -EIO;
 
-	min = CPU_BASED_HLT_EXITING |
+	min =
 #ifdef CONFIG_X86_64
 	      CPU_BASED_CR8_LOAD_EXITING |
 	      CPU_BASED_CR8_STORE_EXITING |
@@ -1432,6 +1435,10 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
 	      CPU_BASED_MWAIT_EXITING |
 	      CPU_BASED_MONITOR_EXITING |
 	      CPU_BASED_INVLPG_EXITING;
+
+	if (yield_on_hlt)
+		min |= CPU_BASED_HLT_EXITING;
+
 	opt = CPU_BASED_TPR_SHADOW |
 	      CPU_BASED_USE_MSR_BITMAPS |
 	      CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2010-12-06 16:33 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02 13:59 [PATCH] kvm-vmx: add module parameter to avoid trapping HLT instructions (v2) Anthony Liguori
2010-12-02 14:39 ` lidong chen
2010-12-02 15:23   ` Anthony Liguori
2010-12-02 15:23   ` Anthony Liguori
2010-12-03  9:38     ` Avi Kivity
2010-12-03 11:12       ` Srivatsa Vaddagiri
2010-12-03 23:28       ` Anthony Liguori
2010-12-02 17:37 ` Marcelo Tosatti
2010-12-02 19:07   ` Anthony Liguori
2010-12-02 20:12     ` Marcelo Tosatti
2010-12-02 20:51       ` Anthony Liguori
2010-12-03  9:36         ` Avi Kivity
2010-12-03 22:45           ` Anthony Liguori
2010-12-04  8:13             ` Avi Kivity
2010-12-04 13:30               ` Anthony Liguori
2010-12-06  8:28                 ` Avi Kivity
2010-12-06  8:35                   ` Avi Kivity
2010-12-06 13:58                     ` Anthony Liguori
2010-12-06 14:01                       ` Avi Kivity
2010-12-06 14:02                         ` Avi Kivity
2010-12-06 14:08                           ` Anthony Liguori
2010-12-06 14:14                             ` Gleb Natapov
2010-12-06 14:03                         ` Anthony Liguori
2010-12-06 14:33                           ` Avi Kivity
2010-12-06 15:07                             ` Anthony Liguori
2010-12-06 15:16                               ` Avi Kivity
2010-12-06 16:21                                 ` Anthony Liguori
2010-12-06 16:30                                   ` Avi Kivity
2010-12-06 16:33                                     ` Anthony Liguori
2010-12-03 12:40         ` Gleb Natapov
2010-12-03 23:31       ` Anthony Liguori
2010-12-03 22:42   ` Anthony Liguori
2010-12-04  8:16     ` Avi Kivity
2010-12-04 13:48       ` Anthony Liguori
2010-12-06  8:32         ` Avi Kivity
2010-12-02 19:14 ` Chris Wright
2010-12-02 20:25   ` Anthony Liguori
2010-12-02 20:40     ` Chris Wright
2010-12-02 20:40   ` Marcelo Tosatti
2010-12-02 21:07     ` Chris Wright
2010-12-02 22:37       ` Anthony Liguori
2010-12-03  2:42         ` Chris Wright
2010-12-03  3:21           ` Anthony Liguori
2010-12-03  3:44             ` Chris Wright
2010-12-03 14:25               ` Anthony Liguori
2010-12-02 22:27     ` Anthony Liguori
2010-12-03 22:49     ` Anthony Liguori
2010-12-04  5:43       ` Srivatsa Vaddagiri
2010-12-03  9:40   ` Avi Kivity
2010-12-03 11:21     ` Srivatsa Vaddagiri
2010-12-03 11:57   ` Srivatsa Vaddagiri
2010-12-03 16:27     ` Srivatsa Vaddagiri
2010-12-03 17:29       ` Chris Wright
2010-12-03 17:33         ` Srivatsa Vaddagiri
2010-12-04  8:18           ` Avi Kivity
2010-12-03 17:57         ` Srivatsa Vaddagiri
2010-12-03 17:58           ` Chris Wright
2010-12-03 18:07             ` Anthony Liguori
2010-12-03 18:12               ` Srivatsa Vaddagiri
2010-12-04  8:19                 ` Avi Kivity
2010-12-03 18:20               ` Chris Wright
2010-12-03 18:55                 ` Anthony Liguori
2010-12-03 18:10             ` Marcelo Tosatti
2010-12-03 18:24               ` Marcelo Tosatti
2010-12-03 17:28     ` Chris Wright
2010-12-03 17:36       ` Srivatsa Vaddagiri
2010-12-03 17:38         ` Chris Wright
2010-12-03 17:43           ` Srivatsa Vaddagiri
2010-12-03 17:47           ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox