Red Hat Bugzilla – Bug 204748
ntp wakes up once per second, that's overkill
Last modified: 2007-11-30 17:11:41 EST
Description of problem:
we're working with RH engineers on the tickless idle kernel feature. However,
having a really idle kernel is no use if userspace applications keep waking up
at a high frequency, because then there still aren't long power save periods.
ntp is one of the apps that on an idle system wakes up regularly, and in fact in
the fedora confuration that is once per second. While once per second may not
sound excessive, there are many daemons on a Fedora system and if they all wake
up once a second there still isn't a lot of really idle time.
The once per second comes from a setting in ntp.h called EVENT_TIMEOUT;
this setting can be changed, as the example patch below does. This setting is
consistency used as 1 << EVENT_TIMOUT, so a value of 4 gives 16 seconds.
On any reasonable functioning machine, a ntp correction interval of 16 seconds
ought to be more than plenty to keep an accurate clock; after all PC clocks are
accurate in the order of seconds per *day*.
--- include/ntp.h~ 2006-08-31 14:28:34.000000000 +0200
+++ include/ntp.h 2006-08-31 14:28:34.000000000 +0200
@@ -165,7 +165,7 @@
#define UNIVAR(x) (SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */
#define ULOGTOD(a) (1L << (int)(a)) /* ulog2 to double */
-#define EVENT_TIMEOUT 0 /* one second, that is */
+#define EVENT_TIMEOUT 4 /* 16 seconds, that is */
Actually system clock isn't corrected in user space at all when PLL updates in
kernel are used, so 16s would be ok in this regard. But there is other code that
needs to be executed with better accuracy than 16s, just changing EVENT_TIMEOUT
However, I think it is possible to modify ntpd so that it will wake up just few
times per hour in usual conditions. I will check how much code needs to be modified.
Any updates? This wakeup issue definitely burns power.
Fixed in ntp-4.2.4-4.fc7.
Note that ntpd still needs to wake up once per second when a refclock is used
(i.e. server 127.127.*.*) or kernel discipline is disabled.
It's not clear to me how comment #3 applies to typical systems.
On this Fedora 7 machine which so far as I know doesn't have a reference clock,
NTP still wakes up once a second showing as
which sounds to me like it's scribbling into the battery backed clock, certainly
not something we want to waste our time doing frequently.
I have ntp-4.2.4p2-3.fc7
How would I know if "kernel discipline is disabled" ?
The Local Clock (server 127.127.1.0) is also a reference clock. It was enabled
by default in ntp.conf before F7.
Kernel discipline should be always enabled unless ntpd is started with -x option
or it's disabled in ntp.conf with tinker command. ntptime prints PLL in the
clock status line.
To verify that ntpd isn't causing the wakeups directly you can start ntpd with
-D 4 and watch the output.
OK, powertop still blames NTP for one wakeup per second but it appears from
strace output that this is caused in fact by NTP calling adjtimex() once every
minute or so, presumably some kernel code then does... something once per
second. Micro-adjustments to the clock?
I don't know if kernel wakeups are less horrible than userspace wakeups but I'm
content that NTP waking up once per minute or so is acceptable, this bug was
properly closed and I will leave you alone, sorry for the disturbance.
one thing to note; if you upgraded from a previous version of fedora, there is
a /etc/ntp.conf.rpmnew, which you need to copy over /etc/ntpd.conf to have
these changes effected.
Please file a bug against kernel component. I'm not sure, but I think I've seen
a similar problem while playing with different timesources.