aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 30b36368fcdf..904d7b7bd780 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -105,10 +105,11 @@ static void ack_flush(void *_completed)
105 105
106void kvm_flush_remote_tlbs(struct kvm *kvm) 106void kvm_flush_remote_tlbs(struct kvm *kvm)
107{ 107{
108 int i, cpu; 108 int i, cpu, me;
109 cpumask_t cpus; 109 cpumask_t cpus;
110 struct kvm_vcpu *vcpu; 110 struct kvm_vcpu *vcpu;
111 111
112 me = get_cpu();
112 cpus_clear(cpus); 113 cpus_clear(cpus);
113 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 114 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
114 vcpu = kvm->vcpus[i]; 115 vcpu = kvm->vcpus[i];
@@ -117,21 +118,24 @@ void kvm_flush_remote_tlbs(struct kvm *kvm)
117 if (test_and_set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests)) 118 if (test_and_set_bit(KVM_REQ_TLB_FLUSH, &vcpu->requests))
118 continue; 119 continue;
119 cpu = vcpu->cpu; 120 cpu = vcpu->cpu;
120 if (cpu != -1 && cpu != raw_smp_processor_id()) 121 if (cpu != -1 && cpu != me)
121 cpu_set(cpu, cpus); 122 cpu_set(cpu, cpus);
122 } 123 }
123 if (cpus_empty(cpus)) 124 if (cpus_empty(cpus))
124 return; 125 goto out;
125 ++kvm->stat.remote_tlb_flush; 126 ++kvm->stat.remote_tlb_flush;
126 smp_call_function_mask(cpus, ack_flush, NULL, 1); 127 smp_call_function_mask(cpus, ack_flush, NULL, 1);
128out:
129 put_cpu();
127} 130}
128 131
129void kvm_reload_remote_mmus(struct kvm *kvm) 132void kvm_reload_remote_mmus(struct kvm *kvm)
130{ 133{
131 int i, cpu; 134 int i, cpu, me;
132 cpumask_t cpus; 135 cpumask_t cpus;
133 struct kvm_vcpu *vcpu; 136 struct kvm_vcpu *vcpu;
134 137
138 me = get_cpu();
135 cpus_clear(cpus); 139 cpus_clear(cpus);
136 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 140 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
137 vcpu = kvm->vcpus[i]; 141 vcpu = kvm->vcpus[i];
@@ -140,12 +144,14 @@ void kvm_reload_remote_mmus(struct kvm *kvm)
140 if (test_and_set_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests)) 144 if (test_and_set_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests))
141 continue; 145 continue;
142 cpu = vcpu->cpu; 146 cpu = vcpu->cpu;
143 if (cpu != -1 && cpu != raw_smp_processor_id()) 147 if (cpu != -1 && cpu != me)
144 cpu_set(cpu, cpus); 148 cpu_set(cpu, cpus);
145 } 149 }
146 if (cpus_empty(cpus)) 150 if (cpus_empty(cpus))
147 return; 151 goto out;
148 smp_call_function_mask(cpus, ack_flush, NULL, 1); 152 smp_call_function_mask(cpus, ack_flush, NULL, 1);
153out:
154 put_cpu();
149} 155}
150 156
151 157