瀏覽代碼

KVM: Replace kvmclock open-coded get_cpu_var() with the real thing

Suggested by Ingo Molnar.

Signed-off-by: Avi Kivity <avi@redhat.com>
Avi Kivity 16 年之前
父節點
當前提交
463656c000
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      arch/x86/kvm/x86.c

+ 6 - 5
arch/x86/kvm/x86.c

@@ -631,16 +631,17 @@ static void kvm_write_guest_time(struct kvm_vcpu *v)
 	unsigned long flags;
 	unsigned long flags;
 	struct kvm_vcpu_arch *vcpu = &v->arch;
 	struct kvm_vcpu_arch *vcpu = &v->arch;
 	void *shared_kaddr;
 	void *shared_kaddr;
+	unsigned long this_tsc_khz;
 
 
 	if ((!vcpu->time_page))
 	if ((!vcpu->time_page))
 		return;
 		return;
 
 
-	preempt_disable();
-	if (unlikely(vcpu->hv_clock_tsc_khz != __get_cpu_var(cpu_tsc_khz))) {
-		kvm_set_time_scale(__get_cpu_var(cpu_tsc_khz), &vcpu->hv_clock);
-		vcpu->hv_clock_tsc_khz = __get_cpu_var(cpu_tsc_khz);
+	this_tsc_khz = get_cpu_var(cpu_tsc_khz);
+	if (unlikely(vcpu->hv_clock_tsc_khz != this_tsc_khz)) {
+		kvm_set_time_scale(this_tsc_khz, &vcpu->hv_clock);
+		vcpu->hv_clock_tsc_khz = this_tsc_khz;
 	}
 	}
-	preempt_enable();
+	put_cpu_var(cpu_tsc_khz);
 
 
 	/* Keep irq disabled to prevent changes to the clock */
 	/* Keep irq disabled to prevent changes to the clock */
 	local_irq_save(flags);
 	local_irq_save(flags);