From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: KVM: x86: update masterclock on TSC writes Date: Tue, 04 Nov 2014 18:10:34 +0100 Message-ID: <5459088A.50801@redhat.com> References: <20141103211627.GA19724@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Cc: kvm-devel To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:39126 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbaKDRKj (ORCPT ); Tue, 4 Nov 2014 12:10:39 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sA4HAcjQ004288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 4 Nov 2014 12:10:38 -0500 In-Reply-To: <20141103211627.GA19724@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: Extending the context we have: > if (vcpus_matched && gtod->clock.vclock_mode == VCLOCK_TSC) > if (!ka->use_master_clock) > do_request = 1; > > - if (!vcpus_matched && ka->use_master_clock) > + if (ka->use_master_clock) > do_request = 1; > > if (do_request) > kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); The patch also makes the previous "if (!ka->use_master_clock)" redundant. If you enter the first "if", do_request will be 1 independent of ka->use_master_clock. So you should also drop that one, and possibly rewrite it simply like this: if ((vcpus_matched && gtod->clock.vclock_mode == VCLOCK_TSC) || ka->use_master_clock) kvm_make_request(KVM_REQ_MASTERCLOCK_UPDATE, vcpu); But this brings the question: what is vclock_mode in your case? If it is VCLOCK_TSC, are you sure that the bug is fixed because you modified the second "if", or could it be fixed also by removing instead the "if (!ka->use_master_clock)"? This would leave the optimization in the case "!vcpus_matched && ka->use_master_clock". Or is the optimization always invalid? A different way to state the same question: can you explain the resulting condition ((vcpus_matched && gtod->clock.vclock_mode == VCLOCK_TSC) || ka->use_master_clock) ? Please add a comment to kvm_track_tsc_matching that clarifies this logic. Paolo