From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v4 1/3] x86: Use native RDTSC(P) execution when guest and host frequencies are the same Date: Wed, 16 Apr 2014 11:33:16 -0400 Message-ID: <534EA2BC.4050000@oracle.com> References: <1397611668-15338-1-git-send-email-boris.ostrovsky@oracle.com> <1397611668-15338-2-git-send-email-boris.ostrovsky@oracle.com> <534E87DE0200007800009787@nat28.tlf.novell.com> <534E9393.6080402@oracle.com> <534EB1D502000078000099A9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <534EB1D502000078000099A9@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: kevin.tian@intel.com, eddie.dong@intel.com, jun.nakajima@intel.com, suravee.suthikulpanit@amd.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 04/16/2014 10:37 AM, Jan Beulich wrote: >>>> On 16.04.14 at 16:28, wrote: >> On 04/16/2014 07:38 AM, Jan Beulich wrote: >>>>>> On 16.04.14 at 03:27, wrote: >>>> @@ -1889,10 +1890,14 @@ void tsc_set_info(struct domain *d, >>>> d->arch.vtsc_offset = get_s_time() - elapsed_nsec; >>>> d->arch.tsc_khz = gtsc_khz ? gtsc_khz : cpu_khz; >>>> set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000 ); >>>> - /* use native TSC if initial host has safe TSC, has not migrated >>>> - * yet and tsc_khz == cpu_khz */ >>>> - if ( host_tsc_is_safe() && incarnation == 0 && >>>> - d->arch.tsc_khz == cpu_khz ) >>>> + /* >>>> + * Use native TSC if initial host has safe TSC and either has not >>>> + * migrated yet or tsc_khz == cpu_khz (either "naturally" or via >>>> + * TSC scaling) >>>> + */ >>>> + if ( host_tsc_is_safe() && >>>> + (incarnation == 0 || d->arch.tsc_khz == cpu_khz || >>>> + cpu_has_tsc_ratio) ) >>> Doesn't this cpu_has_tsc_ratio check also need to be qualified with >>> is_pv_domain()? And is the change from && in the old condition to || >>> actually valid for PV guests? >> Hmm, I haven't thought about PV here. >> >> So then the condition should be >> >> if ( host_tsc_is_safe() ) >> { >> if ( (is_hvm_domain() && (arch.tsc_khz == cpu_khz || cpu_has_tsc_ratio)) || >> (incarnation == 0 && d->arch.tsc_khz == cpu_khz) ) >> d->arch.vtsc = 0; >> } > Almost - to include PVH you need to either use !is_pv_domain() or > has_hvm_container_domain(). PVH never makes here, it is forced to use TSC_MODE_NEVER_EMULATE above (see pvhfixme above). PVH need to be looked at anyway. For example, there is a is_hvm_domain() check at the bottom which I suspect needs to be PVH-safe. I think it should be addressed separately though. -boris