diff mbox series

[v2,2/2] x86/time: report correct frequency of Xen PV clocksource

Message ID 1580852977-23866-3-git-send-email-igor.druzhinin@citrix.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Igor Druzhinin Feb. 4, 2020, 9:49 p.m. UTC
The value of the counter represents the number of nanoseconds
since host boot. That means the correct frequency is always 1GHz.

This inconsistency caused time to go slower in PV shim on most
platforms.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
 xen/arch/x86/time.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Roger Pau Monné Feb. 5, 2020, 9:09 a.m. UTC | #1
On Tue, Feb 04, 2020 at 09:49:37PM +0000, Igor Druzhinin wrote:
> The value of the counter represents the number of nanoseconds
> since host boot. That means the correct frequency is always 1GHz.
> 
> This inconsistency caused time to go slower in PV shim on most
> platforms.
> 
> Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>

Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks!

> ---
>  xen/arch/x86/time.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
> index 7e7a62e..26f9bad 100644
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -587,9 +587,7 @@ static int64_t __init init_xen_timer(struct platform_timesource *pts)
>      if ( !xen_guest )
>          return 0;
>  
> -    pts->frequency = xen_timer_cpu_frequency();
> -
> -    return pts->frequency;
> +    return xen_timer_cpu_frequency();
>  }
>  
>  static always_inline uint64_t read_cycle(const struct vcpu_time_info *info,
> @@ -643,6 +641,7 @@ static struct platform_timesource __initdata plt_xen_timer =
>  {
>      .id = "xen",
>      .name = "XEN PV CLOCK",
> +    .frequency = 1000000000ULL,

I think you can drop the type literal here?

Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 7e7a62e..26f9bad 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -587,9 +587,7 @@  static int64_t __init init_xen_timer(struct platform_timesource *pts)
     if ( !xen_guest )
         return 0;
 
-    pts->frequency = xen_timer_cpu_frequency();
-
-    return pts->frequency;
+    return xen_timer_cpu_frequency();
 }
 
 static always_inline uint64_t read_cycle(const struct vcpu_time_info *info,
@@ -643,6 +641,7 @@  static struct platform_timesource __initdata plt_xen_timer =
 {
     .id = "xen",
     .name = "XEN PV CLOCK",
+    .frequency = 1000000000ULL,
     .read_counter = read_xen_timer,
     .init = init_xen_timer,
     .resume = resume_xen_timer,