Subject: "tickadj" is too large on NetBSD
To: None <tech-kern@netbsd.org>
From: Frederick Bruckman <fb@enteract.com>
List: tech-kern
Date: 05/29/2000 11:51:20
Many (all?) other OS's with the NTP precision kernel timekeeping set
tickadj to 5 uS with a 10 mS clock; we're setting it to 40. In my
experiments (on i386), the lower number gives a client the opportunity
to get within a few milliseconds of an NTP server on the LAN, if the
network is quiet and the box's are not busy, even without the
nanosecond resolution. (I don't have any reference clocks.)

I used to play with the "tickadj" binary, but the word is that it's to
go away. It's not even installed on current, (nor should it be).

So I propose to make tickadj the smallest integer >= tick/2000, and
moreover to make them both configurable at compile time, as below.
An alternate calculation would be '((HZ + 499) / HZ)'.

I tried to defopt it -- putting TICK and TICKADJ in "opt_ntp.h", and
including "opt_ntp.h" in param.c -- without sucess. In that case, what
happens after editing the kernel config, running "config" and
rebuilding, is that the change shows up in "sysctl kern.clockrate",
but "ntpd" doesn't see it! The patch below should be good enough,
(IMO) because if 5 uS turns out to be too small for certain machines,
(they'll never sync), it should probably be increased back for the
whole port.


Index: param.c
===================================================================
RCS file: /cvsroot/syssrc/sys/conf/param.c,v
retrieving revision 1.35
diff -c -r1.35 param.c
*** param.c	2000/04/15 16:49:35	1.35
--- param.c	2000/05/29 16:41:23
***************
*** 93,105 ****
  #define	HZ 100
  #endif
  
  #ifndef MAXFILES
  #define	MAXFILES	(3 * (NPROC + MAXUSERS) + 80)
  #endif
  
  int	hz = HZ;
! int	tick = 1000000 / HZ;
! int	tickadj = 240000 / (60 * HZ);		/* can adjust 240ms in 60s */
  int	rtc_offset = RTC_OFFSET;
  int	maxproc = NPROC;
  int	desiredvnodes = NVNODE;
--- 93,113 ----
  #define	HZ 100
  #endif
  
+ #ifndef TICK
+ #define	TICK		(1000000 / HZ)
+ #endif
+ 
+ #ifndef TICKADJ
+ #define	TICKADJ		((TICK + 1999) / 2000)
+ #endif
+ 
  #ifndef MAXFILES
  #define	MAXFILES	(3 * (NPROC + MAXUSERS) + 80)
  #endif
  
  int	hz = HZ;
! int	tick = TICK;
! int	tickadj = TICKADJ;
  int	rtc_offset = RTC_OFFSET;
  int	maxproc = NPROC;
  int	desiredvnodes = NVNODE;