stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit
@ 2020-03-27  2:11 Tianyu Lan
  2020-03-27  8:53 ` Vitaly Kuznetsov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Tianyu Lan @ 2020-03-27  2:11 UTC (permalink / raw)
  To: kys, haiyangz, sthemmin, liuwe, daniel.lezcano, tglx, michael.h.kelley
  Cc: Tianyu Lan, linux-hyperv, linux-kernel, vkuznets, stable, Yubo Xie

From: Yubo Xie <yuboxie@microsoft.com>

sched clock callback should return time with nano second as unit
but current hv callback returns time with 100ns. Fix it.

Cc: stable@vger.kernel.org
Signed-off-by: Yubo Xie <yuboxie@microsoft.com>
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Fixes: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function")
---
Change since v1:
	Update fix commit number in change log. 
---
 drivers/clocksource/hyperv_timer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 9d808d595ca8..662ed978fa24 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
 
 static u64 read_hv_sched_clock_tsc(void)
 {
-	return read_hv_clock_tsc() - hv_sched_clock_offset;
+	return (read_hv_clock_tsc() - hv_sched_clock_offset)
+		* (NSEC_PER_SEC / HV_CLOCK_HZ);
 }
 
 static void suspend_hv_clock_tsc(struct clocksource *arg)
@@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
 
 static u64 read_hv_sched_clock_msr(void)
 {
-	return read_hv_clock_msr() - hv_sched_clock_offset;
+	return (read_hv_clock_msr() - hv_sched_clock_offset)
+		* (NSEC_PER_SEC / HV_CLOCK_HZ);
 }
 
 static struct clocksource hyperv_cs_msr = {
-- 
2.14.5


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

* Re: [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit
  2020-03-27  2:11 [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Tianyu Lan
@ 2020-03-27  8:53 ` Vitaly Kuznetsov
  2020-03-30 10:05   ` Wei Liu
  2020-03-27 11:30 ` [tip: timers/urgent] clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly tip-bot2 for Yubo Xie
  2020-03-27 15:03 ` [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Sasha Levin
  2 siblings, 1 reply; 6+ messages in thread
From: Vitaly Kuznetsov @ 2020-03-27  8:53 UTC (permalink / raw)
  To: Tianyu Lan
  Cc: Tianyu Lan, linux-hyperv, linux-kernel, stable, Yubo Xie, kys,
	haiyangz, sthemmin, liuwe, daniel.lezcano, tglx,
	michael.h.kelley

Tianyu Lan <ltykernel@gmail.com> writes:

> From: Yubo Xie <yuboxie@microsoft.com>
>
> sched clock callback should return time with nano second as unit
> but current hv callback returns time with 100ns. Fix it.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Yubo Xie <yuboxie@microsoft.com>
> Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> Fixes: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function")
> ---
> Change since v1:
> 	Update fix commit number in change log. 
> ---
>  drivers/clocksource/hyperv_timer.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> index 9d808d595ca8..662ed978fa24 100644
> --- a/drivers/clocksource/hyperv_timer.c
> +++ b/drivers/clocksource/hyperv_timer.c
> @@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
>  
>  static u64 read_hv_sched_clock_tsc(void)
>  {
> -	return read_hv_clock_tsc() - hv_sched_clock_offset;
> +	return (read_hv_clock_tsc() - hv_sched_clock_offset)
> +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
>  }
>  
>  static void suspend_hv_clock_tsc(struct clocksource *arg)
> @@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
>  
>  static u64 read_hv_sched_clock_msr(void)
>  {
> -	return read_hv_clock_msr() - hv_sched_clock_offset;
> +	return (read_hv_clock_msr() - hv_sched_clock_offset)
> +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
>  }
>  
>  static struct clocksource hyperv_cs_msr = {

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


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

* [tip: timers/urgent] clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly
  2020-03-27  2:11 [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Tianyu Lan
  2020-03-27  8:53 ` Vitaly Kuznetsov
@ 2020-03-27 11:30 ` tip-bot2 for Yubo Xie
  2020-03-27 15:03 ` [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Sasha Levin
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Yubo Xie @ 2020-03-27 11:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Yubo Xie, Tianyu Lan, Thomas Gleixner, Vitaly Kuznetsov, stable,
	x86, LKML

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     749da8ca978f19710aba496208c480ad42d37f79
Gitweb:        https://git.kernel.org/tip/749da8ca978f19710aba496208c480ad42d37f79
Author:        Yubo Xie <yuboxie@microsoft.com>
AuthorDate:    Thu, 26 Mar 2020 19:11:59 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 27 Mar 2020 12:27:45 +01:00

clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly

The sched clock read functions return the HV clock (100ns granularity)
without converting it to nanoseconds.

Add the missing conversion.

Fixes: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function")
Signed-off-by: Yubo Xie <yuboxie@microsoft.com>
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20200327021159.31429-1-Tianyu.Lan@microsoft.com

---
 drivers/clocksource/hyperv_timer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 9d808d5..eb0ba78 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
 
 static u64 read_hv_sched_clock_tsc(void)
 {
-	return read_hv_clock_tsc() - hv_sched_clock_offset;
+	return (read_hv_clock_tsc() - hv_sched_clock_offset) *
+		(NSEC_PER_SEC / HV_CLOCK_HZ);
 }
 
 static void suspend_hv_clock_tsc(struct clocksource *arg)
@@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
 
 static u64 read_hv_sched_clock_msr(void)
 {
-	return read_hv_clock_msr() - hv_sched_clock_offset;
+	return (read_hv_clock_msr() - hv_sched_clock_offset) *
+		(NSEC_PER_SEC / HV_CLOCK_HZ);
 }
 
 static struct clocksource hyperv_cs_msr = {

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

* Re: [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit
  2020-03-27  2:11 [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Tianyu Lan
  2020-03-27  8:53 ` Vitaly Kuznetsov
  2020-03-27 11:30 ` [tip: timers/urgent] clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly tip-bot2 for Yubo Xie
@ 2020-03-27 15:03 ` Sasha Levin
  2 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2020-03-27 15:03 UTC (permalink / raw)
  To: Sasha Levin, Tianyu Lan, Yubo Xie, kys, haiyangz, sthemmin
  Cc: Tianyu Lan, stable, stable

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function").

The bot has tested the following trees: v5.5.11, v5.4.27.

v5.5.11: Failed to apply! Possible dependencies:
    0af3e137c144 ("clocksource/drivers/hyper-v: Untangle stimers and timesync from clocksources")
    ddc61bbc4501 ("clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page")

v5.4.27: Failed to apply! Possible dependencies:
    0af3e137c144 ("clocksource/drivers/hyper-v: Untangle stimers and timesync from clocksources")
    ddc61bbc4501 ("clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

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

* Re: [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit
  2020-03-27  8:53 ` Vitaly Kuznetsov
@ 2020-03-30 10:05   ` Wei Liu
  2020-03-30 10:22     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2020-03-30 10:05 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: Tianyu Lan, Tianyu Lan, linux-hyperv, linux-kernel, stable,
	Yubo Xie, kys, haiyangz, sthemmin, liuwe, daniel.lezcano, tglx,
	michael.h.kelley, Wei Liu

On Fri, Mar 27, 2020 at 09:53:39AM +0100, Vitaly Kuznetsov wrote:
> Tianyu Lan <ltykernel@gmail.com> writes:
> 
> > From: Yubo Xie <yuboxie@microsoft.com>
> >
> > sched clock callback should return time with nano second as unit
> > but current hv callback returns time with 100ns. Fix it.
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Yubo Xie <yuboxie@microsoft.com>
> > Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> > Fixes: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function")
> > ---
> > Change since v1:
> > 	Update fix commit number in change log. 
> > ---
> >  drivers/clocksource/hyperv_timer.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> > index 9d808d595ca8..662ed978fa24 100644
> > --- a/drivers/clocksource/hyperv_timer.c
> > +++ b/drivers/clocksource/hyperv_timer.c
> > @@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
> >  
> >  static u64 read_hv_sched_clock_tsc(void)
> >  {
> > -	return read_hv_clock_tsc() - hv_sched_clock_offset;
> > +	return (read_hv_clock_tsc() - hv_sched_clock_offset)
> > +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
> >  }
> >  
> >  static void suspend_hv_clock_tsc(struct clocksource *arg)
> > @@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
> >  
> >  static u64 read_hv_sched_clock_msr(void)
> >  {
> > -	return read_hv_clock_msr() - hv_sched_clock_offset;
> > +	return (read_hv_clock_msr() - hv_sched_clock_offset)
> > +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
> >  }
> >  
> >  static struct clocksource hyperv_cs_msr = {
> 
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

Queued for hyperv-fixes. Thank you both.

Wei.

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

* Re: [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit
  2020-03-30 10:05   ` Wei Liu
@ 2020-03-30 10:22     ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2020-03-30 10:22 UTC (permalink / raw)
  To: Vitaly Kuznetsov
  Cc: Tianyu Lan, Tianyu Lan, linux-hyperv, linux-kernel, stable,
	Yubo Xie, kys, haiyangz, sthemmin, liuwe, daniel.lezcano, tglx,
	michael.h.kelley, Wei Liu

On Mon, Mar 30, 2020 at 11:05:02AM +0100, Wei Liu wrote:
> On Fri, Mar 27, 2020 at 09:53:39AM +0100, Vitaly Kuznetsov wrote:
> > Tianyu Lan <ltykernel@gmail.com> writes:
> > 
> > > From: Yubo Xie <yuboxie@microsoft.com>
> > >
> > > sched clock callback should return time with nano second as unit
> > > but current hv callback returns time with 100ns. Fix it.
> > >
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Yubo Xie <yuboxie@microsoft.com>
> > > Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> > > Fixes: bd00cd52d5be ("clocksource/drivers/hyperv: Add Hyper-V specific sched clock function")
> > > ---
> > > Change since v1:
> > > 	Update fix commit number in change log. 
> > > ---
> > >  drivers/clocksource/hyperv_timer.c | 6 ++++--
> > >  1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
> > > index 9d808d595ca8..662ed978fa24 100644
> > > --- a/drivers/clocksource/hyperv_timer.c
> > > +++ b/drivers/clocksource/hyperv_timer.c
> > > @@ -343,7 +343,8 @@ static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg)
> > >  
> > >  static u64 read_hv_sched_clock_tsc(void)
> > >  {
> > > -	return read_hv_clock_tsc() - hv_sched_clock_offset;
> > > +	return (read_hv_clock_tsc() - hv_sched_clock_offset)
> > > +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
> > >  }
> > >  
> > >  static void suspend_hv_clock_tsc(struct clocksource *arg)
> > > @@ -398,7 +399,8 @@ static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg)
> > >  
> > >  static u64 read_hv_sched_clock_msr(void)
> > >  {
> > > -	return read_hv_clock_msr() - hv_sched_clock_offset;
> > > +	return (read_hv_clock_msr() - hv_sched_clock_offset)
> > > +		* (NSEC_PER_SEC / HV_CLOCK_HZ);
> > >  }
> > >  
> > >  static struct clocksource hyperv_cs_msr = {
> > 
> > Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> 
> Queued for hyperv-fixes. Thank you both.

It appears Thomas already sent this to Linus, so I will drop this from
my branch.

Wei.

> 
> Wei.

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

end of thread, other threads:[~2020-03-30 10:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27  2:11 [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Tianyu Lan
2020-03-27  8:53 ` Vitaly Kuznetsov
2020-03-30 10:05   ` Wei Liu
2020-03-30 10:22     ` Wei Liu
2020-03-27 11:30 ` [tip: timers/urgent] clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly tip-bot2 for Yubo Xie
2020-03-27 15:03 ` [PATCH V2] x86/Hyper-V: Fix hv sched clock function return wrong time unit Sasha Levin

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).