[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
You are supposed to be able to use the -N (--nice) option to ntpd but
upstream ntp bug report shows it doesn't work:

http://bugs.ntp.org/show_bug.cgi?id=1230

Testing on 11.04

$ lsb_release -ds
Ubuntu 11.04
$ uname -srv
Linux 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011
$ ntpd --version
ntpd - NTP daemon program - Ver. 4.2.6p2
$ apt-cache policy ntp | egrep 'Installed|Candidate'
  Installed: 1:4.2.6.p2+dfsg-1ubuntu5.1
  Candidate: 1:4.2.6.p2+dfsg-1ubuntu5.1

WIthout -N

$ (ps alx | head -1) ; (ps alx | grep ntpd) | grep -v grep
F   UID   PID  PPID PRI  NIVSZ   RSS WCHAN  STAT TTYTIME COMMAND
5   117  1955 1  20   0  38864  2164 poll_s Ss   ?  0:00 
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /var/lib/ntp/ntp.conf.dhcp -u 117:126

With -N

$ (ps alx | head -1) ; (ps alx | grep ntpd) | grep -v grepF   UID   PID  PPID 
PRI  NIVSZ   RSS WCHAN  STAT TTYTIME COMMAND
5   117  2915 1  20   0  38736  2096 poll_s Ss   ?  0:00 
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -N -c /var/lib/ntp/ntp.conf.dhcp -u 
117:126

PRI = 20 and NI = 0 in both cases.  If -N did anything NI would not be 0


** Bug watch added: bugs.ntp.org/ #1230
   http://bugs.ntp.org/show_bug.cgi?id=1230

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
I thought it might be because the setpriority() call was tried after
permissions were dropped but running as UID 0 doesn't change the
niceness as seen in ps output


$ (ps alx | head -1) ; (ps alx | grep ntpd) | grep -v grep
F   UID   PID  PPID PRI  NIVSZ   RSS WCHAN  STAT TTYTIME COMMAND
5 0 14085 1  20   0  32404  1976 poll_s Ss   ?  0:00 
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -N -c /var/lib/ntp/ntp.conf.dhcp

UID = 0, PRI = 20, NI = 0

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
When run with -N and -u 117:126

Aug 19 08:14:22 linux ntpd[14158]: sched_setscheduler(): Operation not permitted
Aug 19 08:14:22 linux ntpd[14158]: setpriority() error: Permission denied
Aug 19 08:14:22 linux ntpd[14158]: set_process_priority: No way found to 
improve our priority

Freaking apparmor

Aug 19 08:10:04 linux kernel: [ 3150.656384] type=1400
audit(1313755804.646:29): apparmor=DENIED operation=capable parent=1
profile=/usr/sbin/ntpd pid=14085 comm=ntpd capability=23
capname=sys_nice

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread Jamie Strandboge
This can be added to the apparmor profile to allow -N option to work:
  capability sys_nice,

Then run:
$ sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.ntpd

I'm preparing an upload for this policy change now.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread Jamie Strandboge
ntp (1:4.2.6.p2+dfsg-1ubuntu11) oneiric; urgency=low

  * debian/apparmor-profile: allow sys_nice for -N option to work. More
work is needed to make ntpd start niced, so not auto-closing the bug.
- LP: 229632

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
I switched AppArmor for ntpd into complain mode

$ sudo aa-complain /usr/sbin/ntpd
Setting /usr/sbin/ntpd to complain mode.

after that the ntpd -N flag started to work.

$ (ps alx | head -1) ; (ps alx | grep ntpd) | grep -v grep
F   UID   PID  PPID PRI  NIVSZ   RSS WCHAN  STAT TTYTIME COMMAND
5   117 14798 1 -100  -  38736  2096 poll_s Ss   ?  0:00 
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -N -c /var/lib/ntp/ntp.conf.dhcp -u 
117:126

PRI=1 NI=-100

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
Oops, didn't read Jamie's posts until just now, thanks Jamie!

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
Can an SRU for Lucid be done for the AppArmor modification too?

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
@Jamie given that the default ntpd configuration is to poll and the
stability of the clock affects the polling interval[1] I would strongly
suggest the default ntpd configuration be adjusted to run with the -N
option since it would cut down on the load of NTP servers if polling was
less frequent.  When this scales to the world sizes it does become an
issue.


1. In a nutshell when the clock is stable there is less need for ntpd to check 
to see the time on the upstream NTP server so it ratchets back the interval 
(decreases frequency) for polling by sleeping longer between checks. See ntp 
option maxpoll and minpoll in man ntp.conf to see the controls of the limits 
of the polling frequency range.  See What is the best polling Interval?
http://www.ntp.org/ntpfaq/NTP-s-algo.htm#Q-ALGO-POLL-BEST

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
The minimum sleep time between ntpd upstream requests is 64 seconds.
With 64000 clients an ntpd server must answer one thousand requests per
second.

If the client ntpd clocks are very stable they will ratchet back to one
request every 1024 seconds (about 17 minutes) so the same 6400 clients
would only make the server process 62.5 requests per second.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-19 Thread nutznboltz
Try with and with out ntpd -N option.

Use ntpq -p or ntpdc -c peers to view the polling interval. Both
reports have a poll column which is the sleep time in seconds between
requests being sent out over the network to the upstream NTP source.

The poll column will eventually change from 64 to 128 then 256 through
1024.  This change can take hours or even days to occur as the clock
stabilizes.

Without -N I haven't seen the polling interval get to 1024 on my
systems as process preemption destabilizes ntpd too much.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-16 Thread nutznboltz
@Weisi comment #7 is comment #6 in a patch file without line-breaks.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-16 Thread nutznboltz
I should probably submit this change to Debian not Canonical.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2011-08-15 Thread Weisi
I fully support this request.
Comment #6 is a good solution. Please note that due to the line-breaks the diff 
won't work without mangling.

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in Ubuntu.
https://bugs.launchpad.net/bugs/229632

Title:
  ntpd should run niced

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ntp/+bug/229632/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-05-20 Thread C de-Avillez
** Tags added: patch

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-10 Thread nutznboltz


** Patch added: Adds an option to /etc/default/ntp to make the priority level 
of ntpd configurable.
   http://launchpadlibrarian.net/39006866/ntp-priority.patch

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-10 Thread nutznboltz
We are limited a single NTP upstream source due to political reasons
outside our control and our Ubuntu ntpd loses sync periodically.  I
tried a number of solutions but they all failed.  When I tried setting
the ntpd server's nice value to negative eight it just works.  Clearly
the stability of ntpd is improved by reducing the number of cases in
which ntpd gets preempted by scheduling.

While troubleshooting this I started keeping logs with:

while true ; do ntpq -p | grep name-of-upstream-time-source | logger -t
ntpq -p daemon.info; done

A pair of log entries showing loss of sync looks like:

time   remote   refid  st t when 
poll reach   delay   offset  jitter
===
2010-02-08:2010-02-08T21:53:00-05:00 *-.xxx.x 128.59.39.48  2 u   12   
64  3770.5120.030   0.098
2010-02-08:2010-02-08T21:54:04-05:00  -.xxx.x 128.59.39.48  2 u   11   
64  3770.5120.030   0.342

The * in the first entry indicates that the local Ubuntu host was
synchronized to the remote host.  The second entry does not contain the
* since synchronization was lost.

By changing the nicelevel of the ntpd server process to negative eight
the logs no longer show any loss of synchronization.

See also http://ubuntuforums.org/showthread.php?p=8801540

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-10 Thread nutznboltz
Edit:

while true ; do ntpq -p | grep name-of-upstream-time-source | logger -t
ntpq -p daemon.info; sleep 64; done

the sleep 64 was missing.

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-10 Thread nutznboltz
Scheduler preemption of ntpd causes the time on other systems to appear
unstable since measurements are ruined if preemption occurs during them.

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-09 Thread nutznboltz
You can edit your defaults file to run ntpd at maximum priority:

--- /etc/default/ntp~   2009-12-04 13:07:15.0 -0500
+++ /etc/default/ntp2010-02-09 17:56:07.0 -0500
@@ -1 +1 @@
-NTPD_OPTS='-g'
+NTPD_OPTS='-g -N'

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-09 Thread nutznboltz
Actually the -N argument does nothing.

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs


[Bug 229632] Re: ntpd should run niced

2010-02-09 Thread nutznboltz
Hacking the startup script seems to be the best temporary fix.

-- default-intrepid-ntp-init-script 2010-02-09 15:01:43.255277872 -0500
+++ /etc/init.d/ntp 2010-02-09 15:02:48.0 -0500
@@ -57,7 +57,7 @@
exit 1
fi
lock_ntpdate
-   start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE 
--startas $DAEMON -- -p $PIDFILE -u $UGID $NTPD_OPTS
+   start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE 
--startas $DAEMON --nicelevel -8 -- -p $PIDFILE -u $UGID $NTPD_OPTS
status=$?
unlock_ntpdate
log_end_msg $status

-- 
ntpd should run niced
https://bugs.launchpad.net/bugs/229632
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to ntp in ubuntu.

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs