From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6HxJ-0000Ei-EY for qemu-devel@nongnu.org; Mon, 14 Nov 2016 09:09:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6HxG-00012T-Pb for qemu-devel@nongnu.org; Mon, 14 Nov 2016 09:09:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6HxG-000123-KC for qemu-devel@nongnu.org; Mon, 14 Nov 2016 09:09:50 -0500 From: Juan Quintela In-Reply-To: <20161114123700.158592605@redhat.com> (Marcelo Tosatti's message of "Mon, 14 Nov 2016 10:36:30 -0200") References: <20161114123628.703911091@redhat.com> <20161114123700.158592605@redhat.com> Reply-To: quintela@redhat.com Date: Mon, 14 Nov 2016 15:09:46 +0100 Message-ID: <874m3af905.fsf@emacs.mitica> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [qemu patch 2/2] kvmclock: reduce kvmclock difference on migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Paolo Bonzini , Radim Krcmar , Eduardo Habkost 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 difference on migration from 5s to 0.1s > (when max_downtime == 5s). > > Signed-off-by: Marcelo Tosatti Acked-by: Juan Quintela But, if you have to respin it .... > + /* whether machine supports reliable KVM_GET_CLOCK */ > + bool mach_use_reliable_get_clock; > + > + /* whether source host supported reliable KVM_GET_CLOCK */ > + bool src_use_reliable_get_clock; This two names are really long, but I don't have better suggesitons :-() > if (running) { > struct kvm_clock_data data = {}; > - uint64_t time_at_migration = kvmclock_current_nsec(s); > + uint64_t time_at_migration = 0; This was not "time_at_migration", it was not already before, but just now it looks really weird. (as it was already faulty, this is why it is only a suggestion.) > > - s->clock_valid = false; > + /* local (running VM) restore */ > + if (s->clock_valid) { > + /* > + * if host does not support reliable KVM_GET_CLOCK, > + * read kvmclock value from memory > + */ > + if (!kvm_has_adjust_clock_stable()) { > + time_at_migration = kvmclock_current_nsec(s); > + } > + /* migration/savevm/init restore */ > + } else { > + /* > + * use s->clock in case machine uses reliable > + * get clock and host where vm was executing > + * supported reliable get clock > + */ This comment is just weird. Simplifying /* If A and B do C */ if (!A and || !B) { then D(); } Doing the opposite comment? Migration code looks rigth. Once said that, I continue hating clocks. Later, Juan.