Cleanups for 4.4BSD-Lite
[unix-history] / usr / src / sys / kern / kern_clock.c
index f021224..237cc30 100644 (file)
-/*     kern_clock.c    4.14    %G%     */
-
-#include "../h/param.h"
-#include "../h/systm.h"
-#include "../h/dk.h"
-#include "../h/callout.h"
-#include "../h/seg.h"
-#include "../h/dir.h"
-#include "../h/user.h"
-#include "../h/proc.h"
-#include "../h/reg.h"
-#include "../h/psl.h"
-#include "../h/vm.h"
-#include "../h/buf.h"
-#include "../h/text.h"
-#include "../h/vlimit.h"
-#include "../h/mtpr.h"
-#include "../h/clock.h"
-#include "../h/cpu.h"
-
-#include "dh.h"
-#include "dz.h"
-
-#define        SCHMAG  9/10
+/*-
+ * Copyright (c) 1982, 1986, 1991, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)kern_clock.c        8.2 (Berkeley) %G%
+ */
 
 
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/dkstat.h>
+#include <sys/callout.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/resourcevar.h>
+
+#include <machine/cpu.h>
+
+#ifdef GPROF
+#include <sys/gmon.h>
+#endif
+
+#define ADJTIME                /* For now... */
+#define        ADJ_TICK 1000
+int    adjtimedelta;
 
 /*
 
 /*
- * Hardclock is called straight from
- * the real time clock interrupt.
- * We limit the work we do at real clock interrupt time to:
- *     reloading clock
- *     decrementing time to callouts
- *     recording cpu time usage
- *     modifying priority of current process
- *     arrange for soft clock interrupt
- *     kernel pc profiling
+ * Clock handling routines.
+ *
+ * This code is written to operate with two timers that run independently of
+ * each other.  The main clock, running hz times per second, is used to keep
+ * track of real time.  The second timer handles kernel and user profiling,
+ * and does resource use estimation.  If the second timer is programmable,
+ * it is randomized to avoid aliasing between the two clocks.  For example,
+ * the randomization prevents an adversary from always giving up the cpu
+ * just before its quantum expires.  Otherwise, it would never accumulate
+ * cpu ticks.  The mean frequency of the second timer is stathz.
+ *
+ * If no second timer exists, stathz will be zero; in this case we drive
+ * profiling and statistics off the main clock.  This WILL NOT be accurate;
+ * do not do it unless absolutely necessary.
  *
  *
- * At softclock interrupt time we:
- *     implement callouts
- *     maintain date
- *     lightning bolt wakeup (every second)
- *     alarm clock signals
- *     jab the scheduler
+ * The statistics clock may (or may not) be run at a higher rate while
+ * profiling.  This profile clock runs at profhz.  We require that profhz
+ * be an integral multiple of stathz.
  *
  *
- * On the vax softclock interrupts are implemented by
- * software interrupts.  Note that we may have multiple softclock
- * interrupts compressed into one (due to excessive interrupt load),
- * but that hardclock interrupts should never be lost.
+ * If the statistics clock is running fast, it must be divided by the ratio
+ * profhz/stathz for statistics.  (For profiling, every tick counts.)
  */
 
  */
 
-/*ARGSUSED*/
-hardclock(pc, ps)
-       caddr_t pc;
+/*
+ * TODO:
+ *     allocate more timeout table slots when table overflows.
+ */
+
+/*
+ * Bump a timeval by a small number of usec's.
+ */
+#define BUMPTIME(t, usec) { \
+       register volatile struct timeval *tp = (t); \
+       register long us; \
+ \
+       tp->tv_usec = us = tp->tv_usec + (usec); \
+       if (us >= 1000000) { \
+               tp->tv_usec = us - 1000000; \
+               tp->tv_sec++; \
+       } \
+}
+
+int    stathz;
+int    profhz;
+int    profprocs;
+int    ticks;
+static int psdiv, pscnt;       /* prof => stat divider */
+int    psratio;                /* ratio: prof / stat */
+
+volatile struct        timeval time;
+volatile struct        timeval mono_time;
+
+/*
+ * Initialize clock frequencies and start both clocks running.
+ */
+void
+initclocks()
 {
 {
-       register struct callout *p1;
-       register struct proc *pp;
-       register int s, cpstate;
+       register int i;
 
        /*
 
        /*
-        * reprime clock
+        * Set divisors to 1 (normal case) and let the machine-specific
+        * code do its bit.
         */
         */
-       clkreld();
+       psdiv = pscnt = 1;
+       cpu_initclocks();
 
        /*
 
        /*
-        * update callout times
+        * Compute profhz/stathz, and fix profhz if needed.
         */
         */
-       if(callout[0].c_func == NULL)
-               goto out;
-       p1 = &callout[0];
-       while(p1->c_time<=0 && p1->c_func!=NULL)
-               p1++;
-       p1->c_time--;
-out:
+       i = stathz ? stathz : hz;
+       if (profhz == 0)
+               profhz = i;
+       psratio = profhz / i;
+}
+
+/*
+ * The real-time timer, interrupting hz times per second.
+ */
+void
+hardclock(frame)
+       register struct clockframe *frame;
+{
+       register struct callout *p1;
 
        /*
 
        /*
-        * Maintain iostat and per-process cpu statistics
+        * Update real-time timeout queue.
+        * At front of queue are some number of events which are ``due''.
+        * The time to these is <= 0 and if negative represents the
+        * number of ticks which have passed since it was supposed to happen.
+        * The rest of the q elements (times > 0) are events yet to happen,
+        * where the time for each is given as a delta from the previous.
+        * Decrementing just the first of these serves to decrement the time
+        * to all events.
         */
         */
-       if (!noproc) {
-               s = u.u_procp->p_rssize;
-               u.u_vm.vm_idsrss += s;
-               if (u.u_procp->p_textp) {
-                       register int xrss = u.u_procp->p_textp->x_rssize;
-
-                       s += xrss;
-                       u.u_vm.vm_ixrss += xrss;
-               }
-               if (s > u.u_vm.vm_maxrss)
-                       u.u_vm.vm_maxrss = s;
-               if ((u.u_vm.vm_utime+u.u_vm.vm_stime+1)/hz > u.u_limit[LIM_CPU]) {
-                       psignal(u.u_procp, SIGXCPU);
-                       if (u.u_limit[LIM_CPU] < INFINITY - 5)
-                               u.u_limit[LIM_CPU] += 5;
-               }
+       needsoft = 0;
+       for (p1 = calltodo.c_next; p1 != NULL; p1 = p1->c_next) {
+               if (--p1->c_time > 0)
+                       break;
+               if (p1->c_time == 0)
+                       break;
        }
        }
-       if (USERMODE(ps)) {
-               u.u_vm.vm_utime++;
-               if(u.u_procp->p_nice > NZERO)
-                       cpstate = CP_NICE;
-               else
-                       cpstate = CP_USER;
-       } else {
-               cpstate = CP_SYS;
-               if (noproc)
-                       cpstate = CP_IDLE;
-               else
-                       u.u_vm.vm_stime++;
+
+               /*
+                * Run current process's virtual and profile time, as needed.
+                */
+               pstats = p->p_stats;
+               if (CLKF_USERMODE(frame) &&
+                   timerisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
+                   itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0)
+                       psignal(p, SIGVTALRM);
+               if (timerisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
+                   itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0)
+                       psignal(p, SIGPROF);
        }
        }
-       cp_time[cpstate]++;
-       for (s = 0; s < DK_NDRIVE; s++)
-               if (dk_busy&(1<<s))
-                       dk_time[s]++;
-       if (!noproc) {
-               pp = u.u_procp;
-               pp->p_cpticks++;
-               if(++pp->p_cpu == 0)
-                       pp->p_cpu--;
-               if(pp->p_cpu % 16 == 0) {
-                       (void) setpri(pp);
-                       if (pp->p_pri >= PUSER)
-                               pp->p_pri = pp->p_usrpri;
+
+       /*
+        * If no separate statistics clock is available, run it from here.
+        */
+       if (stathz == 0)
+               statclock(frame);
+
+       /*
+        * Increment the time-of-day.  The increment is just ``tick'' unless
+        * we are still adjusting the clock; see adjtime().
+        */
+       ticks++;
+#ifdef ADJTIME
+       if (adjtimedelta == 0)
+               bumptime(&time, tick);
+       else {
+               if (adjtimedelta < 0) {
+                       bumptime(&time, tick-ADJ_TICK);
+                       adjtimedelta++;
+               } else {
+                       bumptime(&time, tick+ADJ_TICK);
+                       adjtimedelta--;
                }
        }
                }
        }
-       ++lbolt;
-#if VAX780
-       if (cpu == VAX_780 && !BASEPRI(ps))
-               unhang();
+#else
+       if (timedelta == 0)
+               delta = tick;
+       else {
+               delta = tick + tickdelta;
+               timedelta -= tickdelta;
+       }
+       BUMPTIME(&time, delta);
+       BUMPTIME(&mono_time, delta);
+
+       /*
+        * Process callouts at a very low cpu priority, so we don't keep the
+        * relatively high clock interrupt priority any longer than necessary.
+        */
 #endif
        setsoftclock();
 }
 
 /*
 #endif
        setsoftclock();
 }
 
 /*
- * Constant for decay filter for cpu usage.
+ * Software (low priority) clock interrupt.
+ * Run periodic events from timeout queue.
  */
  */
-double ccpu = 0.95122942450071400909;          /* exp(-1/20) */
+/*ARGSUSED*/
+void
+softclock()
+{
+       register struct callout *c;
+       register void *arg;
+       register void (*func) __P((void *));
+       register int s;
+
+       s = splhigh();
+       while ((c = calltodo.c_next) != NULL && c->c_time <= 0) {
+               func = c->c_func;
+               arg = c->c_arg;
+               calltodo.c_next = c->c_next;
+               c->c_next = callfree;
+               callfree = c;
+               splx(s);
+               (*func)(arg);
+               (void) splhigh();
+       }
+       splx(s);
+}
 
 /*
 
 /*
- * Software clock interrupt.
- * This routine is blocked by spl1(),
- * which doesn't block device interrupts!
+ * timeout --
+ *     Execute a function after a specified length of time.
+ *
+ * untimeout --
+ *     Cancel previous timeout function call.
+ *
+ *     See AT&T BCI Driver Reference Manual for specification.  This
+ *     implementation differs from that one in that no identification
+ *     value is returned from timeout, rather, the original arguments
+ *     to timeout are used to identify entries for untimeout.
  */
  */
-/*ARGSUSED*/
-softclock(pc, ps)
-       caddr_t pc;
+void
+timeout(ftn, arg, ticks)
+       void (*ftn) __P((void *));
+       void *arg;
+       register int ticks;
 {
 {
-       register struct callout *p1, *p2;
-       register struct proc *pp;
-       register int a, s;
+       register struct callout *new, *p, *t;
+       register int s;
+
+       if (ticks <= 0)
+               ticks = 1;
+
+       /* Lock out the clock. */
+       s = splhigh();
+
+       /* Fill in the next free callout structure. */
+       if (callfree == NULL)
+               panic("timeout table full");
+       new = callfree;
+       callfree = new->c_next;
+       new->c_arg = arg;
+       new->c_func = ftn;
 
        /*
 
        /*
-        * callout
+        * The time for each event is stored as a difference from the time
+        * of the previous event on the queue.  Walk the queue, correcting
+        * the ticks argument for queue entries passed.  Correct the ticks
+        * value for the queue entry immediately after the insertion point
+        * as well.
         */
         */
-       if(callout[0].c_time <= 0) {
-               p1 = &callout[0];
-               while(p1->c_func != 0 && p1->c_time <= 0) {
-                       (*p1->c_func)(p1->c_arg);
-                       p1++;
-               }
-               p2 = &callout[0];
-               while(p2->c_func = p1->c_func) {
-                       p2->c_time = p1->c_time;
-                       p2->c_arg = p1->c_arg;
-                       p1++;
-                       p2++;
+       for (p = &calltodo;
+           (t = p->c_next) != NULL && ticks > t->c_time; p = t)
+               ticks -= t->c_time;
+       new->c_time = ticks;
+       if (t != NULL)
+               t->c_time -= ticks;
+
+       /* Insert the new entry into the queue. */
+       p->c_next = new;
+       new->c_next = t;
+       splx(s);
+}
+
+void
+untimeout(ftn, arg)
+       void (*ftn) __P((void *));
+       void *arg;
+{
+       register struct callout *p, *t;
+       register int s;
+
+       s = splhigh();
+       for (p = &calltodo; (t = p->c_next) != NULL; p = t)
+               if (t->c_func == ftn && t->c_arg == arg) {
+                       /* Increment next entry's tick count. */
+                       if (t->c_next && t->c_time > 0)
+                               t->c_next->c_time += t->c_time;
+
+                       /* Move entry from callout queue to callfree queue. */
+                       p->c_next = t->c_next;
+                       t->c_next = callfree;
+                       callfree = t;
+                       break;
                }
                }
-       }
+       splx(s);
+}
 
 
-       /*
-        * Drain silos.
-        */
-#if NDH > 0
-       s = spl5(); dhtimer(); splx(s);
-#endif
-#if NDZ > 0
-       s = spl5(); dztimer(); splx(s);
-#endif
+/*
+ * Compute number of hz until specified time.  Used to
+ * compute third argument to timeout() from an absolute time.
+ */
+int
+hzto(tv)
+       struct timeval *tv;
+{
+       register long ticks, sec;
+       int s;
 
        /*
 
        /*
-        * If idling and processes are waiting to swap in,
-        * check on them.
+        * If number of milliseconds will fit in 32 bit arithmetic,
+        * then compute number of milliseconds to time and scale to
+        * ticks.  Otherwise just compute number of hz in time, rounding
+        * times greater than representible to maximum value.
+        *
+        * Delta times less than 25 days can be computed ``exactly''.
+        * Maximum value for any timeout in 10ms ticks is 250 days.
         */
         */
-       if (noproc && runin) {
-               runin = 0;
-               wakeup((caddr_t)&runin);
+       s = splhigh();
+       sec = tv->tv_sec - time.tv_sec;
+       if (sec <= 0x7fffffff / 1000 - 1000)
+               ticks = ((tv->tv_sec - time.tv_sec) * 1000 +
+                       (tv->tv_usec - time.tv_usec) / 1000) / (tick / 1000);
+       else if (sec <= 0x7fffffff / hz)
+               ticks = sec * hz;
+       else
+               ticks = 0x7fffffff;
+       splx(s);
+       return (ticks);
+}
+
+/*
+ * Start profiling on a process.
+ *
+ * Kernel profiling passes proc0 which never exits and hence
+ * keeps the profile clock running constantly.
+ */
+void
+startprofclock(p)
+       register struct proc *p;
+{
+       int s;
+
+       if ((p->p_flag & SPROFIL) == 0) {
+               p->p_flag |= SPROFIL;
+               if (++profprocs == 1 && stathz != 0) {
+                       s = splstatclock();
+                       psdiv = pscnt = psratio;
+                       setstatclockrate(profhz);
+                       splx(s);
+               }
        }
        }
+}
 
 
-       /*
-        * Run paging daemon and reschedule every 1/4 sec.
-        */
-       if (lbolt % (hz/4) == 0) {
-               vmpago();
-               runrun++;
-               aston();
+/*
+ * Stop profiling on a process.
+ */
+void
+stopprofclock(p)
+       register struct proc *p;
+{
+       int s;
+
+       if (p->p_flag & SPROFIL) {
+               p->p_flag &= ~SPROFIL;
+               if (--profprocs == 0 && stathz != 0) {
+                       s = splstatclock();
+                       psdiv = pscnt = 1;
+                       setstatclockrate(stathz);
+                       splx(s);
+               }
        }
        }
+}
 
 
-       /*
-        * Lightning bolt every second:
-        *      sleep timeouts
-        *      process priority recomputation
-        *      process %cpu averaging
-        *      virtual memory metering
-        *      kick swapper if processes want in
-        */
-       if (lbolt >= hz) {
-               if (BASEPRI(ps))
+int    dk_ndrive = DK_NDRIVE;
+
+/*
+ * Statistics clock.  Grab profile sample, and if divider reaches 0,
+ * do process and kernel statistics.
+ */
+void
+statclock(frame)
+       register struct clockframe *frame;
+{
+#ifdef GPROF
+       register struct gmonparam *g;
+#endif
+       register struct proc *p;
+       register int i;
+
+       if (CLKF_USERMODE(frame)) {
+               p = curproc;
+               if (p->p_flag & SPROFIL)
+                       addupc_intr(p, CLKF_PC(frame), 1);
+               if (--pscnt > 0)
                        return;
                        return;
-               lbolt -= hz;
-               ++time;
-               wakeup((caddr_t)&lbolt);
-               for(pp = proc; pp < procNPROC; pp++)
-               if (pp->p_stat && pp->p_stat!=SZOMB) {
-                       if(pp->p_time != 127)
-                               pp->p_time++;
-                       if(pp->p_clktim)
-                               if(--pp->p_clktim == 0)
-                                       if (pp->p_flag & STIMO) {
-                                               s = spl6();
-                                               switch (pp->p_stat) {
-
-                                               case SSLEEP:
-                                                       setrun(pp);
-                                                       break;
-
-                                               case SSTOP:
-                                                       unsleep(pp);
-                                                       break;
-                                               }
-                                               pp->p_flag &= ~STIMO;
-                                               splx(s);
-                                       } else
-                                               psignal(pp, SIGALRM);
-                       if(pp->p_stat==SSLEEP||pp->p_stat==SSTOP)
-                               if (pp->p_slptime != 127)
-                                       pp->p_slptime++;
-                       if (pp->p_flag&SLOAD)
-                               pp->p_pctcpu = ccpu * pp->p_pctcpu +
-                                   (1.0 - ccpu) * (pp->p_cpticks/(float)hz);
-                       pp->p_cpticks = 0;
-                       a = (pp->p_cpu & 0377)*SCHMAG + pp->p_nice - NZERO;
-                       if(a < 0)
-                               a = 0;
-                       if(a > 255)
-                               a = 255;
-                       pp->p_cpu = a;
-                       (void) setpri(pp);
-                       s = spl6();
-                       if(pp->p_pri >= PUSER) {
-                               if ((pp != u.u_procp || noproc) &&
-                                   pp->p_stat == SRUN &&
-                                   (pp->p_flag & SLOAD) &&
-                                   pp->p_pri != pp->p_usrpri) {
-                                       remrq(pp);
-                                       pp->p_pri = pp->p_usrpri;
-                                       setrq(pp);
-                               } else
-                                       pp->p_pri = pp->p_usrpri;
+               /*
+                * Came from user mode; CPU was in user state.
+                * If this process is being profiled record the tick.
+                */
+               p->p_uticks++;
+               if (p->p_nice > NZERO)
+                       cp_time[CP_NICE]++;
+               else
+                       cp_time[CP_USER]++;
+       } else {
+#ifdef GPROF
+               /*
+                * Kernel statistics are just like addupc_intr, only easier.
+                */
+               g = &_gmonparam;
+               if (g->state == GMON_PROF_ON) {
+                       i = CLKF_PC(frame) - g->lowpc;
+                       if (i < g->textsize) {
+                               i /= HISTFRACTION * sizeof(*g->kcount);
+                               g->kcount[i]++;
                        }
                        }
-                       splx(s);
-               }
-               vmmeter();
-               if(runin!=0) {
-                       runin = 0;
-                       wakeup((caddr_t)&runin);
                }
                }
+#endif
+               if (--pscnt > 0)
+                       return;
                /*
                /*
-                * If there are pages that have been cleaned, 
-                * jolt the pageout daemon to process them.
-                * We do this here so that these pages will be
-                * freed if there is an abundance of memory and the
-                * daemon would not be awakened otherwise.
+                * Came from kernel mode, so we were:
+                * - handling an interrupt,
+                * - doing syscall or trap work on behalf of the current
+                *   user process, or
+                * - spinning in the idle loop.
+                * Whichever it is, charge the time as appropriate.
+                * Note that we charge interrupts to the current process,
+                * regardless of whether they are ``for'' that process,
+                * so that we know how much of its real time was spent
+                * in ``non-process'' (i.e., interrupt) work.
                 */
                 */
-               if (bclnlist != NULL)
-                       wakeup((caddr_t)&proc[2]);
-               if (USERMODE(ps)) {
-                       pp = u.u_procp;
-                       if (pp->p_uid)
-                               if (pp->p_nice == NZERO && u.u_vm.vm_utime > 600 * hz)
-                                       pp->p_nice = NZERO+4;
-                       (void) setpri(pp);
-                       pp->p_pri = pp->p_usrpri;
-               }
+               p = curproc;
+               if (CLKF_INTR(frame)) {
+                       if (p != NULL)
+                               p->p_iticks++;
+                       cp_time[CP_INTR]++;
+               } else if (p != NULL) {
+                       p->p_sticks++;
+                       cp_time[CP_SYS]++;
+               } else
+                       cp_time[CP_IDLE]++;
        }
        }
-       if (USERMODE(ps) && u.u_prof.pr_scale) {
-               u.u_procp->p_flag |= SOWEUPC;
-               aston();
+       pscnt = psdiv;
+
+       /*
+        * We maintain statistics shown by user-level statistics
+        * programs:  the amount of time in each cpu state, and
+        * the amount of time each of DK_NDRIVE ``drives'' is busy.
+        *
+        * XXX  should either run linked list of drives, or (better)
+        *      grab timestamps in the start & done code.
+        */
+       for (i = 0; i < DK_NDRIVE; i++)
+               if (dk_busy & (1 << i))
+                       dk_time[i]++;
+
+       /*
+        * We adjust the priority of the current process.
+        * The priority of a process gets worse as it accumulates
+        * CPU time.  The cpu usage estimator (p_cpu) is increased here
+        * and the formula for computing priorities (in kern_synch.c)
+        * will compute a different value each time the p_cpu increases
+        * by 4.  The cpu usage estimator ramps up quite quickly when
+        * the process is running (linearly), and decays away
+        * exponentially, at a rate which is proportionally slower
+        * when the system is busy.  The basic principal is that the
+        * system will 90% forget that a process used a lot of CPU
+        * time in 5*loadav seconds.  This causes the system to favor
+        * processes which haven't run much recently, and to
+        * round-robin among other processes.
+        */
+       if (p != NULL) {
+               p->p_cpticks++;
+               if (++p->p_cpu == 0)
+                       p->p_cpu--;
+               if ((p->p_cpu & 3) == 0) {
+                       resetpriority(p);
+                       if (p->p_pri >= PUSER)
+                               p->p_pri = p->p_usrpri;
+               }
        }
 }
 
 /*
        }
 }
 
 /*
- * timeout is called to arrange that
- * fun(arg) is called in tim/hz seconds.
- * An entry is sorted into the callout
- * structure. The time in each structure
- * entry is the number of hz's more
- * than the previous entry.
- * In this way, decrementing the
- * first entry has the effect of
- * updating all entries.
- *
- * The panic is there because there is nothing
- * intelligent to be done if an entry won't fit.
+ * Return information about system clocks.
  */
  */
-timeout(fun, arg, tim)
-       int (*fun)();
-       caddr_t arg;
+sysctl_clockrate(where, sizep)
+       register char *where;
+       size_t *sizep;
 {
 {
-       register struct callout *p1, *p2, *p3;
-       register int t;
-       int s;
+       struct clockinfo clkinfo;
 
 
-       t = tim;
-       p1 = &callout[0];
-       s = spl7();
-       while(p1->c_func != 0 && p1->c_time <= t) {
-               t -= p1->c_time;
-               p1++;
-       }
-       p1->c_time -= t;
-       p2 = p1;
-       p3 = callout+(ncallout-2);
-       while(p2->c_func != 0) {
-               if (p2 >= p3)
-                       panic("timeout");
-               p2++;
-       }
-       while(p2 >= p1) {
-               (p2+1)->c_time = p2->c_time;
-               (p2+1)->c_func = p2->c_func;
-               (p2+1)->c_arg = p2->c_arg;
-               p2--;
-       }
-       p1->c_time = t;
-       p1->c_func = fun;
-       p1->c_arg = arg;
-       splx(s);
+       /*
+        * Construct clockinfo structure.
+        */
+       clkinfo.hz = hz;
+       clkinfo.tick = tick;
+       clkinfo.profhz = profhz;
+       clkinfo.stathz = stathz ? stathz : hz;
+       return (sysctl_rdstruct(where, sizep, NULL, &clkinfo, sizeof(clkinfo)));
 }
 }