[Bug 213029] New: [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: drivers_platform_x86@xxxxxxxxxxxxxxxxxxxx
          Reporter: mgamal@xxxxxxxxxx
        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 <mikelley@xxxxxxxxxxxxx>
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.

    Signed-off-by: Michael Kelley <mikelley@xxxxxxxxxxxxx>
    Reviewed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
    Acked-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
    Link:
https://lore.kernel.org/r/1614721102-2241-8-git-send-email-mikelley@xxxxxxxxxxxxx
    Signed-off-by: Wei Liu <wei.liu@xxxxxxxxxx>

It does indeed not introduce any functional changes, but degradation in
performance is quite noticeable.

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux