From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v3 2/6] KVM: x86: switch to masterclock update using timekeeper functionality Date: Tue, 1 Aug 2017 14:41:05 +0200 Message-ID: <399f7166-0f18-a1b8-b236-66baccf410b9@redhat.com> References: <1501331711-12961-1-git-send-email-dplotnikov@virtuozzo.com> <1501331711-12961-3-git-send-email-dplotnikov@virtuozzo.com> <80e6cc1b-bccb-6e5b-1d3a-28a54e564d6c@virtuozzo.com> <82c81e37-9c56-26b9-d8c5-cf87eeb1d470@redhat.com> <616b4427-49a9-7815-56c3-9171248d9673@virtuozzo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: rkagan@virtuozzo.com, den@virtuozzo.com, svt-core@lists.sw.ru To: Denis Plotnikov , rkrcmar@redhat.com, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55554 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751865AbdHAMlI (ORCPT ); Tue, 1 Aug 2017 08:41:08 -0400 In-Reply-To: <616b4427-49a9-7815-56c3-9171248d9673@virtuozzo.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 01/08/2017 14:11, Denis Plotnikov wrote: > In fact, this "cycles_valid" is going to be used for deciding whether to > use KVM masterclock or not. And if it's not we still want to know > cycles_stamp value to use it in KVM. Why? Neither pvclock_update_vm_gtod_copy nor kvm_pv_clock_pairing do anything with the two variables that are passed by reference, if the read returns false. Hence my suggestion of calling it cycles_valid. > So the cycles is valid, but clocksource is not reliable (why? let decide > to a clocksource, by default assume they are all not stable), thus we > must calculate time values for a guest each time its needed. > So, my proposal is to name the variable sightly differently: cs_reliable > and go like: > if (clock->read_clock_with_stamp) { > systime_snapshot->cs_reliable = > clock->read_clock_with_stamp( > &now, &systime_snapshot->cycles); > } else { > now = tk_clock_read(&tk->tkr_mono); > systime_snapshot->cs_reliable = false; > systime_snapshot->cycles = now; > } > What do you think? I'm afraid you still have to define the meaning of "reliable". (Though I agree that the right default is false, that was a thinko on my side. This also means that you need to define read_clock_with_stamp for the TSC clocksource too). Paolo