[BACK]Return to vmstat.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.bin / vmstat

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/usr.bin/vmstat/vmstat.c between version 1.227 and 1.227.2.2

version 1.227, 2019/05/09 08:01:07 version 1.227.2.2, 2022/07/17 12:54:56
Line 147  struct cpu_info {
Line 147  struct cpu_info {
  */   */
 struct nlist namelist[] =  struct nlist namelist[] =
 {  {
 #define X_BOOTTIME      0  #define X_HZ            0
         { .n_name = "_boottime" },  
 #define X_HZ            1  
         { .n_name = "_hz" },          { .n_name = "_hz" },
 #define X_STATHZ        2  #define X_STATHZ        1
         { .n_name = "_stathz" },          { .n_name = "_stathz" },
 #define X_NCHSTATS      3  #define X_NCHSTATS      2
         { .n_name = "_nchstats" },          { .n_name = "_nchstats" },
 #define X_ALLEVENTS     4  #define X_ALLEVENTS     3
         { .n_name = "_allevents" },          { .n_name = "_allevents" },
 #define X_POOLHEAD      5  #define X_POOLHEAD      4
         { .n_name = "_pool_head" },          { .n_name = "_pool_head" },
 #define X_UVMEXP        6  #define X_UVMEXP        5
         { .n_name = "_uvmexp" },          { .n_name = "_uvmexp" },
 #define X_TIME_SECOND   7  #define X_CPU_INFOS     6
           { .n_name = "_cpu_infos" },
   #define X_NL_SIZE       7
           { .n_name = NULL },
   };
   
   /*
    * Namelist for time data.
    */
   struct nlist timenl[] =
   {
   #define X_BOOTTIME      0
           { .n_name = "_boottime" },
   #define X_TIME_SECOND   1
         { .n_name = "_time_second" },          { .n_name = "_time_second" },
 #define X_TIME          8  #define X_TIME          2
         { .n_name = "_time" },          { .n_name = "_time" },
 #define X_CPU_INFOS     9  #define X_TIMENL_SIZE   3
         { .n_name = "_cpu_infos" },  
 #define X_NL_SIZE       10  
         { .n_name = NULL },          { .n_name = NULL },
 };  };
   
Line 552  getnlist(int todo)
Line 561  getnlist(int todo)
                                 errx(1, "kvm_nlist: %s %s",                                  errx(1, "kvm_nlist: %s %s",
                                     "namelist", kvm_geterr(kd));                                      "namelist", kvm_geterr(kd));
                         for (i = 0; i < __arraycount(namelist)-1; i++)                          for (i = 0; i < __arraycount(namelist)-1; i++)
                                 if (namelist[i].n_type == 0 &&                                  if (namelist[i].n_type == 0) {
                                     i != X_TIME_SECOND &&  
                                     i != X_TIME) {  
                                         if (doexit++ == 0)                                          if (doexit++ == 0)
                                                 (void)fprintf(stderr,                                                  (void)fprintf(stderr,
                                                     "%s: undefined symbols:",                                                      "%s: undefined symbols:",
Line 568  getnlist(int todo)
Line 575  getnlist(int todo)
                         }                          }
                 }                  }
         }          }
           if ((todo & (VMSTAT|INTRSTAT)) && !(done & (VMSTAT))) {
                   done |= VMSTAT;
                   if ((c = kvm_nlist(kd, timenl)) == -1 || c == X_TIMENL_SIZE)
                           errx(1, "kvm_nlist: %s %s", "timenl", kvm_geterr(kd));
           }
         if ((todo & (SUMSTAT|INTRSTAT)) && !(done & (SUMSTAT|INTRSTAT))) {          if ((todo & (SUMSTAT|INTRSTAT)) && !(done & (SUMSTAT|INTRSTAT))) {
                 done |= SUMSTAT|INTRSTAT;                  done |= SUMSTAT|INTRSTAT;
                 (void) kvm_nlist(kd, intrnl);                  (void) kvm_nlist(kd, intrnl);
Line 636  getuptime(void)
Line 648  getuptime(void)
                 clock_gettime(CLOCK_REALTIME, &now);                  clock_gettime(CLOCK_REALTIME, &now);
         } else {          } else {
                 if (boottime.tv_sec == 0)                  if (boottime.tv_sec == 0)
                         kread(namelist, X_BOOTTIME, &boottime,                          kread(timenl, X_BOOTTIME, &boottime, sizeof(boottime));
                             sizeof(boottime));                  if (kreadc(timenl, X_TIME_SECOND, &nowsec, sizeof(nowsec))) {
                 if (kreadc(namelist, X_TIME_SECOND, &nowsec, sizeof(nowsec))) {  
                         /*                          /*
                          * XXX this assignment dance can be removed once                           * XXX this assignment dance can be removed once
                          * timeval tv_sec is SUS mandated time_t                           * timeval tv_sec is SUS mandated time_t
Line 646  getuptime(void)
Line 657  getuptime(void)
                         now.tv_sec = nowsec;                          now.tv_sec = nowsec;
                         now.tv_nsec = 0;                          now.tv_nsec = 0;
                 } else {                  } else {
                         kread(namelist, X_TIME, &now, sizeof(now));                          kread(timenl, X_TIME, &now, sizeof(now));
                 }                  }
         }          }
         uptime = now.tv_sec - boottime.tv_sec;          uptime = now.tv_sec - boottime.tv_sec;
Line 1559  dopool(int verbose, int wide)
Line 1570  dopool(int verbose, int wide)
 {  {
         int first, ovflw;          int first, ovflw;
         void *addr;          void *addr;
         long total, inuse, this_total, this_inuse;          uint64_t total, inuse, this_total, this_inuse;
         struct {          struct {
                 uint64_t pt_nget;                  uint64_t pt_nget;
                 uint64_t pt_nfail;                  uint64_t pt_nfail;
Line 1653  dopool(int verbose, int wide)
Line 1664  dopool(int verbose, int wide)
                         PRWORD(ovflw, " 0x%0*x", 5, 1,                          PRWORD(ovflw, " 0x%0*x", 5, 1,
                             pp->pr_flags | pp->pr_roflags);                              pp->pr_flags | pp->pr_roflags);
   
                 this_inuse = pp->pr_nout * pp->pr_size;                  this_inuse = (uint64_t)pp->pr_nout * pp->pr_size;
                 this_total = pp->pr_npages * pa.pa_pagesz;                  this_total = (uint64_t)pp->pr_npages * pa.pa_pagesz;
                 if (pp->pr_roflags & PR_RECURSIVE) {                  if (pp->pr_roflags & PR_RECURSIVE) {
                         /*                          /*
                          * Don't count in-use memory, since it's part                           * Don't count in-use memory, since it's part
Line 1693  dopool(int verbose, int wide)
Line 1704  dopool(int verbose, int wide)
         inuse /= KILO;          inuse /= KILO;
         total /= KILO;          total /= KILO;
         (void)printf(          (void)printf(
             "\nIn use %ldK, total allocated %ldK; utilization %.1f%%\n",              "\nIn use %" PRIu64 "K, "
               "total allocated %" PRIu64 "K; utilization %.1f%%\n",
             inuse, total, (100.0 * inuse) / total);              inuse, total, (100.0 * inuse) / total);
 }  }
   

Legend:
Removed from v.1.227  
changed lines
  Added in v.1.227.2.2

CVSweb <webmaster@jp.NetBSD.org>