All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: Haozhong Zhang <haozhong.zhang@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>, Keir Fraser <keir@xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	xen-devel@lists.xen.org,
	Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>,
	Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH v2 06/14] x86/time.c: Scale host TSC in pvclock properly
Date: Tue, 29 Dec 2015 18:22:44 +0000	[thread overview]
Message-ID: <5682CF74.1070901@oracle.com> (raw)
In-Reply-To: <5669685A.9080808@oracle.com>



On 12/10/2015 11:56 AM, Joao Martins wrote:
> 
> 
> On 12/10/2015 12:23 AM, Haozhong Zhang wrote:
>> On 12/08/15 14:21, Boris Ostrovsky wrote:
>>> On 12/07/2015 08:52 PM, Haozhong Zhang wrote:
>>>> On 12/07/15 13:14, Boris Ostrovsky wrote:
>>>>> On 12/06/2015 03:58 PM, Haozhong Zhang wrote:
>>>>>> This patch makes the pvclock return the scaled host TSC and
>>>>>> corresponding scaling parameters to HVM domains if guest TSC is not
>>>>>> emulated and TSC scaling is enabled.
>>>>>>
>>>>>> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
>>>>> +Joao who has been staring at this code.
>>>>>
> Apologies for late response but I was out in the beginning of the week and was
> still catching up.
> 
>>>>> Joao, can you run this series through your test with non-native frequency?
>>>>> (http://lists.xenproject.org/archives/html/xen-devel/2015-12/msg00683.html
>>>>> provides an interface to set it in config file).
>>>>>
> OK, I will run it through my time warp tests.
I have using these for a while now and so far I got no issues with a non-native
frequency [I don't have a Skylake processor in my possession to test it
natively]. In addition I rebased my vdso tests on top of your series and no
warps too. But will raise out any flags if I found anything wrong.

> 
>>>>>
>>>>>> ---
>>>>>>  xen/arch/x86/time.c | 16 ++++++++++++----
>>>>>>  1 file changed, 12 insertions(+), 4 deletions(-)
>>>>>>
>>>>>> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
>>>>>> index 95df4f1..732d1e9 100644
>>>>>> --- a/xen/arch/x86/time.c
>>>>>> +++ b/xen/arch/x86/time.c
>>>>>> @@ -815,10 +815,18 @@ static void __update_vcpu_system_time(struct vcpu *v, int force)
>>>>>>      }
>>>>>>      else
>>>>>>      {
>>>>>> -        tsc_stamp = t->local_tsc_stamp;
>>>>>> -
>>>>>> -        _u.tsc_to_system_mul = t->tsc_scale.mul_frac;
>>>>>> -        _u.tsc_shift         = (s8)t->tsc_scale.shift;
>>>>>> +        if ( is_hvm_domain(d) && cpu_has_tsc_ratio )
>>>>>> +        {
>>>>>> +            tsc_stamp            = hvm_funcs.scale_tsc(v, t->local_tsc_stamp);
>>>>>> +            _u.tsc_to_system_mul = d->arch.vtsc_to_ns.mul_frac;
>>>>>> +            _u.tsc_shift         = d->arch.vtsc_to_ns.shift;
>>>>> I am not sure this is correct (which is why I asked Joao to look at this and
>>>>> test). The scaler below is calculated as result of TSC calibration across
>>>>> physical CPUs and what you use above (vtsc_to_ns) is an uncalibrated value.
>>>>>
>>>> Because guest TSC is synchronized among all vcpus of a domain, I think
>>>> it's safe to use d->arch.vtsc_to_ns here.
>>>
>>> This is only guaranteed if we have constant/reliable TSC. So perhaps you
>>> should set tsc_scaling_supported only when either (or both?) of these TSC
>>> properties are true. Which is probably the case anyway but may be worth
>>> explicitly checking in start_svm/vmx?
>>
>> Yes, I'll add the additional check in the next version.
>>
> I believe constant TSC to be the only feature that is checked on
> local_time_calibration.
> 
>>> (and use tsc_scaling_supported instead
>>> of cpu_has_tsc_ratio in the 'if' statement)
>>
>> This one is only for bug fix, so tsc_scaling_supported has not been
>> introduced. Patch 8 introduces tsc_scaling_supported and patch 12
>> replaces all cpu_has_tsc_ratio with it.
>>
>>>
>>> And just like I asked in the previous email --- should we then use the same
>>> scaler (which would be vtsc_to_ns) in both cases? At least for guests in HVM
>>> containers (it may work for PV guests as well, but it would need to be
>>> confirmed).
>>>
>> Yes, but I'll check PV code first.
>>
>>> Also, I noticed that this routine uses is_hvm_domain(). I think it should be
>>> has_hvm_container_domain().
>>>
>> forgot updating here, will do in the next version.
>>
>> Haozhong
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>>

  reply	other threads:[~2015-12-29 18:22 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-06 20:58 [PATCH v2 00/14] Add VMX TSC scaling support Haozhong Zhang
2015-12-06 20:58 ` [PATCH v2 01/14] svm: Fix incorrect TSC scaling Haozhong Zhang
2015-12-07 16:49   ` Boris Ostrovsky
2015-12-06 20:58 ` [PATCH v2 02/14] x86/time.c: Fix domain type check in tsc_set_info() Haozhong Zhang
2015-12-07 16:49   ` Boris Ostrovsky
2015-12-06 20:58 ` [PATCH v2 03/14] x86/time.c: Use correct guest TSC frequency " Haozhong Zhang
2015-12-07 16:57   ` Boris Ostrovsky
2015-12-08  0:30     ` Haozhong Zhang
2015-12-06 20:58 ` [PATCH v2 04/14] x86/time.c: Use correct guest TSC frequency in tsc_get_info() Haozhong Zhang
2015-12-07 17:53   ` Boris Ostrovsky
2015-12-08  1:08     ` Haozhong Zhang
2015-12-08 18:26       ` Boris Ostrovsky
2015-12-10  0:14         ` Haozhong Zhang
2015-12-06 20:58 ` [PATCH v2 05/14] x86/hvm: Scale host TSC when setting/getting guest TSC Haozhong Zhang
2015-12-07 17:54   ` Boris Ostrovsky
2015-12-06 20:58 ` [PATCH v2 06/14] x86/time.c: Scale host TSC in pvclock properly Haozhong Zhang
2015-12-07 18:14   ` Boris Ostrovsky
2015-12-08  1:52     ` Haozhong Zhang
2015-12-08 19:21       ` Boris Ostrovsky
2015-12-10  0:23         ` Haozhong Zhang
2015-12-10 11:56           ` Joao Martins
2015-12-29 18:22             ` Joao Martins [this message]
2015-12-30  1:07               ` Haozhong Zhang
2015-12-06 20:58 ` [PATCH v2 07/14] svm: Remove redundant TSC scaling in svm_set_tsc_offset() Haozhong Zhang
2015-12-07 18:25   ` Boris Ostrovsky
2015-12-08  1:54     ` Haozhong Zhang
2015-12-06 20:58 ` [PATCH v2 08/14] x86/hvm: Collect information of TSC scaling ratio Haozhong Zhang
2015-12-07 18:31   ` Boris Ostrovsky
2015-12-10 10:19   ` Tian, Kevin
2015-12-10 10:27     ` Zhang, Haozhong
2015-12-06 20:58 ` [PATCH v2 09/14] x86/hvm: Setup " Haozhong Zhang
2015-12-07 18:42   ` Boris Ostrovsky
2015-12-08  1:58     ` Haozhong Zhang
2015-12-10 10:27   ` Tian, Kevin
2015-12-10 10:37     ` Zhang, Haozhong
2015-12-06 20:58 ` [PATCH v2 10/14] x86/hvm: Replace architecture TSC scaling by a common function Haozhong Zhang
2015-12-07 18:55   ` Boris Ostrovsky
2015-12-08  2:06     ` Haozhong Zhang
2015-12-10 10:29   ` Tian, Kevin
2015-12-06 20:58 ` [PATCH v2 11/14] x86/hvm: Move saving/loading vcpu's TSC to common code Haozhong Zhang
2015-12-07 18:56   ` Boris Ostrovsky
2015-12-10 10:30   ` Tian, Kevin
2015-12-06 20:58 ` [PATCH v2 12/14] x86/hvm: Detect TSC scaling through hvm_funcs Haozhong Zhang
2015-12-07 18:58   ` Boris Ostrovsky
2015-12-10 10:31   ` Tian, Kevin
2015-12-06 20:58 ` [PATCH v2 13/14] vmx: Add VMX RDTSC(P) scaling support Haozhong Zhang
2015-12-10 10:33   ` Tian, Kevin
2015-12-06 20:58 ` [PATCH v2 14/14] docs: Add descriptions of TSC scaling in xl.cfg and tscmode.txt Haozhong Zhang
2015-12-10 10:40   ` Tian, Kevin
2015-12-10 10:56     ` Zhang, Haozhong
2015-12-06 21:14 ` [PATCH v2 00/14] Add VMX TSC scaling support Haozhong Zhang
2015-12-07  9:03   ` Egger, Christoph
2015-12-07 10:16     ` Haozhong Zhang
2015-12-07 17:04       ` Andrew Cooper
2015-12-08  2:13         ` Haozhong Zhang
2015-12-10 10:43         ` Tian, Kevin
2015-12-10 11:13           ` Haozhong Zhang
2015-12-11  7:35             ` Tian, Kevin
2015-12-11 10:09               ` Andrew Cooper
2015-12-07 10:37   ` Jan Beulich
2015-12-07 10:56     ` Haozhong Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5682CF74.1070901@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=Aravind.Gopalakrishnan@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=haozhong.zhang@intel.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.