linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
@ 2015-01-13  8:14 Imre Palik
  2015-01-13  9:52 ` [Xen-devel] " David Vrabel
  2015-01-20 19:21 ` David Vrabel
  0 siblings, 2 replies; 8+ messages in thread
From: Imre Palik @ 2015-01-13  8:14 UTC (permalink / raw)
  To: xen-devel, David Vrabel
  Cc: Konrad Rzeszutek Wilk, Boris Ostrovsky, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, linux-kernel, Palik, Imre,
	Anthony Liguori

From: "Palik, Imre" <imrep@amazon.de>

In Dom0's the use of the TSC clocksource (whenever it is stable enough to
be used) instead of the Xen clocksource should not cause any issues, as
Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
efficient than the Xen paravirtualised clocksource, thus it should have
higher rating.

This patch decreases the rating of the Xen clocksource in Dom0s to 275.
Which is half-way between the rating of the TSC clocksource (300) and the
hpet clocksource (250).

Cc: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Imre Palik <imrep@amazon.de>
---
 arch/x86/xen/time.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index f473d26..c768726 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -487,6 +487,10 @@ static void __init xen_time_init(void)
 	int cpu = smp_processor_id();
 	struct timespec tp;
 
+	/* As Dom0 is never moved, no penalty on using TSC there */
+	if (xen_initial_domain())
+		xen_clocksource.rating = 275;
+
 	clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
 
 	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13  8:14 [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's Imre Palik
@ 2015-01-13  9:52 ` David Vrabel
  2015-01-13 15:42   ` Boris Ostrovsky
  2015-01-20 19:21 ` David Vrabel
  1 sibling, 1 reply; 8+ messages in thread
From: David Vrabel @ 2015-01-13  9:52 UTC (permalink / raw)
  To: Imre Palik, xen-devel, David Vrabel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Boris Ostrovsky, Thomas Gleixner

On 13/01/15 08:14, Imre Palik wrote:
> From: "Palik, Imre" <imrep@amazon.de>
> 
> In Dom0's the use of the TSC clocksource (whenever it is stable enough to
> be used) instead of the Xen clocksource should not cause any issues, as
> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
> efficient than the Xen paravirtualised clocksource, thus it should have
> higher rating.
> 
> This patch decreases the rating of the Xen clocksource in Dom0s to 275.
> Which is half-way between the rating of the TSC clocksource (300) and the
> hpet clocksource (250).

I'm happy with this but would like to see acks from those who objected
to v1.

David

> --- a/arch/x86/xen/time.c
> +++ b/arch/x86/xen/time.c
> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>  	int cpu = smp_processor_id();
>  	struct timespec tp;
>  
> +	/* As Dom0 is never moved, no penalty on using TSC there */
> +	if (xen_initial_domain())
> +		xen_clocksource.rating = 275;
> +
>  	clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
>  
>  	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13  9:52 ` [Xen-devel] " David Vrabel
@ 2015-01-13 15:42   ` Boris Ostrovsky
  2015-01-13 16:07     ` David Vrabel
  0 siblings, 1 reply; 8+ messages in thread
From: Boris Ostrovsky @ 2015-01-13 15:42 UTC (permalink / raw)
  To: David Vrabel, Imre Palik, xen-devel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Thomas Gleixner

On 01/13/2015 04:52 AM, David Vrabel wrote:
> On 13/01/15 08:14, Imre Palik wrote:
>> From: "Palik, Imre" <imrep@amazon.de>
>>
>> In Dom0's the use of the TSC clocksource (whenever it is stable enough to
>> be used) instead of the Xen clocksource should not cause any issues, as
>> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
>> efficient than the Xen paravirtualised clocksource, thus it should have
>> higher rating.
>>
>> This patch decreases the rating of the Xen clocksource in Dom0s to 275.
>> Which is half-way between the rating of the TSC clocksource (300) and the
>> hpet clocksource (250).
> I'm happy with this but would like to see acks from those who objected
> to v1.
>
> David
>
>> --- a/arch/x86/xen/time.c
>> +++ b/arch/x86/xen/time.c
>> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>>   	int cpu = smp_processor_id();
>>   	struct timespec tp;
>>   
>> +	/* As Dom0 is never moved, no penalty on using TSC there */

Again, why not any PV guest with TSC_MODE_NEVER_EMULATE?

And I am not sure I understood the argument about unsynchronized TSCs. 
You mentioned you can't find a platform to test on. I think you may be 
able to unsynchronize TSCs by writing something to MSR 0x10 early during 
Xen boot and then migrate dom0's vcpu to that pcpu later (making sure 
this vcpu was not running there while dom0 was booting)

-boris

>> +	if (xen_initial_domain())
>> +		xen_clocksource.rating = 275;
>> +
>>   	clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
>>   
>>   	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13 15:42   ` Boris Ostrovsky
@ 2015-01-13 16:07     ` David Vrabel
  2015-01-13 16:17       ` Boris Ostrovsky
  0 siblings, 1 reply; 8+ messages in thread
From: David Vrabel @ 2015-01-13 16:07 UTC (permalink / raw)
  To: Boris Ostrovsky, Imre Palik, xen-devel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Thomas Gleixner

On 13/01/15 15:42, Boris Ostrovsky wrote:
> On 01/13/2015 04:52 AM, David Vrabel wrote:
>> On 13/01/15 08:14, Imre Palik wrote:
>>> From: "Palik, Imre" <imrep@amazon.de>
>>>
>>> In Dom0's the use of the TSC clocksource (whenever it is stable
>>> enough to
>>> be used) instead of the Xen clocksource should not cause any issues, as
>>> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
>>> efficient than the Xen paravirtualised clocksource, thus it should have
>>> higher rating.
>>>
>>> This patch decreases the rating of the Xen clocksource in Dom0s to 275.
>>> Which is half-way between the rating of the TSC clocksource (300) and
>>> the
>>> hpet clocksource (250).
>> I'm happy with this but would like to see acks from those who objected
>> to v1.
>>
>> David
>>
>>> --- a/arch/x86/xen/time.c
>>> +++ b/arch/x86/xen/time.c
>>> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>>>       int cpu = smp_processor_id();
>>>       struct timespec tp;
>>>   +    /* As Dom0 is never moved, no penalty on using TSC there */
> 
> Again, why not any PV guest with TSC_MODE_NEVER_EMULATE?

Surely if TSC_MODE_NEVER_EMULATE is set then the TSC is /not/ stable
across a guest save/restore thus the PV clocksource must be used?

I don't think we want to assume that TSC_MODE_NEVER_EMULATE => never
migrate.

David

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13 16:07     ` David Vrabel
@ 2015-01-13 16:17       ` Boris Ostrovsky
  2015-01-13 16:33         ` Boris Ostrovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Boris Ostrovsky @ 2015-01-13 16:17 UTC (permalink / raw)
  To: David Vrabel, Imre Palik, xen-devel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Thomas Gleixner

On 01/13/2015 11:07 AM, David Vrabel wrote:
> On 13/01/15 15:42, Boris Ostrovsky wrote:
>> On 01/13/2015 04:52 AM, David Vrabel wrote:
>>> On 13/01/15 08:14, Imre Palik wrote:
>>>> From: "Palik, Imre" <imrep@amazon.de>
>>>>
>>>> In Dom0's the use of the TSC clocksource (whenever it is stable
>>>> enough to
>>>> be used) instead of the Xen clocksource should not cause any issues, as
>>>> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
>>>> efficient than the Xen paravirtualised clocksource, thus it should have
>>>> higher rating.
>>>>
>>>> This patch decreases the rating of the Xen clocksource in Dom0s to 275.
>>>> Which is half-way between the rating of the TSC clocksource (300) and
>>>> the
>>>> hpet clocksource (250).
>>> I'm happy with this but would like to see acks from those who objected
>>> to v1.
>>>
>>> David
>>>
>>>> --- a/arch/x86/xen/time.c
>>>> +++ b/arch/x86/xen/time.c
>>>> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>>>>        int cpu = smp_processor_id();
>>>>        struct timespec tp;
>>>>    +    /* As Dom0 is never moved, no penalty on using TSC there */
>> Again, why not any PV guest with TSC_MODE_NEVER_EMULATE?
> Surely if TSC_MODE_NEVER_EMULATE is set then the TSC is /not/ stable
> across a guest save/restore thus the PV clocksource must be used?

TSC is declared stable when !d->disable_migrate && !d->arch.vtsc, with 
vtsc being 0 with TSC_MODE_NEVER_EMULATE (per domain_cpuid()).

And if TSC is not stable as seen by CPUID (which would be the case if 
disable_migrate is not set) then kernel won't use TSC as clocksource 
anyway, regardless of rating value, won't it?

-boris

>
> I don't think we want to assume that TSC_MODE_NEVER_EMULATE => never
> migrate.
>
> David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13 16:17       ` Boris Ostrovsky
@ 2015-01-13 16:33         ` Boris Ostrovsky
  2015-01-14 14:21           ` Boris Ostrovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Boris Ostrovsky @ 2015-01-13 16:33 UTC (permalink / raw)
  To: David Vrabel, Imre Palik, xen-devel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Thomas Gleixner

On 01/13/2015 11:17 AM, Boris Ostrovsky wrote:
> On 01/13/2015 11:07 AM, David Vrabel wrote:
>> On 13/01/15 15:42, Boris Ostrovsky wrote:
>>> On 01/13/2015 04:52 AM, David Vrabel wrote:
>>>> On 13/01/15 08:14, Imre Palik wrote:
>>>>> From: "Palik, Imre" <imrep@amazon.de>
>>>>>
>>>>> In Dom0's the use of the TSC clocksource (whenever it is stable
>>>>> enough to
>>>>> be used) instead of the Xen clocksource should not cause any 
>>>>> issues, as
>>>>> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
>>>>> efficient than the Xen paravirtualised clocksource, thus it should 
>>>>> have
>>>>> higher rating.
>>>>>
>>>>> This patch decreases the rating of the Xen clocksource in Dom0s to 
>>>>> 275.
>>>>> Which is half-way between the rating of the TSC clocksource (300) and
>>>>> the
>>>>> hpet clocksource (250).
>>>> I'm happy with this but would like to see acks from those who objected
>>>> to v1.
>>>>
>>>> David
>>>>
>>>>> --- a/arch/x86/xen/time.c
>>>>> +++ b/arch/x86/xen/time.c
>>>>> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>>>>>        int cpu = smp_processor_id();
>>>>>        struct timespec tp;
>>>>>    +    /* As Dom0 is never moved, no penalty on using TSC there */
>>> Again, why not any PV guest with TSC_MODE_NEVER_EMULATE?
>> Surely if TSC_MODE_NEVER_EMULATE is set then the TSC is /not/ stable
>> across a guest save/restore thus the PV clocksource must be used?
>
> TSC is declared stable when !d->disable_migrate && !d->arch.vtsc, with 
> vtsc being 0 with TSC_MODE_NEVER_EMULATE (per domain_cpuid()).

I think I inverted domain_cpuid's logic here but my point was that we 
use'd use combination of TSC_MODE_NEVER_EMULATE and CPUID flag 
indicating TSC stability to pick the clocksource.


-boris

>
> And if TSC is not stable as seen by CPUID (which would be the case if 
> disable_migrate is not set) then kernel won't use TSC as clocksource 
> anyway, regardless of rating value, won't it?
>
> -boris
>
>>
>> I don't think we want to assume that TSC_MODE_NEVER_EMULATE => never
>> migrate.
>>
>> David
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13 16:33         ` Boris Ostrovsky
@ 2015-01-14 14:21           ` Boris Ostrovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Boris Ostrovsky @ 2015-01-14 14:21 UTC (permalink / raw)
  To: David Vrabel, Imre Palik, xen-devel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Thomas Gleixner

On 01/13/2015 11:33 AM, Boris Ostrovsky wrote:
> On 01/13/2015 11:17 AM, Boris Ostrovsky wrote:
>> On 01/13/2015 11:07 AM, David Vrabel wrote:
>>> On 13/01/15 15:42, Boris Ostrovsky wrote:
>>>> On 01/13/2015 04:52 AM, David Vrabel wrote:
>>>>> On 13/01/15 08:14, Imre Palik wrote:
>>>>>> From: "Palik, Imre" <imrep@amazon.de>
>>>>>>
>>>>>> In Dom0's the use of the TSC clocksource (whenever it is stable
>>>>>> enough to
>>>>>> be used) instead of the Xen clocksource should not cause any 
>>>>>> issues, as
>>>>>> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
>>>>>> efficient than the Xen paravirtualised clocksource, thus it 
>>>>>> should have
>>>>>> higher rating.
>>>>>>
>>>>>> This patch decreases the rating of the Xen clocksource in Dom0s 
>>>>>> to 275.
>>>>>> Which is half-way between the rating of the TSC clocksource (300) 
>>>>>> and
>>>>>> the
>>>>>> hpet clocksource (250).
>>>>> I'm happy with this but would like to see acks from those who 
>>>>> objected
>>>>> to v1.
>>>>>
>>>>> David
>>>>>
>>>>>> --- a/arch/x86/xen/time.c
>>>>>> +++ b/arch/x86/xen/time.c
>>>>>> @@ -487,6 +487,10 @@ static void __init xen_time_init(void)
>>>>>>        int cpu = smp_processor_id();
>>>>>>        struct timespec tp;
>>>>>>    +    /* As Dom0 is never moved, no penalty on using TSC there */
>>>> Again, why not any PV guest with TSC_MODE_NEVER_EMULATE?
>>> Surely if TSC_MODE_NEVER_EMULATE is set then the TSC is /not/ stable
>>> across a guest save/restore thus the PV clocksource must be used?
>>
>> TSC is declared stable when !d->disable_migrate && !d->arch.vtsc, 
>> with vtsc being 0 with TSC_MODE_NEVER_EMULATE (per domain_cpuid()).
>
> I think I inverted domain_cpuid's logic here but my point was that we 
> use'd use combination of TSC_MODE_NEVER_EMULATE and CPUID flag 
> indicating TSC stability to pick the clocksource.
>
>
> -boris
>
>>
>> And if TSC is not stable as seen by CPUID (which would be the case if 
>> disable_migrate is not set) then kernel won't use TSC as clocksource 
>> anyway, regardless of rating value, won't it?


So this is not going to work because early_init_intel() may set 
X86_FEATURE_CONSTANT_TSC unconditionally, without consulting CPUID.

Imre, you can ignore my question about non-dom0 guests then.

-boris



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Xen-devel] [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's
  2015-01-13  8:14 [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's Imre Palik
  2015-01-13  9:52 ` [Xen-devel] " David Vrabel
@ 2015-01-20 19:21 ` David Vrabel
  1 sibling, 0 replies; 8+ messages in thread
From: David Vrabel @ 2015-01-20 19:21 UTC (permalink / raw)
  To: Imre Palik, xen-devel, David Vrabel
  Cc: Palik, Imre, x86, linux-kernel, Ingo Molnar, Anthony Liguori,
	H. Peter Anvin, Boris Ostrovsky, Thomas Gleixner

On 13/01/15 08:14, Imre Palik wrote:
> From: "Palik, Imre" <imrep@amazon.de>
> 
> In Dom0's the use of the TSC clocksource (whenever it is stable enough to
> be used) instead of the Xen clocksource should not cause any issues, as
> Dom0 VMs never live-migrated.  The TSC clocksource is somewhat more
> efficient than the Xen paravirtualised clocksource, thus it should have
> higher rating.
> 
> This patch decreases the rating of the Xen clocksource in Dom0s to 275.
> Which is half-way between the rating of the TSC clocksource (300) and the
> hpet clocksource (250).

Applied to devel/for-linus-3.20, thanks.

David

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-20 19:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-13  8:14 [PATCH] xen-time: decreasing the rating of the xen clocksource below that of the tsc clocksource for dom0's Imre Palik
2015-01-13  9:52 ` [Xen-devel] " David Vrabel
2015-01-13 15:42   ` Boris Ostrovsky
2015-01-13 16:07     ` David Vrabel
2015-01-13 16:17       ` Boris Ostrovsky
2015-01-13 16:33         ` Boris Ostrovsky
2015-01-14 14:21           ` Boris Ostrovsky
2015-01-20 19:21 ` David Vrabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).