* [PATCH] x86: reduce redundancy in tsc_[gs]et_info()
@ 2014-04-30 13:53 Jan Beulich
2014-04-30 14:48 ` Andrew Cooper
2014-04-30 15:08 ` Boris Ostrovsky
0 siblings, 2 replies; 4+ messages in thread
From: Jan Beulich @ 2014-04-30 13:53 UTC (permalink / raw)
To: xen-devel; +Cc: Keir Fraser
[-- Attachment #1: Type: text/plain, Size: 3868 bytes --]
- some of the case statements are effectively or mostly special cases
of others, so there's no good reason not to share the code
- in the "get" function, a variable can be made case-wide instead of
having multiple instance of it (and those even with a pointless
initializer)
- minor formatting adjustments
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1786,26 +1786,22 @@ void tsc_get_info(struct domain *d, uint
switch ( *tsc_mode )
{
+ uint64_t tsc;
+
case TSC_MODE_NEVER_EMULATE:
- *elapsed_nsec = *gtsc_khz = 0;
+ *elapsed_nsec = *gtsc_khz = 0;
break;
- case TSC_MODE_ALWAYS_EMULATE:
- *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
- *gtsc_khz = d->arch.tsc_khz;
- break;
case TSC_MODE_DEFAULT:
if ( d->arch.vtsc )
{
+ case TSC_MODE_ALWAYS_EMULATE:
*elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
*gtsc_khz = d->arch.tsc_khz;
+ break;
}
- else
- {
- uint64_t tsc = 0;
- rdtscll(tsc);
- *elapsed_nsec = scale_delta(tsc,&d->arch.vtsc_to_ns);
- *gtsc_khz = cpu_khz;
- }
+ rdtscll(tsc);
+ *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns);
+ *gtsc_khz = cpu_khz;
break;
case TSC_MODE_PVRDTSCP:
if ( d->arch.vtsc )
@@ -1815,10 +1811,9 @@ void tsc_get_info(struct domain *d, uint
}
else
{
- uint64_t tsc = 0;
rdtscll(tsc);
- *elapsed_nsec = (scale_delta(tsc,&d->arch.vtsc_to_ns) -
- d->arch.vtsc_offset);
+ *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns) -
+ d->arch.vtsc_offset;
*gtsc_khz = 0; /* ignored by tsc_set_info */
}
break;
@@ -1875,28 +1870,24 @@ void tsc_set_info(struct domain *d,
switch ( d->arch.tsc_mode = tsc_mode )
{
- case TSC_MODE_NEVER_EMULATE:
- d->arch.vtsc = 0;
- break;
- case TSC_MODE_ALWAYS_EMULATE:
- d->arch.vtsc = 1;
- 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 );
- d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
- break;
case TSC_MODE_DEFAULT:
- d->arch.vtsc = 1;
+ case TSC_MODE_ALWAYS_EMULATE:
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 )
+ d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
+ set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
+ /*
+ * In default mode use native TSC if the host has safe TSC,
+ * the VM has not migrated yet, and tsc_khz == cpu_khz.
+ */
+ if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
+ incarnation == 0 && d->arch.tsc_khz == cpu_khz )
+ {
+ case TSC_MODE_NEVER_EMULATE:
d->arch.vtsc = 0;
- else
- d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
+ break;
+ }
+ d->arch.vtsc = 1;
+ d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
break;
case TSC_MODE_PVRDTSCP:
d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) &&
[-- Attachment #2: x86-TSC-set-info-cleanup.patch --]
[-- Type: text/plain, Size: 3909 bytes --]
x86: reduce redundancy in tsc_[gs]et_info()
- some of the case statements are effectively or mostly special cases
of others, so there's no good reason not to share the code
- in the "get" function, a variable can be made case-wide instead of
having multiple instance of it (and those even with a pointless
initializer)
- minor formatting adjustments
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1786,26 +1786,22 @@ void tsc_get_info(struct domain *d, uint
switch ( *tsc_mode )
{
+ uint64_t tsc;
+
case TSC_MODE_NEVER_EMULATE:
- *elapsed_nsec = *gtsc_khz = 0;
+ *elapsed_nsec = *gtsc_khz = 0;
break;
- case TSC_MODE_ALWAYS_EMULATE:
- *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
- *gtsc_khz = d->arch.tsc_khz;
- break;
case TSC_MODE_DEFAULT:
if ( d->arch.vtsc )
{
+ case TSC_MODE_ALWAYS_EMULATE:
*elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
*gtsc_khz = d->arch.tsc_khz;
+ break;
}
- else
- {
- uint64_t tsc = 0;
- rdtscll(tsc);
- *elapsed_nsec = scale_delta(tsc,&d->arch.vtsc_to_ns);
- *gtsc_khz = cpu_khz;
- }
+ rdtscll(tsc);
+ *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns);
+ *gtsc_khz = cpu_khz;
break;
case TSC_MODE_PVRDTSCP:
if ( d->arch.vtsc )
@@ -1815,10 +1811,9 @@ void tsc_get_info(struct domain *d, uint
}
else
{
- uint64_t tsc = 0;
rdtscll(tsc);
- *elapsed_nsec = (scale_delta(tsc,&d->arch.vtsc_to_ns) -
- d->arch.vtsc_offset);
+ *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns) -
+ d->arch.vtsc_offset;
*gtsc_khz = 0; /* ignored by tsc_set_info */
}
break;
@@ -1875,28 +1870,24 @@ void tsc_set_info(struct domain *d,
switch ( d->arch.tsc_mode = tsc_mode )
{
- case TSC_MODE_NEVER_EMULATE:
- d->arch.vtsc = 0;
- break;
- case TSC_MODE_ALWAYS_EMULATE:
- d->arch.vtsc = 1;
- 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 );
- d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
- break;
case TSC_MODE_DEFAULT:
- d->arch.vtsc = 1;
+ case TSC_MODE_ALWAYS_EMULATE:
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 )
+ d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
+ set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
+ /*
+ * In default mode use native TSC if the host has safe TSC,
+ * the VM has not migrated yet, and tsc_khz == cpu_khz.
+ */
+ if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
+ incarnation == 0 && d->arch.tsc_khz == cpu_khz )
+ {
+ case TSC_MODE_NEVER_EMULATE:
d->arch.vtsc = 0;
- else
- d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
+ break;
+ }
+ d->arch.vtsc = 1;
+ d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
break;
case TSC_MODE_PVRDTSCP:
d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) &&
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86: reduce redundancy in tsc_[gs]et_info()
2014-04-30 13:53 [PATCH] x86: reduce redundancy in tsc_[gs]et_info() Jan Beulich
@ 2014-04-30 14:48 ` Andrew Cooper
2014-04-30 14:59 ` Jan Beulich
2014-04-30 15:08 ` Boris Ostrovsky
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2014-04-30 14:48 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Keir Fraser
[-- Attachment #1.1: Type: text/plain, Size: 4599 bytes --]
On 30/04/14 14:53, Jan Beulich wrote:
> - some of the case statements are effectively or mostly special cases
> of others, so there's no good reason not to share the code
> - in the "get" function, a variable can be made case-wide instead of
> having multiple instance of it (and those even with a pointless
> initializer)
> - minor formatting adjustments
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -1786,26 +1786,22 @@ void tsc_get_info(struct domain *d, uint
>
> switch ( *tsc_mode )
> {
> + uint64_t tsc;
> +
> case TSC_MODE_NEVER_EMULATE:
> - *elapsed_nsec = *gtsc_khz = 0;
> + *elapsed_nsec = *gtsc_khz = 0;
> break;
> - case TSC_MODE_ALWAYS_EMULATE:
> - *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
> - *gtsc_khz = d->arch.tsc_khz;
> - break;
> case TSC_MODE_DEFAULT:
> if ( d->arch.vtsc )
> {
> + case TSC_MODE_ALWAYS_EMULATE:
> *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
> *gtsc_khz = d->arch.tsc_khz;
double space after =
> + break;
> }
> - else
> - {
> - uint64_t tsc = 0;
> - rdtscll(tsc);
> - *elapsed_nsec = scale_delta(tsc,&d->arch.vtsc_to_ns);
> - *gtsc_khz = cpu_khz;
> - }
> + rdtscll(tsc);
> + *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns);
> + *gtsc_khz = cpu_khz;
> break;
> case TSC_MODE_PVRDTSCP:
> if ( d->arch.vtsc )
> @@ -1815,10 +1811,9 @@ void tsc_get_info(struct domain *d, uint
> }
> else
> {
> - uint64_t tsc = 0;
> rdtscll(tsc);
> - *elapsed_nsec = (scale_delta(tsc,&d->arch.vtsc_to_ns) -
> - d->arch.vtsc_offset);
> + *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns) -
> + d->arch.vtsc_offset;
> *gtsc_khz = 0; /* ignored by tsc_set_info */
> }
> break;
There is a coverity complaint that following this switch statement,
there is a read of *elapsed_nsec which might be uninitialised if
tsc_mode missed on of the case statements. While I believe this is
currently impossible, it might we wise to have a "default: BUG();" in
case half a new tsc_mode appears.
> @@ -1875,28 +1870,24 @@ void tsc_set_info(struct domain *d,
>
> switch ( d->arch.tsc_mode = tsc_mode )
> {
> - case TSC_MODE_NEVER_EMULATE:
> - d->arch.vtsc = 0;
> - break;
> - case TSC_MODE_ALWAYS_EMULATE:
> - d->arch.vtsc = 1;
> - 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 );
> - d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> - break;
> case TSC_MODE_DEFAULT:
> - d->arch.vtsc = 1;
> + case TSC_MODE_ALWAYS_EMULATE:
> 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 )
This wont apply cleanly on top of staging. Boris made some changed in
this area with his HVM guest TSC series.
~Andrew
> + d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
> + set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
> + /*
> + * In default mode use native TSC if the host has safe TSC,
> + * the VM has not migrated yet, and tsc_khz == cpu_khz.
> + */
> + if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
> + incarnation == 0 && d->arch.tsc_khz == cpu_khz )
> + {
> + case TSC_MODE_NEVER_EMULATE:
> d->arch.vtsc = 0;
> - else
> - d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> + break;
> + }
> + d->arch.vtsc = 1;
> + d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> break;
> case TSC_MODE_PVRDTSCP:
> d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) &&
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 5790 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] x86: reduce redundancy in tsc_[gs]et_info()
2014-04-30 14:48 ` Andrew Cooper
@ 2014-04-30 14:59 ` Jan Beulich
0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2014-04-30 14:59 UTC (permalink / raw)
To: Andrew Cooper; +Cc: xen-devel, Keir Fraser
>>> On 30.04.14 at 16:48, <andrew.cooper3@citrix.com> wrote:
> On 30/04/14 14:53, Jan Beulich wrote:
>> --- a/xen/arch/x86/time.c
>> +++ b/xen/arch/x86/time.c
>> @@ -1786,26 +1786,22 @@ void tsc_get_info(struct domain *d, uint
>>
>> switch ( *tsc_mode )
>> {
>> + uint64_t tsc;
>> +
>> case TSC_MODE_NEVER_EMULATE:
>> - *elapsed_nsec = *gtsc_khz = 0;
>> + *elapsed_nsec = *gtsc_khz = 0;
>> break;
>> - case TSC_MODE_ALWAYS_EMULATE:
>> - *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
>> - *gtsc_khz = d->arch.tsc_khz;
>> - break;
>> case TSC_MODE_DEFAULT:
>> if ( d->arch.vtsc )
>> {
>> + case TSC_MODE_ALWAYS_EMULATE:
>> *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
>> *gtsc_khz = d->arch.tsc_khz;
>
> double space after =
I left them untouched on lines I didn't need to touch anyway, but of
course I can as well clean them up uniformly (there were two or three
more of them).
>> @@ -1815,10 +1811,9 @@ void tsc_get_info(struct domain *d, uint
>> }
>> else
>> {
>> - uint64_t tsc = 0;
>> rdtscll(tsc);
>> - *elapsed_nsec = (scale_delta(tsc,&d->arch.vtsc_to_ns) -
>> - d->arch.vtsc_offset);
>> + *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns) -
>> + d->arch.vtsc_offset;
>> *gtsc_khz = 0; /* ignored by tsc_set_info */
>> }
>> break;
>
> There is a coverity complaint that following this switch statement,
> there is a read of *elapsed_nsec which might be uninitialised if
> tsc_mode missed on of the case statements. While I believe this is
> currently impossible, it might we wise to have a "default: BUG();" in
> case half a new tsc_mode appears.
I'm not in favor of such constructs when it's sufficiently obvious that
all cases are being handled.
>> @@ -1875,28 +1870,24 @@ void tsc_set_info(struct domain *d,
>>
>> switch ( d->arch.tsc_mode = tsc_mode )
>> {
>> - case TSC_MODE_NEVER_EMULATE:
>> - d->arch.vtsc = 0;
>> - break;
>> - case TSC_MODE_ALWAYS_EMULATE:
>> - d->arch.vtsc = 1;
>> - 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 );
>> - d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
>> - break;
>> case TSC_MODE_DEFAULT:
>> - d->arch.vtsc = 1;
>> + case TSC_MODE_ALWAYS_EMULATE:
>> 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 )
>
> This wont apply cleanly on top of staging. Boris made some changed in
> this area with his HVM guest TSC series.
Right - I forgot I need to re-sync before submitting. Will be a v2 with
the above formatting changes also taken care of.
Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: reduce redundancy in tsc_[gs]et_info()
2014-04-30 13:53 [PATCH] x86: reduce redundancy in tsc_[gs]et_info() Jan Beulich
2014-04-30 14:48 ` Andrew Cooper
@ 2014-04-30 15:08 ` Boris Ostrovsky
1 sibling, 0 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2014-04-30 15:08 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Keir Fraser
[-- Attachment #1.1: Type: text/plain, Size: 4243 bytes --]
On 04/30/2014 09:53 AM, Jan Beulich wrote:
> - some of the case statements are effectively or mostly special cases
> of others, so there's no good reason not to share the code
> - in the "get" function, a variable can be made case-wide instead of
> having multiple instance of it (and those even with a pointless
> initializer)
> - minor formatting adjustments
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -1786,26 +1786,22 @@ void tsc_get_info(struct domain *d, uint
>
> switch ( *tsc_mode )
> {
> + uint64_t tsc;
> +
> case TSC_MODE_NEVER_EMULATE:
> - *elapsed_nsec = *gtsc_khz = 0;
> + *elapsed_nsec = *gtsc_khz = 0;
> break;
> - case TSC_MODE_ALWAYS_EMULATE:
> - *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
> - *gtsc_khz = d->arch.tsc_khz;
> - break;
> case TSC_MODE_DEFAULT:
> if ( d->arch.vtsc )
> {
> + case TSC_MODE_ALWAYS_EMULATE:
> *elapsed_nsec = get_s_time() - d->arch.vtsc_offset;
> *gtsc_khz = d->arch.tsc_khz;
> + break;
> }
> - else
> - {
> - uint64_t tsc = 0;
> - rdtscll(tsc);
> - *elapsed_nsec = scale_delta(tsc,&d->arch.vtsc_to_ns);
> - *gtsc_khz = cpu_khz;
> - }
> + rdtscll(tsc);
> + *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns);
> + *gtsc_khz = cpu_khz;
> break;
> case TSC_MODE_PVRDTSCP:
> if ( d->arch.vtsc )
> @@ -1815,10 +1811,9 @@ void tsc_get_info(struct domain *d, uint
> }
> else
> {
> - uint64_t tsc = 0;
> rdtscll(tsc);
> - *elapsed_nsec = (scale_delta(tsc,&d->arch.vtsc_to_ns) -
> - d->arch.vtsc_offset);
> + *elapsed_nsec = scale_delta(tsc, &d->arch.vtsc_to_ns) -
> + d->arch.vtsc_offset;
> *gtsc_khz = 0; /* ignored by tsc_set_info */
> }
> break;
> @@ -1875,28 +1870,24 @@ void tsc_set_info(struct domain *d,
>
> switch ( d->arch.tsc_mode = tsc_mode )
> {
> - case TSC_MODE_NEVER_EMULATE:
> - d->arch.vtsc = 0;
> - break;
> - case TSC_MODE_ALWAYS_EMULATE:
> - d->arch.vtsc = 1;
> - 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 );
> - d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> - break;
> case TSC_MODE_DEFAULT:
> - d->arch.vtsc = 1;
> + case TSC_MODE_ALWAYS_EMULATE:
> 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 )
> + d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
> + set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
> + /*
> + * In default mode use native TSC if the host has safe TSC,
> + * the VM has not migrated yet, and tsc_khz == cpu_khz.
> + */
> + if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
> + incarnation == 0 && d->arch.tsc_khz == cpu_khz )
> + {
> + case TSC_MODE_NEVER_EMULATE:
> d->arch.vtsc = 0;
> - else
> - d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> + break;
> + }
> + d->arch.vtsc = 1;
> + d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
> break;
> case TSC_MODE_PVRDTSCP:
> d->arch.vtsc = boot_cpu_has(X86_FEATURE_RDTSCP) &&
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 5126 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-30 15:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 13:53 [PATCH] x86: reduce redundancy in tsc_[gs]et_info() Jan Beulich
2014-04-30 14:48 ` Andrew Cooper
2014-04-30 14:59 ` Jan Beulich
2014-04-30 15:08 ` Boris Ostrovsky
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.