1*2b15cb3dSCy Schubert<HTML> 2*2b15cb3dSCy Schubert<HEAD> 3*2b15cb3dSCy Schubert<TITLE>Solaris hints and kinks</title><link href="scripts/style.css" type="text/css" rel="stylesheet"> 4*2b15cb3dSCy Schubert 5*2b15cb3dSCy Schubert</HEAD> 6*2b15cb3dSCy Schubert<BODY> 7*2b15cb3dSCy SchubertInformation on compiling and executing ntpd under Solaris. 8*2b15cb3dSCy Schubert<BR> 9*2b15cb3dSCy Schubert<p>Last update: 10*2b15cb3dSCy Schubert <!-- #BeginDate format:En2m -->27-Jan-2014 05:31<!-- #EndDate --> 11*2b15cb3dSCy Schubert UTC, 12*2b15cb3dSCy SchubertJohn Hawkinson, 13*2b15cb3dSCy Schubert<! -- This is deliberately not a mailto -- > <jhawk@MIT.EDU> 14*2b15cb3dSCy Schubert</p> 15*2b15cb3dSCy Schubert<P> 16*2b15cb3dSCy SchubertIf you're not running Solaris 2.5.1 or later, it is likely 17*2b15cb3dSCy Schubertthat you will have problems; upgrading would be a really good plan. 18*2b15cb3dSCy Schubert<P> 19*2b15cb3dSCy Schubert<H3>All Solaris versions</H3> 20*2b15cb3dSCy Schubert<P> 21*2b15cb3dSCy Schubert We have a report that says starting with Solaris 2.6 we should leave 22*2b15cb3dSCy Schubert <I>dosynctodr</I> alone. 23*2b15cb3dSCy Schubert <A HREF="solaris-dosynctodr.html">Here is the report</A>. 24*2b15cb3dSCy Schubert<P> 25*2b15cb3dSCy SchubertProper operation of ntp under Solaris may require setting the kernel 26*2b15cb3dSCy Schubertvariable <I>dosynctodr</I> to zero (meaning "do not synchronize the clock 27*2b15cb3dSCy Schubertto the hardware time-of-day clock"). This can be done with the 28*2b15cb3dSCy Schuberttickadj utility: 29*2b15cb3dSCy Schubert<BLOCKQUOTE><TT> 30*2b15cb3dSCy Schuberttickadj -s 31*2b15cb3dSCy Schubert</TT></BLOCKQUOTE> 32*2b15cb3dSCy SchubertIf you prefer, it can also be done with the native Solaris kernel debugger: 33*2b15cb3dSCy Schubert<BLOCKQUOTE><TT> 34*2b15cb3dSCy Schubertecho dosynctodr/W0 | adb -k -w /dev/ksyms /dev/mem 35*2b15cb3dSCy Schubert</BLOCKQUOTE></TT> 36*2b15cb3dSCy Schubert<P> 37*2b15cb3dSCy SchubertOr, it can also be set by adding a line to /etc/system: 38*2b15cb3dSCy Schubert<BLOCKQUOTE><TT> 39*2b15cb3dSCy Schubertset dosynctodr = 0 40*2b15cb3dSCy Schubert</BLOCKQUOTE></TT> 41*2b15cb3dSCy Schubert<P> 42*2b15cb3dSCy SchubertInstead of the <I>tick</I> kernel variable, which many operating 43*2b15cb3dSCy Schubertsystems use to control microseconds added to the system time every 44*2b15cb3dSCy Schubertclock tick (c.f. <A HREF="#frequency_tolerance">Dealing 45*2b15cb3dSCy Schubertwith Frequency Tolerance Violations</A>), Solaris has the variables 46*2b15cb3dSCy Schubert<I>nsec_per_tick</I> and <I>usec_per_tick</I>. 47*2b15cb3dSCy Schubert<P> 48*2b15cb3dSCy Schubert<I>nsec_per_tick</I> and <I>usec_per_tick</I> control the number of 49*2b15cb3dSCy Schubertnanoseconds and microseconds, respectively, added to the system clock 50*2b15cb3dSCy Schuberteach clock interrupt. Enterprising souls may set these based on 51*2b15cb3dSCy Schubertinformation collected by ntpd in the <CODE>/etc/ntp.drift</CODE> file 52*2b15cb3dSCy Schubertto correct for individual hardware variations. 53*2b15cb3dSCy Schubert<P> 54*2b15cb3dSCy SchubertOn UltraSPARC systems, <I>nsec_per_tick</I> and <I>usec_per_tick</I> 55*2b15cb3dSCy Schubertare ignored in favor of the <I>cpu_tick_freq</I> variable, which 56*2b15cb3dSCy Schubertshould be automatically be determined by the PROM in an accurate 57*2b15cb3dSCy Schubertfashion. 58*2b15cb3dSCy Schubert<P> 59*2b15cb3dSCy SchubertIn general, the same ntp binaries should not be used across multiple 60*2b15cb3dSCy Schubertoperating system releases. There is enough variation in the core operating 61*2b15cb3dSCy Schubertsystem support for timekeeping that a rebuild of ntpd for the idiosyncracies 62*2b15cb3dSCy Schubertof your specific operating system version is advisable. 63*2b15cb3dSCy Schubert<P> 64*2b15cb3dSCy SchubertIt is recommended that ntp be started via a script like <A 65*2b15cb3dSCy SchubertHREF="solaris.xtra.S99ntpd">this one</A>, installed in 66*2b15cb3dSCy Schubert<CODE>/etc/init.d/ntpd</CODE> with a symbol link from 67*2b15cb3dSCy Schubert<CODE>/etc/rc2.d/S99ntpd</CODE>. 68*2b15cb3dSCy Schubert 69*2b15cb3dSCy Schubert<a id="frequency_tolerance" /> 70*2b15cb3dSCy Schubert<h4>Dealing with Frequency Tolerance Violations (<tt>tickadj</tt> and 71*2b15cb3dSCy SchubertFriends)</h4> 72*2b15cb3dSCy Schubert The NTP Version 3 specification RFC-1305 calls for a maximum 73*2b15cb3dSCy Schubert oscillator frequency tolerance of +-100 parts-per-million (PPM), which is 74*2b15cb3dSCy Schubertrepresentative of those components suitable for use in relatively 75*2b15cb3dSCy Schubertinexpensive workstation platforms. For those platforms meeting this 76*2b15cb3dSCy Schuberttolerance, NTP will automatically compensate for the frequency errors of the 77*2b15cb3dSCy Schubertindividual oscillator and no further adjustments are required, either to the 78*2b15cb3dSCy Schubertconfiguration file or to various kernel variables. For the NTP Version 4 79*2b15cb3dSCy Schubertrelease, this tolerance has been increased to +-500 PPM. <p>However, in the 80*2b15cb3dSCy Schubertcase of certain notorious platforms, in particular Sun 4.1.1 systems, the 81*2b15cb3dSCy Schubertperformance can be improved by adjusting the values of certain kernel 82*2b15cb3dSCy Schubertvariables; in particular, <tt>tick</tt> and <tt>tickadj</tt>. The variable 83*2b15cb3dSCy Schubert<tt>tick</tt> is the increment in microseconds added to the system time on 84*2b15cb3dSCy Schuberteach interval- timer interrupt, while the variable <tt>tickadj</tt> is used 85*2b15cb3dSCy Schubertby the time adjustment code as a slew rate, in microseconds per tick. When 86*2b15cb3dSCy Schubertthe time is being adjusted via a call to the system routine 87*2b15cb3dSCy Schubert<tt>adjtime()</tt>, the kernel increases or reduces tick by <tt>tickadj</tt> 88*2b15cb3dSCy Schubertmicroseconds per tick until the specified adjustment has been 89*2b15cb3dSCy Schubertcompleted. Unfortunately, in most Unix implementations the tick increment 90*2b15cb3dSCy Schubertmust be either zero or plus/minus exactly <tt>tickadj</tt> microseconds, 91*2b15cb3dSCy Schubertmeaning that adjustments are truncated to be an integral multiple of 92*2b15cb3dSCy Schubert<tt>tickadj</tt> (this latter behaviour is a misfeature, and is the only 93*2b15cb3dSCy Schubertreason the <tt>tickadj</tt> code needs to concern itself with the internal 94*2b15cb3dSCy Schubertimplementation of <tt>tickadj</tt> at all). In addition, the stock Unix 95*2b15cb3dSCy Schubertimplementation considers it an error to request another adjustment before a 96*2b15cb3dSCy Schubertprior one has completed.</p> <p>Thus, to make very sure it avoids problems 97*2b15cb3dSCy Schubertrelated to the roundoff, the <tt>tickadj</tt> program can be used to adjust 98*2b15cb3dSCy Schubertthe values of <tt>tick</tt> and <tt>tickadj</tt>. This ensures that all 99*2b15cb3dSCy Schubertadjustments given to <tt>adjtime()</tt> are an even multiple of 100*2b15cb3dSCy Schubert<tt>tickadj</tt> microseconds and computes the largest adjustment that can 101*2b15cb3dSCy Schubertbe completed in the adjustment interval (using both the value of 102*2b15cb3dSCy Schubert<tt>tick</tt> and the value of <tt>tickadj</tt>) so it can avoid exceeding 103*2b15cb3dSCy Schubertthis limit. It is important to note that not all systems will allow 104*2b15cb3dSCy Schubertinspection or modification of kernel variables other than at system build 105*2b15cb3dSCy Schuberttime. It is also important to know that, with the current NTP tolerances, it 106*2b15cb3dSCy Schubertis rarely necessary to make these changes, but in many cases they will 107*2b15cb3dSCy Schubertsubstantially improve the general accuracy of the time service.</p> 108*2b15cb3dSCy Schubert<p>Unfortunately, the value of <tt>tickadj</tt> set by default is almost 109*2b15cb3dSCy Schubertalways too large for <tt>ntpd</tt>. NTP operates by continuously making 110*2b15cb3dSCy Schubertsmall adjustments to the clock, usually at one-second intervals. If 111*2b15cb3dSCy Schubert<tt>tickaj</tt> is set too large, the adjustments will disappear in the 112*2b15cb3dSCy Schubertroundoff; while, if <tt>tickadj</tt> is too small, NTP will have difficulty 113*2b15cb3dSCy Schubertif it needs to make an occasional large adjustment. While the daemon itself 114*2b15cb3dSCy Schubertwill read the kernel's values of these variables, it will not change the 115*2b15cb3dSCy Schubertvalues, even if they are unsuitable. You must do this yourself before the 116*2b15cb3dSCy Schubertdaemon is started using the <tt>tickadj</tt> program included in the 117*2b15cb3dSCy Schubert<tt>./util</tt> directory of the distribution. Note that the latter program 118*2b15cb3dSCy Schubertwill also compute an optimal value of <tt>tickadj</tt> for NTP use based on 119*2b15cb3dSCy Schubertthe kernel's value of <tt>tick</tt>.</p> <p>The <tt>tickadj</tt> program can 120*2b15cb3dSCy Schubertreset several other kernel variables if asked. It can change the value of 121*2b15cb3dSCy Schubert<tt>tick</tt> if asked. This is handy to compensate for kernel bugs which 122*2b15cb3dSCy Schubertcause the clock to run with a very large frequency error, as with SunOS 123*2b15cb3dSCy Schubert4.1.1 systems. It can also be used to set the value of the kernel 124*2b15cb3dSCy Schubert<tt>dosynctodr</tt> variable to zero. This variable controls whether to 125*2b15cb3dSCy Schubertsynchronize the system clock to the time-of-day clock, something you really 126*2b15cb3dSCy Schubertdon't want to be happen when <tt>ntpd</tt> is trying to keep it under 127*2b15cb3dSCy Schubertcontrol. In some systems, such as recent Sun Solaris kernels, the 128*2b15cb3dSCy Schubert<tt>dosynctodr</tt > variable is the only one that can be changed by the 129*2b15cb3dSCy Schubert<tt>tickadj</tt> program. In this and other modern kernels, it is not 130*2b15cb3dSCy Schubertnecessary to change the other variables in any case.</p> 131*2b15cb3dSCy Schubert 132*2b15cb3dSCy Schubert<p>We have a report that says starting with Solaris 2.6 we should leave 133*2b15cb3dSCy Schubert<i>dosynctodr</i> alone.</p> <p>In order to maintain reasonable correctness 134*2b15cb3dSCy Schubertbounds, as well as reasonably good accuracy with acceptable polling 135*2b15cb3dSCy Schubertintervals, <tt>ntpd</tt> will complain if the frequency error is greater 136*2b15cb3dSCy Schubertthan 500 PPM. For machines with a value of <tt>tick</tt> in the 10-ms range, 137*2b15cb3dSCy Schuberta change of one in the value of <tt>tick</tt> will change the frequency by 138*2b15cb3dSCy Schubertabout 100 PPM. In order to determine the value of <tt>tick</tt> for a 139*2b15cb3dSCy Schubertparticular CPU, disconnect the machine from all source s of time 140*2b15cb3dSCy Schubert(<tt>dosynctodr</tt> = 0) and record its actual time compared to an outside 141*2b15cb3dSCy Schubertsource (eyeball-and-wristwatch will do) over a day or more. Multiply the 142*2b15cb3dSCy Schuberttime change over the day by 0.116 and add or subtract the result to tick, 143*2b15cb3dSCy Schubertdepending on whether the CPU is fast or slow. An example call to 144*2b15cb3dSCy Schubert<tt>tickadj</tt> useful on SunOS 4.1.1 is:</p> 145*2b15cb3dSCy Schubert <pre> 146*2b15cb3dSCy Schubert <tt>tickadj</tt> -t 9999 -a 5 -s 147*2b15cb3dSCy Schubert</pre> 148*2b15cb3dSCy Schubertwhich sets tick 100 PPM fast, <tt>tickadj</tt> to 5 microseconds and turns 149*2b15cb3dSCy Schubertoff the clock/calendar chip fiddle. This line can be added to the <tt 150*2b15cb3dSCy Schubert>rc.local</tt> configuration file to automatically set the kernel variables 151*2b15cb3dSCy Schubertat boot time. <p>All this stuff about diddling kernel variables so the NTP 152*2b15cb3dSCy Schubertdaemon will work is really silly. If vendors would ship machines with clocks 153*2b15cb3dSCy Schubertthat kept reasonable time and would make their <tt>adjtime()</tt> system 154*2b15cb3dSCy Schubertcall apply the slew it is given exactly, independent of the value of 155*2b15cb3dSCy Schubert<tt>tickadj</tt>, all this could go away. This is in fact the case on many 156*2b15cb3dSCy Schubertcurrent Unix systems.</p> 157*2b15cb3dSCy Schubert 158*2b15cb3dSCy Schubert<H3>Solaris 2.6</H3> 159*2b15cb3dSCy Schubert<P> 160*2b15cb3dSCy SchubertSolaris 2.6 adds support for kernel PLL timekeeping, but breaks this 161*2b15cb3dSCy Schubertsupport in such a fashion that using it worse than not. This is <A 162*2b15cb3dSCy SchubertHREF="solaris.xtra.4095849"> SUN Bug ID 4095849</A>, and it is not yet 163*2b15cb3dSCy Schubertfixed as of June 1998. 164*2b15cb3dSCy Schubert<P> 165*2b15cb3dSCy Schubert<H3>Solaris 2.5 and 2.5.1</H3> 166*2b15cb3dSCy Schubert<P> 167*2b15cb3dSCy SchubertOn UltraSPARC systems, calculation of <I>cpu_tick_freq</I> is broken 168*2b15cb3dSCy Schubertsuch that values that are off by significant amounts may be used 169*2b15cb3dSCy Schubertinstead. This unfortunately means that ntpd may have severe problems 170*2b15cb3dSCy Schubertkeeping synchronization. This is <A HREF="solaris.xtra.4023118"> SUN Bug ID 171*2b15cb3dSCy Schubert4023118</A>. Bryan Cantrill <! -- <bmc@eng.sun.com> --> of Sun 172*2b15cb3dSCy Schubertposted <A HREF="solaris.xtra.patchfreq">patchfreq</A>, a workaround script, 173*2b15cb3dSCy Schubertto comp.protocols.time.ntp in March of 1997. 174*2b15cb3dSCy Schubert<P> 175*2b15cb3dSCy Schubert<HR> 176*2b15cb3dSCy Schubert<H2>OLD DATA</H2> 177*2b15cb3dSCy Schubert<STRONG>I can't vouch for the accuracy the information below this 178*2b15cb3dSCy Schubertrule. It may be significantly dated or incorrect.</STRONG> 179*2b15cb3dSCy Schubert<P> 180*2b15cb3dSCy Schubert<P> 181*2b15cb3dSCy Schubert<H3>Solaris 2.2</H3> 182*2b15cb3dSCy Schubert<P> 183*2b15cb3dSCy SchubertSolaris 2.2 and later contain completely re-written clock code to 184*2b15cb3dSCy Schubertprovide high resolution microsecond timers. A benefit of the 185*2b15cb3dSCy Schubertre-written clock code is that adjtime does not round off its 186*2b15cb3dSCy Schubertadjustments, so ntp does not have to compensate for this 187*2b15cb3dSCy Schubertrounding. Under Solaris 2.2 and later, ntp #define's 188*2b15cb3dSCy Schubert<CODE>ADJTIME_IS_ACCURATE</CODE>, and does not look for the <I>tickadj</I> 189*2b15cb3dSCy Schubertkernel variable. 190*2b15cb3dSCy Schubert<P> 191*2b15cb3dSCy Schubert<H3>Solaris 2.1</H3> 192*2b15cb3dSCy Schubert(This originally written by William L. Jones <jones@chpc.utexas.edu>) 193*2b15cb3dSCy Schubert<P> 194*2b15cb3dSCy SchubertSolaris 2.1 contains fairly traditional clock code, with <I>tick</I> 195*2b15cb3dSCy Schubertand <I>tickadj</I>. 196*2b15cb3dSCy Schubert<P> 197*2b15cb3dSCy SchubertSince settimeofday under Solaris 2.1 only sets the seconds part of timeval 198*2b15cb3dSCy Schubertcare must be used in starting xntpd. I suggest the following start 199*2b15cb3dSCy Schubertup script: 200*2b15cb3dSCy Schubert<BLOCKQUOTE><TT> 201*2b15cb3dSCy Schuberttickadj -s -a 1000 202*2b15cb3dSCy Schubert<BR>ntpdate -v server1 server2 203*2b15cb3dSCy Schubert<BR>sleep 20 204*2b15cb3dSCy Schubert<BR>ntpdate -v server1 server2 205*2b15cb3dSCy Schubert<BR>sleep 20 206*2b15cb3dSCy Schubert<BR>tickadj -a 200 207*2b15cb3dSCy Schubert<BR>xntpd 208*2b15cb3dSCy Schubert</TT></BLOCKQUOTE> 209*2b15cb3dSCy Schubert 210*2b15cb3dSCy SchubertThe first tickadj turns of the time of day clock and sets the tick 211*2b15cb3dSCy Schubertadjust value to 1 millisecond. This will insure that an adjtime value 212*2b15cb3dSCy Schubertof at most 2 seconds will complete in 20 seconds. 213*2b15cb3dSCy Schubert<P> 214*2b15cb3dSCy SchubertThe first ntpdate will set the time to within two seconds 215*2b15cb3dSCy Schubertusing settimeofday or it will adjust time using adjtime. 216*2b15cb3dSCy Schubert<P> 217*2b15cb3dSCy SchubertThe first sleep insures the adjtime has completed for the first ntpdate. 218*2b15cb3dSCy Schubert<P> 219*2b15cb3dSCy SchubertThe second ntpdate will use adjtime to set the time of day since the 220*2b15cb3dSCy Schubertclock should be within 2 seconds of the correct time. 221*2b15cb3dSCy Schubert<P> 222*2b15cb3dSCy SchubertThe second tickadj set the tick adjust system value to 5 microseconds. 223*2b15cb3dSCy Schubert<P> 224*2b15cb3dSCy SchubertThe second sleeps insure that adjtime will complete before starting 225*2b15cb3dSCy Schubertthe next xntpd. 226*2b15cb3dSCy Schubert<P> 227*2b15cb3dSCy SchubertI tried running with a tickadj of 5 microseconds with out much success. 228*2b15cb3dSCy Schubert200 microseconds seems to work well. 229*2b15cb3dSCy Schubert<P> 230*2b15cb3dSCy Schubert<HR> 231*2b15cb3dSCy SchubertPrior versions of this file had major text contributed by: 232*2b15cb3dSCy Schubert<MENU> 233*2b15cb3dSCy Schubert<LI>Denny Gentry <denny@eng.sun.com> 234*2b15cb3dSCy Schubert</MENU> 235*2b15cb3dSCy Schubert<BODY> 236*2b15cb3dSCy Schubert</HTML> 237