x86/Hyper-V: Fix hv sched clock function return wrong time unit
Subsystems (4)
PATCH v2 1/1 x86/Hyper-V: Fix hv sched clock function return wrong time unit
From: Yubo Xie <[email protected]>
sched clock callback should return time with nano second as unit but current hv callback returns time with 100ns. Fix it.
---
Change since v1:
Update fix commit number in change log.
--- drivers/clocksource/hyperv_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +4 -2
@@ -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 = {
Signature · 1 line
2.14.5
Quoted 31 lines · Tianyu Lan
From: Yubo Xie <[email protected]>
sched clock callback should return time with nano second as unit but current hv callback returns time with 100ns. Fix it.
Signed-off-by Yubo Xie <[email protected]>Signed-off-by Tianyu Lan <[email protected]>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(-)drivers/clocksource/hyperv_timer.c +2
-1@@ -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)
drivers/clocksource/hyperv_timer.c static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg) · line 406
Quoted 9 lines
drivers/clocksource/hyperv_timer.c +2
-1@@ -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 = {
Signature · 1 line
Vitaly
Quoted 41 lines · Vitaly Kuznetsov
Quoted 39 lines · Tianyu Lan
From: Yubo Xie <[email protected]>
sched clock callback should return time with nano second as unit but current hv callback returns time with 100ns. Fix it.
Signed-off-by Yubo Xie <[email protected]>Signed-off-by Tianyu Lan <[email protected]>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(-)drivers/clocksource/hyperv_timer.c +4
-2@@ -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 ); }
Quoted 3 lines
drivers/clocksource/hyperv_timer.c static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg) · line 406
Quoted 1 line
drivers/clocksource/hyperv_timer.c +0
-0static struct clocksource hyperv_cs_msr = {Reviewed-by Vitaly Kuznetsov <[email protected]>
Queued for hyperv-fixes. Thank you both.
Wei.
Wei Liu
maintainerQuoted 42 lines · Wei Liu
Quoted 41 lines · Vitaly Kuznetsov
Quoted 39 lines · Tianyu Lan
From: Yubo Xie <[email protected]>
sched clock callback should return time with nano second as unit but current hv callback returns time with 100ns. Fix it.
Signed-off-by Yubo Xie <[email protected]>Signed-off-by Tianyu Lan <[email protected]>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(-)drivers/clocksource/hyperv_timer.c +4
-2@@ -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 ); }
Quoted 5 lines
Quoted 3 lines
drivers/clocksource/hyperv_timer.c static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg) · line 406
Quoted 1 line
drivers/clocksource/hyperv_timer.c +0
-0static struct clocksource hyperv_cs_msr = {Reviewed-by Vitaly Kuznetsov <[email protected]>Queued for hyperv-fixes. Thank you both.
It appears Thomas already sent this to Linus, so I will drop this from my branch.
Wei.
Quoted 2 lines
Wei.
[tip: timers/urgent] clocksource/drivers/hyper-v: Make sched clock return nanoseconds correctly
In reply to Tianyu LanThe following commit has been merged into the timers/urgent branch of tip:
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 <[email protected]> AuthorDate: Thu, 26 Mar 2020 19:11:59 -07:00 Committer: Thomas Gleixner <[email protected]> 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.
--- drivers/clocksource/hyperv_timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +4 -2
@@ -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 = {
Sasha Levin
maintainerHi
[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?
Signature · 2 lines
Thanks Sasha