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