Print this page
Add boot_hrtime to global and zone kstats.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/kstat_fr.c
          +++ new/usr/src/uts/common/os/kstat_fr.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  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  /*
  22   22   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright 2014, Joyent, Inc. All rights reserved.
  24   24   * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
       25 + * Copyright 2016 Garrett D'Amore
  25   26   */
  26   27  
  27   28  /*
  28   29   * Kernel statistics framework
  29   30   */
  30   31  
  31   32  #include <sys/types.h>
  32   33  #include <sys/time.h>
  33   34  #include <sys/systm.h>
  34   35  #include <sys/vmsystm.h>
↓ open down ↓ 106 lines elided ↑ open up ↑
 141  142  extern  uint_t          segmapcnt_ndata;
 142  143  extern  int             segmap_kstat_update(kstat_t *, int);
 143  144  extern  kstat_named_t   *biostats_ptr;
 144  145  extern  uint_t          biostats_ndata;
 145  146  extern  kstat_named_t   *pollstats_ptr;
 146  147  extern  uint_t          pollstats_ndata;
 147  148  
 148  149  extern  int     vac;
 149  150  extern  uint_t  nproc;
 150  151  extern  time_t  boot_time;
      152 +extern  hrtime_t        boot_hrtime;
 151  153  extern  sysinfo_t       sysinfo;
 152  154  extern  vminfo_t        vminfo;
 153  155  
 154  156  struct {
 155  157          kstat_named_t ncpus;
 156  158          kstat_named_t lbolt;
 157  159          kstat_named_t deficit;
 158  160          kstat_named_t clk_intr;
 159  161          kstat_named_t vac;
 160  162          kstat_named_t nproc;
 161  163          kstat_named_t avenrun_1min;
 162  164          kstat_named_t avenrun_5min;
 163  165          kstat_named_t avenrun_15min;
 164  166          kstat_named_t boot_time;
      167 +        kstat_named_t boot_hrtime;
 165  168          kstat_named_t nsec_per_tick;
 166  169  } system_misc_kstat = {
 167  170          { "ncpus",              KSTAT_DATA_UINT32 },
 168  171          { "lbolt",              KSTAT_DATA_UINT32 },
 169  172          { "deficit",            KSTAT_DATA_UINT32 },
 170  173          { "clk_intr",           KSTAT_DATA_UINT32 },
 171  174          { "vac",                KSTAT_DATA_UINT32 },
 172  175          { "nproc",              KSTAT_DATA_UINT32 },
 173  176          { "avenrun_1min",       KSTAT_DATA_UINT32 },
 174  177          { "avenrun_5min",       KSTAT_DATA_UINT32 },
 175  178          { "avenrun_15min",      KSTAT_DATA_UINT32 },
 176  179          { "boot_time",          KSTAT_DATA_UINT32 },
      180 +        { "boot_hrtime",        KSTAT_DATA_TIME },
 177  181          { "nsec_per_tick",      KSTAT_DATA_UINT32 },
 178  182  };
 179  183  
 180  184  struct {
 181  185          kstat_named_t physmem;
 182  186          kstat_named_t nalloc;
 183  187          kstat_named_t nfree;
 184  188          kstat_named_t nalloc_calls;
 185  189          kstat_named_t nfree_calls;
 186  190          kstat_named_t kernelbase;
↓ open down ↓ 616 lines elided ↑ open up ↑
 803  807          return (0);
 804  808  }
 805  809  
 806  810  /* ARGSUSED */
 807  811  static int
 808  812  system_misc_kstat_update(kstat_t *ksp, int rw)
 809  813  {
 810  814          int myncpus = ncpus;
 811  815          int *loadavgp = &avenrun[0];
 812  816          time_t zone_boot_time;
      817 +        hrtime_t zone_boot_hrtime;
 813  818          clock_t zone_lbolt;
 814  819          hrtime_t zone_hrtime;
 815  820          size_t zone_nproc;
 816  821  
 817  822          if (rw == KSTAT_WRITE)
 818  823                  return (EACCES);
 819  824  
 820  825          if (!INGLOBALZONE(curproc)) {
 821  826                  /*
 822  827                   * Here we grab cpu_lock which is OK as long as no-one in the
↓ open down ↓ 6 lines elided ↑ open up ↑
 829  834                          ASSERT(myncpus > 0);
 830  835                  }
 831  836                  mutex_exit(&cpu_lock);
 832  837                  loadavgp = &curproc->p_zone->zone_avenrun[0];
 833  838          }
 834  839  
 835  840          if (INGLOBALZONE(curproc)) {
 836  841                  zone_boot_time = boot_time;
 837  842                  zone_lbolt = ddi_get_lbolt();
 838  843                  zone_nproc = nproc;
      844 +                zone_boot_hrtime = boot_hrtime;
 839  845          } else {
 840  846                  zone_boot_time = curproc->p_zone->zone_boot_time;
      847 +                zone_boot_hrtime = curproc->p_zone->zone_boot_hrtime;
 841  848  
 842  849                  zone_hrtime = gethrtime();
 843  850                  zone_lbolt = (clock_t)(NSEC_TO_TICK(zone_hrtime) -
 844  851                      NSEC_TO_TICK(curproc->p_zone->zone_zsched->p_mstart));
 845  852                  mutex_enter(&curproc->p_zone->zone_nlwps_lock);
 846  853                  zone_nproc = curproc->p_zone->zone_nprocs;
 847  854                  mutex_exit(&curproc->p_zone->zone_nlwps_lock);
 848  855          }
 849  856  
 850  857          system_misc_kstat.ncpus.value.ui32              = (uint32_t)myncpus;
 851  858          system_misc_kstat.lbolt.value.ui32              = (uint32_t)zone_lbolt;
 852  859          system_misc_kstat.deficit.value.ui32            = (uint32_t)deficit;
 853  860          system_misc_kstat.clk_intr.value.ui32           = (uint32_t)zone_lbolt;
 854  861          system_misc_kstat.vac.value.ui32                = (uint32_t)vac;
 855  862          system_misc_kstat.nproc.value.ui32              = (uint32_t)zone_nproc;
 856  863          system_misc_kstat.avenrun_1min.value.ui32       = (uint32_t)loadavgp[0];
 857  864          system_misc_kstat.avenrun_5min.value.ui32       = (uint32_t)loadavgp[1];
 858  865          system_misc_kstat.avenrun_15min.value.ui32      = (uint32_t)loadavgp[2];
 859  866          system_misc_kstat.boot_time.value.ui32          = (uint32_t)
 860  867              zone_boot_time;
      868 +        system_misc_kstat.boot_hrtime.value.t           = zone_boot_hrtime;
 861  869          system_misc_kstat.nsec_per_tick.value.ui32      = (uint32_t)
 862  870              nsec_per_tick;
 863  871          return (0);
 864  872  }
 865  873  
 866  874  #ifdef  __sparc
 867  875  extern caddr_t  econtig32;
 868  876  #else   /* !__sparc */
 869  877  extern caddr_t  econtig;
 870  878  #endif  /* __sparc */
↓ open down ↓ 579 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX