459053
diff -up ./top/top.c.ori ./top/top.c
459053
--- ./top/top.c.ori	2017-04-07 18:36:05.953611338 +0200
459053
+++ ./top/top.c	2017-04-07 18:37:14.037321741 +0200
459053
@@ -91,6 +91,7 @@ static int   Rc_questions;
459053
 static unsigned Pg2K_shft = 0;
459053
 
459053
         /* SMP, Irix/Solaris mode, Linux 2.5.xx support */
459053
+static CPU_t      *Cpu_tics;
459053
 static int         Cpu_faux_tot;
459053
 static float       Cpu_pmax;
459053
 static const char *Cpu_States_fmts;
459053
@@ -2356,10 +2357,10 @@ static void zap_fieldstab (void) {
459053
          * This guy's modeled on libproc's 'eight_cpu_numbers' function except
459053
          * we preserve all cpu data in our CPU_t array which is organized
459053
          * as follows:
459053
-         *    cpus[0] thru cpus[n] == tics for each separate cpu
459053
-         *    cpus[sumSLOT]        == tics from the 1st /proc/stat line
459053
-         *  [ and beyond sumSLOT   == tics for each cpu NUMA node ] */
459053
-static CPU_t *cpus_refresh (CPU_t *cpus) {
459053
+         *    Cpu_tics[0] thru Cpu_tics[n] == tics for each separate cpu
459053
+         *    Cpu_tics[sumSLOT]            == tics from /proc/stat line #1
459053
+         *  [ and beyond sumSLOT           == tics for each cpu NUMA node ] */
459053
+static void cpus_refresh (void) {
459053
  #define sumSLOT ( smp_num_cpus )
459053
  #define totSLOT ( 1 + smp_num_cpus + Numa_node_tot)
459053
    static FILE *fp = NULL;
459053
@@ -2377,7 +2378,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
       sav_slot = sumSLOT;
459053
       zap_fieldstab();
459053
       if (fp) { fclose(fp); fp = NULL; }
459053
-      if (cpus) { free(cpus); cpus = NULL; }
459053
+      if (Cpu_tics) free(Cpu_tics);
459053
    }
459053
 
459053
    /* by opening this file once, we'll avoid the hit on minor page faults
459053
@@ -2387,7 +2388,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
          error_exit(fmtmk(N_fmt(FAIL_statopn_fmt), strerror(errno)));
459053
       /* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a
459053
                slot can hold tics representing the /proc/stat cpu summary */
459053
-      cpus = alloc_c(totSLOT * sizeof(CPU_t));
459053
+      Cpu_tics = alloc_c(totSLOT * sizeof(CPU_t));
459053
    }
459053
    rewind(fp);
459053
    fflush(fp);
459053
@@ -2410,7 +2411,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
  #undef buffGRW
459053
 
459053
    // remember from last time around
459053
-   sum_ptr = &cpus[sumSLOT];
459053
+   sum_ptr = &Cpu_tics[sumSLOT];
459053
    memcpy(&sum_ptr->sav, &sum_ptr->cur, sizeof(CT_t));
459053
    // then value the last slot with the cpu summary line
459053
    if (4 > sscanf(bp, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
459053
@@ -2437,7 +2438,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
 
459053
    // now value each separate cpu's tics...
459053
    for (i = 0; i < sumSLOT; i++) {
459053
-      CPU_t *cpu_ptr = &cpus[i];               // avoid gcc subscript bloat
459053
+      CPU_t *cpu_ptr = &Cpu_tics[i];           // avoid gcc subscript bloat
459053
 #ifdef PRETEND8CPUS
459053
       bp = buf;
459053
 #endif
459053
@@ -2448,7 +2449,6 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
          , &cpu_ptr->cur.u, &cpu_ptr->cur.n, &cpu_ptr->cur.s
459053
          , &cpu_ptr->cur.i, &cpu_ptr->cur.w, &cpu_ptr->cur.x
459053
          , &cpu_ptr->cur.y, &cpu_ptr->cur.z)) {
459053
-            memmove(cpu_ptr, sum_ptr, sizeof(CPU_t));
459053
             break;        // tolerate cpus taken offline
459053
       }
459053
 
459053
@@ -2488,8 +2488,6 @@ static CPU_t *cpus_refresh (CPU_t *cpus)
459053
    } // end: for each cpu
459053
 
459053
    Cpu_faux_tot = i;      // tolerate cpus taken offline
459053
-
459053
-   return cpus;
459053
  #undef sumSLOT
459053
  #undef totSLOT
459053
 } // end: cpus_refresh
459053
@@ -5119,7 +5117,6 @@ static void summary_hlp (CPU_t *cpu, con
459053
 static void summary_show (void) {
459053
  #define isROOM(f,n) (CHKw(w, f) && Msg_row + (n) < Screen_rows - 1)
459053
  #define anyFLG 0xffffff
459053
-   static CPU_t *smpcpu = NULL;
459053
    WIN_t *w = Curwin;             // avoid gcc bloat with a local copy
459053
    char tmp[MEDBUFSIZ];
459053
    int i;
459053
@@ -5142,7 +5139,7 @@ static void summary_show (void) {
459053
          , Frame_stopped, Frame_zombied));
459053
       Msg_row += 1;
459053
 
459053
-      smpcpu = cpus_refresh(smpcpu);
459053
+      cpus_refresh();
459053
 
459053
 #ifndef NUMA_DISABLE
459053
       if (!Numa_node_tot) goto numa_nope;
459053
@@ -5150,11 +5147,11 @@ static void summary_show (void) {
459053
       if (CHKw(w, View_CPUNOD)) {
459053
          if (Numa_node_sel < 0) {
459053
             // display the 1st /proc/stat line, then the nodes (if room)
459053
-            summary_hlp(&smpcpu[smp_num_cpus], N_txt(WORD_allcpus_txt));
459053
+            summary_hlp(&Cpu_tics[smp_num_cpus], N_txt(WORD_allcpus_txt));
459053
             Msg_row += 1;
459053
             // display each cpu node's states
459053
             for (i = 0; i < Numa_node_tot; i++) {
459053
-               CPU_t *nod_ptr = &smpcpu[1 + smp_num_cpus + i];
459053
+               CPU_t *nod_ptr = &Cpu_tics[1 + smp_num_cpus + i];
459053
                if (!isROOM(anyFLG, 1)) break;
459053
 #ifndef OFF_NUMASKIP
459053
                if (nod_ptr->id) {
459053
@@ -5169,13 +5166,13 @@ static void summary_show (void) {
459053
          } else {
459053
             // display the node summary, then the associated cpus (if room)
459053
             snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), Numa_node_sel);
459053
-            summary_hlp(&smpcpu[1 + smp_num_cpus + Numa_node_sel], tmp);
459053
+            summary_hlp(&Cpu_tics[1 + smp_num_cpus + Numa_node_sel], tmp);
459053
             Msg_row += 1;
459053
             for (i = 0; i < Cpu_faux_tot; i++) {
459053
-               if (Numa_node_sel == smpcpu[i].node) {
459053
+               if (Numa_node_sel == Cpu_tics[i].node) {
459053
                   if (!isROOM(anyFLG, 1)) break;
459053
-                  snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);
459053
-                  summary_hlp(&smpcpu[i], tmp);
459053
+                  snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_tics[i].id);
459053
+                  summary_hlp(&Cpu_tics[i], tmp);
459053
                   Msg_row += 1;
459053
                }
459053
             }
459053
@@ -5185,14 +5182,14 @@ numa_nope:
459053
 #endif
459053
       if (CHKw(w, View_CPUSUM)) {
459053
          // display just the 1st /proc/stat line
459053
-         summary_hlp(&smpcpu[Cpu_faux_tot], N_txt(WORD_allcpus_txt));
459053
+         summary_hlp(&Cpu_tics[Cpu_faux_tot], N_txt(WORD_allcpus_txt));
459053
          Msg_row += 1;
459053
 
459053
       } else {
459053
          // display each cpu's states separately, screen height permitting...
459053
          for (i = 0; i < Cpu_faux_tot; i++) {
459053
-            snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);
459053
-            summary_hlp(&smpcpu[i], tmp);
459053
+            snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_tics[i].id);
459053
+            summary_hlp(&Cpu_tics[i], tmp);
459053
             Msg_row += 1;
459053
             if (!isROOM(anyFLG, 1)) break;
459053
          }
459053
@@ -5643,6 +5640,7 @@ static void frame_make (void) {
459053
 
459053
    // whoa either first time or thread/task mode change, (re)prime the pump...
459053
    if (Pseudo_row == PROC_XTRA) {
459053
+      cpus_refresh();
459053
       procs_refresh();
459053
       usleep(LIB_USLEEP);
459053
       putp(Cap_clr_scr);
459053
diff -up ./top/top.h.ori ./top/top.h
459053
--- ./top/top.h.ori	2017-04-07 18:36:14.921573192 +0200
459053
+++ ./top/top.h	2017-04-07 18:37:14.037321741 +0200
459053
@@ -728,7 +728,7 @@ typedef struct WIN_t {
459053
 //atic inline void   widths_resize (void);
459053
 //atic void          zap_fieldstab (void);
459053
 /*------  Library Interface  ---------------------------------------------*/
459053
-//atic CPU_t        *cpus_refresh (CPU_t *cpus);
459053
+//atic void          cpus_refresh (void);
459053
 #ifdef OFF_HST_HASH
459053
 //atic inline HST_t *hstbsrch (HST_t *hst, int max, int pid);
459053
 #else