Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-28 Thread Paolo Bonzini
On 28/11/2016 17:36, Marcelo Tosatti wrote: > If the source masterclock is disabled, then the guest does > not enable the optimization to not use a global variable > to guarantee monotonicity. Therefore there will be no > time backwards events (the timer backwards events crashed > guests, and

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-28 Thread Marcelo Tosatti
On Mon, Nov 28, 2016 at 02:47:18PM +0100, Paolo Bonzini wrote: > > > On 17/11/2016 13:16, Marcelo Tosatti wrote: > > What QEMU wants is to use KVM_GET_CLOCK at pre_save independently > > of whether masterclock is enabled or not... it just depends > > on KVM_GET_CLOCK being correct for the masterc

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-28 Thread Paolo Bonzini
On 28/11/2016 15:28, Eduardo Habkost wrote: > > +s->src_use_reliable_get_clock = data.flags & KVM_CLOCK_TSC_STABLE; > > I still don't understand the reasoning behind > kvm_has_adjust_clock_stable() vs (flags & KVM_CLOCK_TSC_STABLE), > but on either case, updating src_use_reliable_get_clock i

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-28 Thread Eduardo Habkost
On Mon, Nov 28, 2016 at 02:47:18PM +0100, Paolo Bonzini wrote: > > > On 17/11/2016 13:16, Marcelo Tosatti wrote: > > What QEMU wants is to use KVM_GET_CLOCK at pre_save independently > > of whether masterclock is enabled or not... it just depends > > on KVM_GET_CLOCK being correct for the masterc

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-28 Thread Paolo Bonzini
On 17/11/2016 13:16, Marcelo Tosatti wrote: > What QEMU wants is to use KVM_GET_CLOCK at pre_save independently > of whether masterclock is enabled or not... it just depends > on KVM_GET_CLOCK being correct for the masterclock case > (108b249c453dd7132599ab6dc7e435a7036c193f). > > So a "reliable

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-17 Thread Paolo Bonzini
On 17/11/2016 13:16, Marcelo Tosatti wrote: > On Mon, Nov 14, 2016 at 04:15:18PM -0200, Marcelo Tosatti wrote: >> On Mon, Nov 14, 2016 at 06:20:29PM +0100, Paolo Bonzini wrote: >>> >>> >>> On 14/11/2016 18:13, Marcelo Tosatti wrote: On Mon, Nov 14, 2016 at 05:43:33PM +0100, Paolo Bonzini wro

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-17 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 04:15:18PM -0200, Marcelo Tosatti wrote: > On Mon, Nov 14, 2016 at 06:20:29PM +0100, Paolo Bonzini wrote: > > > > > > On 14/11/2016 18:13, Marcelo Tosatti wrote: > > > On Mon, Nov 14, 2016 at 05:43:33PM +0100, Paolo Bonzini wrote: > > >> > > >> > > >> On 14/11/2016 16:40,

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 06:20:29PM +0100, Paolo Bonzini wrote: > > > On 14/11/2016 18:13, Marcelo Tosatti wrote: > > On Mon, Nov 14, 2016 at 05:43:33PM +0100, Paolo Bonzini wrote: > >> > >> > >> On 14/11/2016 16:40, Marcelo Tosatti wrote: > >>> static bool kvmclock_src_use_reliable_get_clock(void

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Paolo Bonzini
On 14/11/2016 18:13, Marcelo Tosatti wrote: > On Mon, Nov 14, 2016 at 05:43:33PM +0100, Paolo Bonzini wrote: >> >> >> On 14/11/2016 16:40, Marcelo Tosatti wrote: >>> static bool kvmclock_src_use_reliable_get_clock(void *opaque) >>> { >>> KVMClockState *s = opaque; >>> >>> /* >>> * On

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 05:43:33PM +0100, Paolo Bonzini wrote: > > > On 14/11/2016 16:40, Marcelo Tosatti wrote: > > static bool kvmclock_src_use_reliable_get_clock(void *opaque) > > { > > KVMClockState *s = opaque; > > > > /* > > * On machine types that support reliable KVM_GET_CLO

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Paolo Bonzini
On 14/11/2016 16:40, Marcelo Tosatti wrote: > static bool kvmclock_src_use_reliable_get_clock(void *opaque) > { > KVMClockState *s = opaque; > > /* > * On machine types that support reliable KVM_GET_CLOCK, > * if host kernel does provide reliable KVM_GET_CLOCK, > * set src

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 03:09:46PM +0100, Juan Quintela wrote: > Marcelo Tosatti wrote: > > Check for KVM_CAP_ADJUST_CLOCK capability KVM_CLOCK_TSC_STABLE, which > > indicates that KVM_GET_CLOCK returns a value as seen by the guest at > > that moment. > > > > For new machine types, use this value

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 04:00:38PM +0100, Paolo Bonzini wrote: > > > On 14/11/2016 15:50, Marcelo Tosatti wrote: > > Well, i didnt want to mix the meaning of the variables: > > > > +/* whether machine supports reliable KVM_GET_CLOCK */ > > +bool mach_use_reliable_get_clock; > > + > > +

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Paolo Bonzini
On 14/11/2016 15:50, Marcelo Tosatti wrote: > Well, i didnt want to mix the meaning of the variables: > > +/* whether machine supports reliable KVM_GET_CLOCK */ > +bool mach_use_reliable_get_clock; > + > +/* whether source host supported reliable KVM_GET_CLOCK */ > +bool src_use_

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 03:22:02PM +0100, Paolo Bonzini wrote: > > > On 14/11/2016 15:00, Marcelo Tosatti wrote: > > On Mon, Nov 14, 2016 at 02:54:38PM +0100, Paolo Bonzini wrote: > >> > >> > >> On 14/11/2016 13:36, Marcelo Tosatti wrote: > >>> +/* local (running VM) restore */ > >>> +

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Paolo Bonzini
On 14/11/2016 15:00, Marcelo Tosatti wrote: > On Mon, Nov 14, 2016 at 02:54:38PM +0100, Paolo Bonzini wrote: >> >> >> On 14/11/2016 13:36, Marcelo Tosatti wrote: >>> +/* local (running VM) restore */ >>> +if (s->clock_valid) { >>> +/* >>> + * if host does n

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Juan Quintela
Paolo Bonzini wrote: > On 14/11/2016 13:36, Marcelo Tosatti wrote: >> +/* local (running VM) restore */ >> +if (s->clock_valid) { >> +/* >> + * if host does not support reliable KVM_GET_CLOCK, >> + * read kvmclock value from memory >> +

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Juan Quintela
Marcelo Tosatti wrote: > Check for KVM_CAP_ADJUST_CLOCK capability KVM_CLOCK_TSC_STABLE, which > indicates that KVM_GET_CLOCK returns a value as seen by the guest at > that moment. > > For new machine types, use this value rather than reading > from guest memory. > > This reduces kvmclock differe

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
On Mon, Nov 14, 2016 at 02:54:38PM +0100, Paolo Bonzini wrote: > > > On 14/11/2016 13:36, Marcelo Tosatti wrote: > > +/* local (running VM) restore */ > > +if (s->clock_valid) { > > +/* > > + * if host does not support reliable KVM_GET_CLOCK, > > +

Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Paolo Bonzini
On 14/11/2016 13:36, Marcelo Tosatti wrote: > +/* local (running VM) restore */ > +if (s->clock_valid) { > +/* > + * if host does not support reliable KVM_GET_CLOCK, > + * read kvmclock value from memory > + */ > +if (!kv

[Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-14 Thread Marcelo Tosatti
Check for KVM_CAP_ADJUST_CLOCK capability KVM_CLOCK_TSC_STABLE, which indicates that KVM_GET_CLOCK returns a value as seen by the guest at that moment. For new machine types, use this value rather than reading from guest memory. This reduces kvmclock difference on migration from 5s to 0.1s (when