From: Miroslav Lichvar Date: Tue, 21 Aug 2018 11:04:21 +0000 (+0200) Subject: sys_linux: improve support for upcoming kernel versions X-Git-Tag: 3.4-pre1~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7db9d4aceab85d61adc5f1013d98465f96cfb003;p=thirdparty%2Fchrony.git sys_linux: improve support for upcoming kernel versions Starting with Linux 4.19, the frequency of the system clock should be updated immediately in the system call itself, which will significantly reduce the maximum delay of the update. Increase the assumed tick rate in order to reduce the dispersion accumulated by the driver when it sets the frequency. --- diff --git a/sys_linux.c b/sys_linux.c index 978aa67c..bd245465 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -309,9 +309,9 @@ get_version_specific_details(void) nominal_tick = (1000000L + (hz/2))/hz; /* Mirror declaration in kernel */ max_tick_bias = nominal_tick / 10; - /* We can't reliably detect the internal kernel HZ, it may not even be fixed - (CONFIG_NO_HZ aka tickless), assume the lowest commonly used fixed rate */ - tick_update_hz = 100; + /* In modern kernels the frequency of the clock is updated immediately in the + adjtimex() system call. Assume a maximum delay of 10 microseconds. */ + tick_update_hz = 100000; get_kernel_version(&major, &minor, &patch); DEBUG_LOG("Linux kernel major=%d minor=%d patch=%d", major, minor, patch); @@ -322,9 +322,15 @@ get_version_specific_details(void) if (kernelvercmp(major, minor, patch, 2, 6, 27) >= 0 && kernelvercmp(major, minor, patch, 2, 6, 33) < 0) { - /* Tickless kernels before 2.6.33 accumulated ticks only in - half-second intervals */ + /* In tickless kernels before 2.6.33 the frequency is updated in + a half-second interval */ tick_update_hz = 2; + } else if (kernelvercmp(major, minor, patch, 4, 19, 0) < 0) { + /* In kernels before 4.19 the frequency is updated only on internal ticks + (CONFIG_HZ). As their rate cannot be reliably detected from the user + space, and it may not even be constant (CONFIG_NO_HZ - aka tickless), + assume the lowest commonly used constant rate */ + tick_update_hz = 100; } /* ADJ_SETOFFSET support */