aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-02-12 03:54:46 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-12 12:48:41 -0500
commit8d0be2b3bf4a55606967d7d84e56c52521e94333 (patch)
tree25708d831300f807a29ed90fae7a6e692ff392be
parent133de9021d2988f3fbdad84c2d26484c7a757526 (diff)
[PATCH] KVM: VMX: add vcpu_clear()
Like the inline code it replaces, this function decaches the vmcs from the cpu it last executed on. in addition: - vcpu_clear() works if the last cpu is also the cpu we're running on - it is faster on larger smps by virtue of using smp_call_function_single() Includes fix from Ingo Molnar. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Avi Kivity <avi@qumranet.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/kvm/vmx.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 407862825c1f..28da0cae64a7 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -125,6 +125,15 @@ static void __vcpu_clear(void *arg)
125 per_cpu(current_vmcs, cpu) = NULL; 125 per_cpu(current_vmcs, cpu) = NULL;
126} 126}
127 127
128static void vcpu_clear(struct kvm_vcpu *vcpu)
129{
130 if (vcpu->cpu != raw_smp_processor_id() && vcpu->cpu != -1)
131 smp_call_function_single(vcpu->cpu, __vcpu_clear, vcpu, 0, 1);
132 else
133 __vcpu_clear(vcpu);
134 vcpu->launched = 0;
135}
136
128static unsigned long vmcs_readl(unsigned long field) 137static unsigned long vmcs_readl(unsigned long field)
129{ 138{
130 unsigned long value; 139 unsigned long value;
@@ -202,10 +211,8 @@ static struct kvm_vcpu *vmx_vcpu_load(struct kvm_vcpu *vcpu)
202 211
203 cpu = get_cpu(); 212 cpu = get_cpu();
204 213
205 if (vcpu->cpu != cpu) { 214 if (vcpu->cpu != cpu)
206 smp_call_function(__vcpu_clear, vcpu, 0, 1); 215 vcpu_clear(vcpu);
207 vcpu->launched = 0;
208 }
209 216
210 if (per_cpu(current_vmcs, cpu) != vcpu->vmcs) { 217 if (per_cpu(current_vmcs, cpu) != vcpu->vmcs) {
211 u8 error; 218 u8 error;