Print this page
OS-2366 ddi_periodic_add(9F) is entirely rubbish (MORE)


  47 #include <sys/debug.h>
  48 #include <sys/vtrace.h>
  49 #include <sys/spl.h>
  50 #include <sys/atomic.h>
  51 #include <sys/dumphdr.h>
  52 #include <sys/archsystm.h>
  53 #include <sys/fs/swapnode.h>
  54 #include <sys/panic.h>
  55 #include <sys/disp.h>
  56 #include <sys/msacct.h>
  57 #include <sys/mem_cage.h>
  58 
  59 #include <vm/page.h>
  60 #include <vm/anon.h>
  61 #include <vm/rm.h>
  62 #include <sys/cyclic.h>
  63 #include <sys/cpupart.h>
  64 #include <sys/rctl.h>
  65 #include <sys/task.h>
  66 #include <sys/sdt.h>
  67 #include <sys/ddi_timer.h>
  68 #include <sys/random.h>
  69 #include <sys/modctl.h>
  70 #include <sys/zone.h>
  71 
  72 /*
  73  * for NTP support
  74  */
  75 #include <sys/timex.h>
  76 #include <sys/inttypes.h>
  77 
  78 #include <sys/sunddi.h>
  79 #include <sys/clock_impl.h>
  80 
  81 /*
  82  * clock() is called straight from the clock cyclic; see clock_init().
  83  *
  84  * Functions:
  85  *      reprime clock
  86  *      maintain date
  87  *      jab the scheduler


 299 /*
 300  * Cache aligned, per CPU structure with lbolt usage statistics.
 301  */
 302 static lbolt_cpu_t *lb_cpu;
 303 
 304 /*
 305  * Single, cache aligned, structure with all the information required by
 306  * the lbolt implementation.
 307  */
 308 lbolt_info_t *lb_info;
 309 
 310 
 311 int one_sec = 1; /* turned on once every second */
 312 static int fsflushcnt;  /* counter for t_fsflushr */
 313 int     dosynctodr = 1; /* patchable; enable/disable sync to TOD chip */
 314 int     tod_needsync = 0;       /* need to sync tod chip with software time */
 315 static int tod_broken = 0;      /* clock chip doesn't work */
 316 time_t  boot_time = 0;          /* Boot time in seconds since 1970 */
 317 cyclic_id_t clock_cyclic;       /* clock()'s cyclic_id */
 318 cyclic_id_t deadman_cyclic;     /* deadman()'s cyclic_id */
 319 cyclic_id_t ddi_timer_cyclic;   /* cyclic_timer()'s cyclic_id */
 320 
 321 extern void     clock_tick_schedule(int);
 322 
 323 static int lgrp_ticks;          /* counter to schedule lgrp load calcs */
 324 
 325 /*
 326  * for tod fault detection
 327  */
 328 #define TOD_REF_FREQ            ((longlong_t)(NANOSEC))
 329 #define TOD_STALL_THRESHOLD     (TOD_REF_FREQ * 3 / 2)
 330 #define TOD_JUMP_THRESHOLD      (TOD_REF_FREQ / 2)
 331 #define TOD_FILTER_N            4
 332 #define TOD_FILTER_SETTLE       (4 * TOD_FILTER_N)
 333 static int tod_faulted = TOD_NOFAULT;
 334 
 335 static int tod_status_flag = 0;         /* used by tod_validate() */
 336 
 337 static hrtime_t prev_set_tick = 0;      /* gethrtime() prior to tod_set() */
 338 static time_t prev_set_tod = 0;         /* tv_sec value passed to tod_set() */
 339 




  47 #include <sys/debug.h>
  48 #include <sys/vtrace.h>
  49 #include <sys/spl.h>
  50 #include <sys/atomic.h>
  51 #include <sys/dumphdr.h>
  52 #include <sys/archsystm.h>
  53 #include <sys/fs/swapnode.h>
  54 #include <sys/panic.h>
  55 #include <sys/disp.h>
  56 #include <sys/msacct.h>
  57 #include <sys/mem_cage.h>
  58 
  59 #include <vm/page.h>
  60 #include <vm/anon.h>
  61 #include <vm/rm.h>
  62 #include <sys/cyclic.h>
  63 #include <sys/cpupart.h>
  64 #include <sys/rctl.h>
  65 #include <sys/task.h>
  66 #include <sys/sdt.h>
  67 #include <sys/ddi_periodic.h>
  68 #include <sys/random.h>
  69 #include <sys/modctl.h>
  70 #include <sys/zone.h>
  71 
  72 /*
  73  * for NTP support
  74  */
  75 #include <sys/timex.h>
  76 #include <sys/inttypes.h>
  77 
  78 #include <sys/sunddi.h>
  79 #include <sys/clock_impl.h>
  80 
  81 /*
  82  * clock() is called straight from the clock cyclic; see clock_init().
  83  *
  84  * Functions:
  85  *      reprime clock
  86  *      maintain date
  87  *      jab the scheduler


 299 /*
 300  * Cache aligned, per CPU structure with lbolt usage statistics.
 301  */
 302 static lbolt_cpu_t *lb_cpu;
 303 
 304 /*
 305  * Single, cache aligned, structure with all the information required by
 306  * the lbolt implementation.
 307  */
 308 lbolt_info_t *lb_info;
 309 
 310 
 311 int one_sec = 1; /* turned on once every second */
 312 static int fsflushcnt;  /* counter for t_fsflushr */
 313 int     dosynctodr = 1; /* patchable; enable/disable sync to TOD chip */
 314 int     tod_needsync = 0;       /* need to sync tod chip with software time */
 315 static int tod_broken = 0;      /* clock chip doesn't work */
 316 time_t  boot_time = 0;          /* Boot time in seconds since 1970 */
 317 cyclic_id_t clock_cyclic;       /* clock()'s cyclic_id */
 318 cyclic_id_t deadman_cyclic;     /* deadman()'s cyclic_id */

 319 
 320 extern void     clock_tick_schedule(int);
 321 
 322 static int lgrp_ticks;          /* counter to schedule lgrp load calcs */
 323 
 324 /*
 325  * for tod fault detection
 326  */
 327 #define TOD_REF_FREQ            ((longlong_t)(NANOSEC))
 328 #define TOD_STALL_THRESHOLD     (TOD_REF_FREQ * 3 / 2)
 329 #define TOD_JUMP_THRESHOLD      (TOD_REF_FREQ / 2)
 330 #define TOD_FILTER_N            4
 331 #define TOD_FILTER_SETTLE       (4 * TOD_FILTER_N)
 332 static int tod_faulted = TOD_NOFAULT;
 333 
 334 static int tod_status_flag = 0;         /* used by tod_validate() */
 335 
 336 static hrtime_t prev_set_tick = 0;      /* gethrtime() prior to tod_set() */
 337 static time_t prev_set_tod = 0;         /* tv_sec value passed to tod_set() */
 338