New: [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver
https://bugzilla.kernel.org/show_bug.cgi?id=213029
Bug ID: 213029
Summary: [5.12 Regression] clock_gettime() a lot slower with
Hyper-V clocksource driver
Product: Drivers
Version: 2.5
Kernel Version: 5.12
Hardware: x86-64
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Platform_x86
Assignee: [email protected]
Reporter: [email protected]
Regression: No
Since kernel 5.12 the performance of clock_gettime() is a lot slower. There seems to be a regression concerning VDSO in the Hyper-V clocksource driver.
The following code snippet runs a lot slower:
===============================
# gcc gettime.c -o gettime # cat gettime.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
struct timespec start;
unsigned long i;
for (i=0; i<100000000UL; i++) {
if( clock_gettime(CLOCK_REALTIME, &start) == -1 ) {
perror( "clock gettime" );
exit( EXIT_FAILURE );
}
}
return 0;
}===============================
# cat /sys/devices/system/clocksource/clocksource0/current_clocksource hyperv_clocksource_tsc_page
1) With kernel >= 5.12
# time ./gettime real 0m48.201s user 0m14.788s sys 0m31.531s
2) With kernel < 5.12
# time ./gettime real 0m3.308s user 0m3.214s sys 0m0.003s
I bisected the kernel and the commit that introduces the regression seems to be this:
commit e4ab4658f1cff14c82202132f7af2cb5c2741469
Author: Michael Kelley <[email protected]> Date: Tue Mar 2 13:38:19 2021 -0800
clocksource/drivers/hyper-v: Handle vDSO differences inline
While the driver for the Hyper-V Reference TSC and STIMERs is architecture neutral, vDSO is implemented for x86/x64, but not for ARM64. Current code calls into utility functions under arch/x86 (and coming, under arch/arm64) to handle the difference.
Change this approach to handle the difference inline based on whether VDSO_CLOCK_MODE_HVCLOCK is present. The new approach removes code under arch/* since the difference is tied more to the specifics of the Linux implementation than to the architecture.
No functional change.
Link:
https://lore.kernel.org/r/[email protected]
It does indeed not introduce any functional changes, but degradation in performance is quite noticeable.
Signature · 4 lines
You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.
[Bug 213029] [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver
https://bugzilla.kernel.org/show_bug.cgi?id=213029
Michael Kelley ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]
--- Comment #1 from Michael Kelley ([email protected]) ---
And I was trying to be so clever. :-( I see that Vitaly Kuznetsov has posted a patch to fix this.
One thing: The commit that causes the problem was first available in 5.13-RC1. But your problem statement above says that you see the problem with 5.12. Can you confirm? The 5.12 release doesn't have the problematic commit.
Signature · 4 lines
You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.
[Bug 213029] [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver
In reply to [email protected]https://bugzilla.kernel.org/show_bug.cgi?id=213029
Randy Dunlap ([email protected]) changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |[email protected]
Resolution|--- |CODE_FIX--- Comment #2 from Randy Dunlap ([email protected]) --- Patch merged:
commit 3486d2c9be65
Author: Vitaly Kuznetsov <[email protected]> Date: Thu May 13 09:32:46 2021 +0200
clocksource/drivers/hyper-v: Re-enable VDSO_CLOCKMODE_HVCLOCK on X86
Signature · 4 lines
You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.