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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/clock.c
          +++ new/usr/src/uts/common/os/clock.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  22   22  /*        All Rights Reserved   */
  23   23  
  24   24  /*
  25   25   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  26      - * Copyright (c) 2011, Joyent, Inc. All rights reserved.
       26 + * Copyright (c) 2013, Joyent, Inc.  All rights reserved.
  27   27   */
  28   28  
  29   29  #include <sys/param.h>
  30   30  #include <sys/t_lock.h>
  31   31  #include <sys/types.h>
  32   32  #include <sys/tuneable.h>
  33   33  #include <sys/sysmacros.h>
  34   34  #include <sys/systm.h>
  35   35  #include <sys/cpuvar.h>
  36   36  #include <sys/lgrp.h>
↓ open down ↓ 20 lines elided ↑ open up ↑
  57   57  #include <sys/mem_cage.h>
  58   58  
  59   59  #include <vm/page.h>
  60   60  #include <vm/anon.h>
  61   61  #include <vm/rm.h>
  62   62  #include <sys/cyclic.h>
  63   63  #include <sys/cpupart.h>
  64   64  #include <sys/rctl.h>
  65   65  #include <sys/task.h>
  66   66  #include <sys/sdt.h>
  67      -#include <sys/ddi_timer.h>
       67 +#include <sys/ddi_periodic.h>
  68   68  #include <sys/random.h>
  69   69  #include <sys/modctl.h>
  70   70  #include <sys/zone.h>
  71   71  
  72   72  /*
  73   73   * for NTP support
  74   74   */
  75   75  #include <sys/timex.h>
  76   76  #include <sys/inttypes.h>
  77   77  
↓ open down ↓ 231 lines elided ↑ open up ↑
 309  309  
 310  310  
 311  311  int one_sec = 1; /* turned on once every second */
 312  312  static int fsflushcnt;  /* counter for t_fsflushr */
 313  313  int     dosynctodr = 1; /* patchable; enable/disable sync to TOD chip */
 314  314  int     tod_needsync = 0;       /* need to sync tod chip with software time */
 315  315  static int tod_broken = 0;      /* clock chip doesn't work */
 316  316  time_t  boot_time = 0;          /* Boot time in seconds since 1970 */
 317  317  cyclic_id_t clock_cyclic;       /* clock()'s cyclic_id */
 318  318  cyclic_id_t deadman_cyclic;     /* deadman()'s cyclic_id */
 319      -cyclic_id_t ddi_timer_cyclic;   /* cyclic_timer()'s cyclic_id */
 320  319  
 321  320  extern void     clock_tick_schedule(int);
 322  321  
 323  322  static int lgrp_ticks;          /* counter to schedule lgrp load calcs */
 324  323  
 325  324  /*
 326  325   * for tod fault detection
 327  326   */
 328  327  #define TOD_REF_FREQ            ((longlong_t)(NANOSEC))
 329  328  #define TOD_STALL_THRESHOLD     (TOD_REF_FREQ * 3 / 2)
↓ open down ↓ 610 lines elided ↑ open up ↑
 940  939                          THREAD_TRANSITION(t);
 941  940                          setfrontdq(t);
 942  941                  }
 943  942                  thread_unlock(t);
 944  943          }
 945  944  }
 946  945  
 947  946  void
 948  947  clock_init(void)
 949  948  {
 950      -        cyc_handler_t clk_hdlr, timer_hdlr, lbolt_hdlr;
      949 +        cyc_handler_t clk_hdlr, lbolt_hdlr;
 951  950          cyc_time_t clk_when, lbolt_when;
 952  951          int i, sz;
 953  952          intptr_t buf;
 954  953  
 955  954          /*
 956  955           * Setup handler and timer for the clock cyclic.
 957  956           */
 958  957          clk_hdlr.cyh_func = (cyc_func_t)clock;
 959  958          clk_hdlr.cyh_level = CY_LOCK_LEVEL;
 960  959          clk_hdlr.cyh_arg = NULL;
 961  960  
 962  961          clk_when.cyt_when = 0;
 963  962          clk_when.cyt_interval = nsec_per_tick;
 964  963  
 965  964          /*
 966      -         * cyclic_timer is dedicated to the ddi interface, which
 967      -         * uses the same clock resolution as the system one.
 968      -         */
 969      -        timer_hdlr.cyh_func = (cyc_func_t)cyclic_timer;
 970      -        timer_hdlr.cyh_level = CY_LOCK_LEVEL;
 971      -        timer_hdlr.cyh_arg = NULL;
 972      -
 973      -        /*
 974  965           * The lbolt cyclic will be reprogramed to fire at a nsec_per_tick
 975  966           * interval to satisfy performance needs of the DDI lbolt consumers.
 976  967           * It is off by default.
 977  968           */
 978  969          lbolt_hdlr.cyh_func = (cyc_func_t)lbolt_cyclic;
 979  970          lbolt_hdlr.cyh_level = CY_LOCK_LEVEL;
 980  971          lbolt_hdlr.cyh_arg = NULL;
 981  972  
 982  973          lbolt_when.cyt_interval = nsec_per_tick;
 983  974  
↓ open down ↓ 54 lines elided ↑ open up ↑
1038 1029                  lbolt_when.cyt_when = CY_INFINITY;
1039 1030                  lbolt_hybrid = lbolt_event_driven;
1040 1031          }
1041 1032  
1042 1033          /*
1043 1034           * Grab cpu_lock and install all three cyclics.
1044 1035           */
1045 1036          mutex_enter(&cpu_lock);
1046 1037  
1047 1038          clock_cyclic = cyclic_add(&clk_hdlr, &clk_when);
1048      -        ddi_timer_cyclic = cyclic_add(&timer_hdlr, &clk_when);
1049 1039          lb_info->id.lbi_cyclic_id = cyclic_add(&lbolt_hdlr, &lbolt_when);
1050 1040  
1051 1041          mutex_exit(&cpu_lock);
1052 1042  }
1053 1043  
1054 1044  /*
1055 1045   * Called before calcloadavg to get 10-sec moving loadavg together
1056 1046   */
1057 1047  
1058 1048  static int
↓ open down ↓ 1617 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX