diff mbox

[18/18] KVM: x86: update pvclock area conditionally, on cpu migration

Message ID 20121119215959.499058001@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti Nov. 19, 2012, 9:58 p.m. UTC
As requested by Glauber, do not update kvmclock area on vcpu->pcpu 
migration, in case the host has stable TSC. 

This is to reduce cacheline bouncing.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Glauber Costa Nov. 20, 2012, 9:01 a.m. UTC | #1
On 11/20/2012 01:58 AM, Marcelo Tosatti wrote:
> As requested by Glauber, do not update kvmclock area on vcpu->pcpu 
> migration, in case the host has stable TSC. 
> 
> This is to reduce cacheline bouncing.
> 
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> 
> Index: vsyscall/arch/x86/kvm/x86.c
> ===================================================================
> --- vsyscall.orig/arch/x86/kvm/x86.c
> +++ vsyscall/arch/x86/kvm/x86.c
> @@ -2615,7 +2615,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu 
>  			kvm_x86_ops->write_tsc_offset(vcpu, offset);
>  			vcpu->arch.tsc_catchup = 1;
>  		}
> -		kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
> +		/*
> + 		 * On a host with synchronized TSC, there is no need to update
> + 		 * kvmclock on vcpu->cpu migration
> + 		 */
> +		if (!vcpu->kvm->arch.use_master_clock || vcpu->cpu == -1)
> +			kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
>  		if (vcpu->cpu != cpu)
>  			kvm_migrate_timers(vcpu);
>  		vcpu->cpu = cpu;

Ok. Since you are only touching the one in kvm_arch_vcpu_load() and
leaving the others untouched, it looks correct.

Acked-by: Glauber Costa <glommer@parallels.com>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: vsyscall/arch/x86/kvm/x86.c
===================================================================
--- vsyscall.orig/arch/x86/kvm/x86.c
+++ vsyscall/arch/x86/kvm/x86.c
@@ -2615,7 +2615,12 @@  void kvm_arch_vcpu_load(struct kvm_vcpu 
 			kvm_x86_ops->write_tsc_offset(vcpu, offset);
 			vcpu->arch.tsc_catchup = 1;
 		}
-		kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
+		/*
+ 		 * On a host with synchronized TSC, there is no need to update
+ 		 * kvmclock on vcpu->cpu migration
+ 		 */
+		if (!vcpu->kvm->arch.use_master_clock || vcpu->cpu == -1)
+			kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
 		if (vcpu->cpu != cpu)
 			kvm_migrate_timers(vcpu);
 		vcpu->cpu = cpu;