Re: [PATCH 2/2] kvm: kvmclock: eliminate kvmclock offset when time page count goes to zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 20, 2012 at 10:50:11AM -0600, Bruce Rogers wrote:
> When a guest is migrated, a time offset is generated in order to
> maintain the correct kvmclock based time for the guest. Detect when
> all kvmclock time pages are deleted so that the kvmclock offset can
> be safely reset to zero.
> 
> Cc: Glauber Costa <glommer@xxxxxxxxxx>
> Cc: Zachary Amsden <zamsden@xxxxxxxxx>
> Signed-off-by: Bruce Rogers <brogers@xxxxxxxx>
> ---
>  arch/x86/include/asm/kvm_host.h |    1 +
>  arch/x86/kvm/x86.c              |    5 ++++-
>  2 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index db7c1f2..112415c 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -524,6 +524,7 @@ struct kvm_arch {
>  
>  	unsigned long irq_sources_bitmap;
>  	s64 kvmclock_offset;
> +	unsigned int n_time_pages;
>  	raw_spinlock_t tsc_write_lock;
>  	u64 last_tsc_nsec;
>  	u64 last_tsc_write;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 14c290d..350c51b 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1511,6 +1511,8 @@ static void kvmclock_reset(struct kvm_vcpu *vcpu)
>  	if (vcpu->arch.time_page) {
>  		kvm_release_page_dirty(vcpu->arch.time_page);
>  		vcpu->arch.time_page = NULL;
> +		if (--vcpu->kvm->arch.n_time_pages == 0)
> +			vcpu->kvm->arch.kvmclock_offset = 0;
>  	}
>  }
>  
> @@ -1624,7 +1626,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
>  		if (is_error_page(vcpu->arch.time_page)) {
>  			kvm_release_page_clean(vcpu->arch.time_page);
>  			vcpu->arch.time_page = NULL;
> -		}
> +		} else
> +			vcpu->kvm->arch.n_time_pages++;
>  		break;
>  	}
>  	case MSR_KVM_ASYNC_PF_EN:

Userspace is responsible for configuring a correct kvmclock_offset
AFAICS?

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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux