Bug 204748

Summary: ntp wakes up once per second, that's overkill
Product: [Fedora] Fedora Reporter: Arjan van de Ven <arjan>
Component: ntpAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: redhat
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-01-29 14:01:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 204948    

Description Arjan van de Ven 2006-08-31 12:35:00 UTC
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 */

Comment 1 Miroslav Lichvar 2006-08-31 14:34:33 UTC
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
isn't sufficient.

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.

Comment 2 Jeff Garzik 2006-12-19 21:19:59 UTC
Any updates?  This wakeup issue definitely burns power.

Comment 3 Miroslav Lichvar 2007-01-29 14:01:41 UTC
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.

Comment 4 Nick Lamb 2007-09-04 01:44:27 UTC
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

do_adjtimex (sync_cmos_clock)

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" ?

Comment 5 Miroslav Lichvar 2007-09-04 11:55:48 UTC
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.

Comment 6 Nick Lamb 2007-09-04 17:05:35 UTC
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.

Comment 7 Arjan van de Ven 2007-09-05 07:24:21 UTC
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.

Comment 8 Miroslav Lichvar 2007-09-05 08:11:33 UTC
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.