Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1521818

Re: [PATCH] KVM: x86: do not go through vcpu in __get_kvmclock_ns

From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] KVM: x86: do not go through vcpu in __get_kvmclock_ns
Date 2016-11-14 17:20 +0100
Message-ID <sDs9c-RG-31@gated-at.bofh.it> (permalink)
References <sCh69-32E-13@gated-at.bofh.it> <sDqTL-8jU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 14/11/2016 15:52, Radim Krčmář wrote:
> The hunk below should return the same value in pvclock_ns and kernel_ns
> if they can be used interchangeably.  boot_ns is expected to be a bit
> delayed, because it is read late.  boot_ns shows a bounded offset from
> kernel_ns, unlike the drifting pvclock_ns.
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 83990ad3710e..30d4d3d02ac7 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -6653,6 +6653,17 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
>  		goto cancel_injection;
>  	}
>  
> +	if (vcpu->kvm->arch.use_master_clock) {
> +		s64 kernel_ns;
> +		cycle_t tsc_now, pvclock_ns, boot_ns;
> +
> +		kvm_get_time_and_clockread(&kernel_ns, &tsc_now);
> +		pvclock_ns = __pvclock_read_cycles(&vcpu->arch.hv_clock, kvm_read_l1_tsc(vcpu, tsc_now)) - vcpu->kvm->arch.kvmclock_offset;
> +		boot_ns = ktime_get_boot_ns();
> +
> +		printk("ns diff: %lld %lld\n", pvclock_ns - kernel_ns, boot_ns - kernel_ns);
> +	}
> +
>  	preempt_disable();
>  
>  	kvm_x86_ops->prepare_guest_switch(vcpu);

Ok, I'll post a v2 of this patch.

Paolo

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] KVM: x86: do not go through vcpu in __get_kvmclock_ns Radim Krčmář <rkrcmar@redhat.com> - 2016-11-14 16:00 +0100
  Re: [PATCH] KVM: x86: do not go through vcpu in __get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-11-14 17:20 +0100
  Re: [PATCH] KVM: x86: do not go through vcpu in __get_kvmclock_ns Marcelo Tosatti <mtosatti@redhat.com> - 2016-11-14 18:20 +0100

csiph-web