All of lore.kernel.org
 help / color / mirror / Atom feed
From: bugzilla-daemon@bugzilla.kernel.org
To: platform-driver-x86@vger.kernel.org
Subject: [Bug 213029] New: [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver
Date: Tue, 11 May 2021 13:08:22 +0000	[thread overview]
Message-ID: <bug-213029-215701@https.bugzilla.kernel.org/> (raw)

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@kernel-bugs.osdl.org
          Reporter: mgamal@redhat.com
        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@microsoft.com>
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@microsoft.com>
    Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
    Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Link:
https://lore.kernel.org/r/1614721102-2241-8-git-send-email-mikelley@microsoft.com
    Signed-off-by: Wei Liu <wei.liu@kernel.org>

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.

             reply	other threads:[~2021-05-11 13:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11 13:08 bugzilla-daemon [this message]
2021-05-12 15:02 ` [Bug 213029] [5.12 Regression] clock_gettime() a lot slower with Hyper-V clocksource driver bugzilla-daemon
2025-12-22  7:05 ` bugzilla-daemon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-213029-215701@https.bugzilla.kernel.org/ \
    --to=bugzilla-daemon@bugzilla.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.