top: exploit the new library API for cpu display needs
This commit is mostly about eliminating code, now that
a library is responsible for the cpu tics maintenance.
The top program will continue to provide numa support,
without involving the library in any of those details.
[ not to mention all the 'dl' and 'stderr' numa crap ]
With this transfer of the cpu tics duty to our library
the provision associated with the CPU_ZEROTICS #define
could not initially be migrated. The commit referenced
below suggests it may have lost its importance. In any
case such logic may yet be incorporated in the future.
But for now, that #define has been completely removed.
Reference(s):
commit ee3ed4b45e
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
73d7a18d66
commit
8ded6c5739
228
top/top.c
228
top/top.c
@ -53,6 +53,7 @@
|
|||||||
#include "../proc/meminfo.h"
|
#include "../proc/meminfo.h"
|
||||||
#include "../proc/procps.h"
|
#include "../proc/procps.h"
|
||||||
#include "../proc/readproc.h"
|
#include "../proc/readproc.h"
|
||||||
|
#include "../proc/readstat.h"
|
||||||
#include "../proc/sig.h"
|
#include "../proc/sig.h"
|
||||||
#include "../proc/sysinfo.h"
|
#include "../proc/sysinfo.h"
|
||||||
#include "../proc/version.h"
|
#include "../proc/version.h"
|
||||||
@ -265,6 +266,9 @@ enum mem_enums {
|
|||||||
mem_AVAIL, swp_TOTAL, swp_FREE, swp_USED
|
mem_AVAIL, swp_TOTAL, swp_FREE, swp_USED
|
||||||
};
|
};
|
||||||
#define MEM_VAL(e) mem_chain[e].result
|
#define MEM_VAL(e) mem_chain[e].result
|
||||||
|
|
||||||
|
static struct procps_statinfo *sys_info;
|
||||||
|
static struct procps_jiffs_hist *Cpu_jiffs;
|
||||||
|
|
||||||
/*###### Sort callbacks ################################################*/
|
/*###### Sort callbacks ################################################*/
|
||||||
|
|
||||||
@ -435,8 +439,9 @@ static void bye_bye (const char *str) {
|
|||||||
"\n\t %s"
|
"\n\t %s"
|
||||||
"\n\t Hertz = %u (%u bytes, %u-bit time)"
|
"\n\t Hertz = %u (%u bytes, %u-bit time)"
|
||||||
"\n\t page_bytes = %d, Cpu_faux_tot = %d, smp_num_cpus = %d"
|
"\n\t page_bytes = %d, Cpu_faux_tot = %d, smp_num_cpus = %d"
|
||||||
"\n\t sizeof(CPU_t) = %u, sizeof(HST_t) = %u (%d HST_t's/Page), HHist_siz = %u"
|
"\n\t sizeof(HST_t) = %u (%d HST_t's/Page), HHist_siz = %u"
|
||||||
"\n\t sizeof(proc_t) = %u, sizeof(proc_t.cmd) = %u, sizeof(proc_t*) = %u"
|
"\n\t sizeof(proc_t) = %u, sizeof(proc_t.cmd) = %u, sizeof(proc_t*) = %u"
|
||||||
|
"\n\t sizeof(procps_jiffs) = %u, sizeof(procps_jiffs_hist) = %u, sizeof(procps_sys_result) = %u"
|
||||||
"\n\t Frames_libflags = %08lX"
|
"\n\t Frames_libflags = %08lX"
|
||||||
"\n\t SCREENMAX = %u, ROWMINSIZ = %u, ROWMAXSIZ = %u"
|
"\n\t SCREENMAX = %u, ROWMINSIZ = %u, ROWMAXSIZ = %u"
|
||||||
"\n\t PACKAGE = '%s', LOCALEDIR = '%s'"
|
"\n\t PACKAGE = '%s', LOCALEDIR = '%s'"
|
||||||
@ -464,9 +469,10 @@ static void bye_bye (const char *str) {
|
|||||||
, __func__
|
, __func__
|
||||||
, PACKAGE_STRING
|
, PACKAGE_STRING
|
||||||
, (unsigned)Hertz, (unsigned)sizeof(Hertz), (unsigned)sizeof(Hertz) * 8
|
, (unsigned)Hertz, (unsigned)sizeof(Hertz), (unsigned)sizeof(Hertz) * 8
|
||||||
, (int)page_bytes, Cpu_faux_tot, (int)smp_num_cpus, (unsigned)sizeof(CPU_t)
|
, (int)page_bytes, Cpu_faux_tot, (int)smp_num_cpus
|
||||||
, (unsigned)sizeof(HST_t), ((int)page_bytes / (int)sizeof(HST_t)), HHist_siz
|
, (unsigned)sizeof(HST_t), ((int)page_bytes / (int)sizeof(HST_t)), HHist_siz
|
||||||
, (unsigned)sizeof(proc_t), (unsigned)sizeof(p->cmd), (unsigned)sizeof(proc_t*)
|
, (unsigned)sizeof(proc_t), (unsigned)sizeof(p->cmd), (unsigned)sizeof(proc_t*)
|
||||||
|
, (unsigned)sizeof(struct procps_jiffs), (unsigned)sizeof(struct procps_jiffs_hist), (unsigned)sizeof(struct procps_sys_result)
|
||||||
, (long)Frames_libflags
|
, (long)Frames_libflags
|
||||||
, (unsigned)SCREENMAX, (unsigned)ROWMINSIZ, (unsigned)ROWMAXSIZ
|
, (unsigned)SCREENMAX, (unsigned)ROWMINSIZ, (unsigned)ROWMAXSIZ
|
||||||
, PACKAGE, LOCALEDIR
|
, PACKAGE, LOCALEDIR
|
||||||
@ -570,6 +576,8 @@ static void bye_bye (const char *str) {
|
|||||||
#endif // end: ATEOJ_RPTHSH
|
#endif // end: ATEOJ_RPTHSH
|
||||||
#endif // end: OFF_HST_HASH
|
#endif // end: OFF_HST_HASH
|
||||||
|
|
||||||
|
procps_stat_unref(sys_info);
|
||||||
|
procps_meminfo_unref(mem_info);
|
||||||
#ifndef NUMA_DISABLE
|
#ifndef NUMA_DISABLE
|
||||||
if (Libnuma_handle) dlclose(Libnuma_handle);
|
if (Libnuma_handle) dlclose(Libnuma_handle);
|
||||||
#endif
|
#endif
|
||||||
@ -2362,143 +2370,84 @@ static void zap_fieldstab (void) {
|
|||||||
/*###### Library Interface #############################################*/
|
/*###### Library Interface #############################################*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This guy's modeled on libproc's 'eight_cpu_numbers' function except
|
* We'll track all cpu data in the jiffs array which is organized
|
||||||
* we preserve all cpu data in our CPU_t array which is organized
|
|
||||||
* as follows:
|
* as follows:
|
||||||
* cpus[0] thru cpus[n] == tics for each separate cpu
|
* Cpu_jiffs[0] - Cpu_jiffs[n] == tics for each separate cpu
|
||||||
* cpus[sumSLOT] == tics from the 1st /proc/stat line
|
* Cpu_jiffs[sumSLOT] == tics from /proc/stat line #1
|
||||||
* [ and beyond sumSLOT == tics for each cpu NUMA node ] */
|
* [ and beyond sumSLOT == tics for each cpu NUMA node ] */
|
||||||
static CPU_t *cpus_refresh (CPU_t *cpus) {
|
static void cpus_refresh (void) {
|
||||||
#define sumSLOT ( smp_num_cpus )
|
#define sumSLOT ( smp_num_cpus )
|
||||||
#define totSLOT ( 1 + smp_num_cpus + Numa_node_tot)
|
#define totSLOT ( 1 + smp_num_cpus + Numa_node_tot )
|
||||||
static FILE *fp = NULL;
|
static int sav_slot = -1;
|
||||||
static int siz, sav_slot = -1;
|
int i;
|
||||||
static char *buf;
|
|
||||||
CPU_t *sum_ptr; // avoid gcc subscript bloat
|
|
||||||
int i, num, tot_read;
|
|
||||||
#ifndef NUMA_DISABLE
|
#ifndef NUMA_DISABLE
|
||||||
int node;
|
int node;
|
||||||
#endif
|
#endif
|
||||||
char *bp;
|
|
||||||
|
|
||||||
/*** hotplug_acclimated ***/
|
/*** hotplug_acclimated ***/
|
||||||
if (sav_slot != sumSLOT) {
|
if (sav_slot != sumSLOT) {
|
||||||
sav_slot = sumSLOT;
|
sav_slot = sumSLOT;
|
||||||
zap_fieldstab();
|
zap_fieldstab();
|
||||||
if (fp) { fclose(fp); fp = NULL; }
|
if (Cpu_jiffs) { free(Cpu_jiffs); Cpu_jiffs = NULL; }
|
||||||
if (cpus) { free(cpus); cpus = NULL; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* by opening this file once, we'll avoid the hit on minor page faults
|
if (!Cpu_jiffs) {
|
||||||
(sorry Linux, but you'll have to close it for us) */
|
|
||||||
if (!fp) {
|
|
||||||
if (!(fp = fopen("/proc/stat", "r")))
|
|
||||||
error_exit(fmtmk(N_fmt(FAIL_statopn_fmt), strerror(errno)));
|
|
||||||
/* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a
|
/* note: we allocate one more CPU_t via totSLOT than 'cpus' so that a
|
||||||
slot can hold tics representing the /proc/stat cpu summary */
|
slot can hold tics representing the /proc/stat cpu summary */
|
||||||
cpus = alloc_c(totSLOT * sizeof(CPU_t));
|
Cpu_jiffs = alloc_c(totSLOT * sizeof(struct procps_jiffs_hist));
|
||||||
}
|
}
|
||||||
rewind(fp);
|
|
||||||
fflush(fp);
|
|
||||||
|
|
||||||
#define buffGRW 1024
|
// first. snapshot the proc/stat cpu jiffs
|
||||||
/* we slurp in the entire directory thus avoiding repeated calls to fgets,
|
if (procps_stat_read_jiffs(sys_info) < 0)
|
||||||
especially in a massively parallel environment. additionally, each cpu
|
error_exit(N_txt(LIB_errorsys_txt));
|
||||||
line is then frozen in time rather than changing until we get around to
|
// second, retrieve just the cpu summary jiffs
|
||||||
accessing it. this helps to minimize (not eliminate) most distortions. */
|
if (procps_stat_get_jiffs_hist(sys_info, &Cpu_jiffs[sumSLOT], -1) < 0)
|
||||||
tot_read = 0;
|
error_exit(N_txt(LIB_errorsys_txt));
|
||||||
if (buf) buf[0] = '\0';
|
// then retrieve all of the actual cpu jiffs
|
||||||
else buf = alloc_c((siz = buffGRW));
|
Cpu_faux_tot = procps_stat_get_jiffs_hist_all(sys_info, Cpu_jiffs, sumSLOT);
|
||||||
while (0 < (num = fread(buf + tot_read, 1, (siz - tot_read), fp))) {
|
if (Cpu_faux_tot < 0)
|
||||||
tot_read += num;
|
error_exit(N_txt(LIB_errorsys_txt));
|
||||||
if (tot_read < siz) break;
|
|
||||||
buf = alloc_r(buf, (siz += buffGRW));
|
|
||||||
};
|
|
||||||
buf[tot_read] = '\0';
|
|
||||||
bp = buf;
|
|
||||||
#undef buffGRW
|
|
||||||
|
|
||||||
// remember from last time around
|
|
||||||
sum_ptr = &cpus[sumSLOT];
|
|
||||||
memcpy(&sum_ptr->sav, &sum_ptr->cur, sizeof(CT_t));
|
|
||||||
// then value the last slot with the cpu summary line
|
|
||||||
if (4 > sscanf(bp, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
|
|
||||||
, &sum_ptr->cur.u, &sum_ptr->cur.n, &sum_ptr->cur.s
|
|
||||||
, &sum_ptr->cur.i, &sum_ptr->cur.w, &sum_ptr->cur.x
|
|
||||||
, &sum_ptr->cur.y, &sum_ptr->cur.z))
|
|
||||||
error_exit(N_txt(FAIL_statget_txt));
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
sum_ptr->cur.tot = sum_ptr->cur.u + sum_ptr->cur.s
|
|
||||||
+ sum_ptr->cur.n + sum_ptr->cur.i + sum_ptr->cur.w
|
|
||||||
+ sum_ptr->cur.x + sum_ptr->cur.y + sum_ptr->cur.z;
|
|
||||||
/* if a cpu has registered substantially fewer tics than those expected,
|
|
||||||
we'll force it to be treated as 'idle' so as not to present misleading
|
|
||||||
percentages. */
|
|
||||||
sum_ptr->edge =
|
|
||||||
((sum_ptr->cur.tot - sum_ptr->sav.tot) / smp_num_cpus) / (100 / TICS_EDGE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NUMA_DISABLE
|
#ifndef NUMA_DISABLE
|
||||||
// forget all of the prior node statistics (maybe)
|
/* henceforth, with just a little more arithmetic we can avoid
|
||||||
if (CHKw(Curwin, View_CPUNOD))
|
maintaining *any* node stats unless they're actually needed */
|
||||||
memset(sum_ptr + 1, 0, Numa_node_tot * sizeof(CPU_t));
|
if (CHKw(Curwin, View_CPUNOD)) {
|
||||||
#endif
|
struct procps_jiffs_hist *sum_ptr = &Cpu_jiffs[sumSLOT];
|
||||||
|
// forget all of the prior node statistics
|
||||||
// now value each separate cpu's tics...
|
memset(sum_ptr + 1, 0, Numa_node_tot * sizeof(struct procps_jiffs_hist));
|
||||||
for (i = 0; i < sumSLOT; i++) {
|
// spin thru each cpu and value the jiffs for it's numa node
|
||||||
CPU_t *cpu_ptr = &cpus[i]; // avoid gcc subscript bloat
|
for (i = 0; i < sumSLOT; i++) {
|
||||||
#ifdef PRETEND8CPUS
|
struct procps_jiffs_hist *cpu_ptr = &Cpu_jiffs[i];
|
||||||
bp = buf;
|
if (CHKw(Curwin, View_CPUNOD)
|
||||||
#endif
|
&& Numa_node_tot
|
||||||
bp = 1 + strchr(bp, '\n');
|
&& -1 < (node = Numa_node_of_cpu(cpu_ptr->id))) {
|
||||||
// remember from last time around
|
struct procps_jiffs_hist *nod_ptr = sum_ptr + 1 + node;
|
||||||
memcpy(&cpu_ptr->sav, &cpu_ptr->cur, sizeof(CT_t));
|
nod_ptr->new.user += cpu_ptr->new.user; nod_ptr->old.user += cpu_ptr->old.user;
|
||||||
if (4 > sscanf(bp, "cpu%d %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", &cpu_ptr->id
|
nod_ptr->new.nice += cpu_ptr->new.nice; nod_ptr->old.nice += cpu_ptr->old.nice;
|
||||||
, &cpu_ptr->cur.u, &cpu_ptr->cur.n, &cpu_ptr->cur.s
|
nod_ptr->new.system += cpu_ptr->new.system; nod_ptr->old.system += cpu_ptr->old.system;
|
||||||
, &cpu_ptr->cur.i, &cpu_ptr->cur.w, &cpu_ptr->cur.x
|
nod_ptr->new.idle += cpu_ptr->new.idle; nod_ptr->old.idle += cpu_ptr->old.idle;
|
||||||
, &cpu_ptr->cur.y, &cpu_ptr->cur.z)) {
|
nod_ptr->new.iowait += cpu_ptr->new.iowait; nod_ptr->old.iowait += cpu_ptr->old.iowait;
|
||||||
memmove(cpu_ptr, sum_ptr, sizeof(CPU_t));
|
nod_ptr->new.irq += cpu_ptr->new.irq; nod_ptr->old.irq += cpu_ptr->old.irq;
|
||||||
break; // tolerate cpus taken offline
|
nod_ptr->new.sirq += cpu_ptr->new.sirq; nod_ptr->old.sirq += cpu_ptr->old.sirq;
|
||||||
}
|
nod_ptr->new.stolen += cpu_ptr->new.stolen; nod_ptr->old.stolen += cpu_ptr->old.stolen;
|
||||||
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
cpu_ptr->edge = sum_ptr->edge;
|
|
||||||
#endif
|
|
||||||
#ifdef PRETEND8CPUS
|
|
||||||
cpu_ptr->id = i;
|
|
||||||
#endif
|
|
||||||
#ifndef NUMA_DISABLE
|
|
||||||
/* henceforth, with just a little more arithmetic we can avoid
|
|
||||||
maintaining *any* node stats unless they're actually needed */
|
|
||||||
if (CHKw(Curwin, View_CPUNOD)
|
|
||||||
&& Numa_node_tot
|
|
||||||
&& -1 < (node = Numa_node_of_cpu(cpu_ptr->id))) {
|
|
||||||
// use our own pointer to avoid gcc subscript bloat
|
|
||||||
CPU_t *nod_ptr = sum_ptr + 1 + node;
|
|
||||||
nod_ptr->cur.u += cpu_ptr->cur.u; nod_ptr->sav.u += cpu_ptr->sav.u;
|
|
||||||
nod_ptr->cur.n += cpu_ptr->cur.n; nod_ptr->sav.n += cpu_ptr->sav.n;
|
|
||||||
nod_ptr->cur.s += cpu_ptr->cur.s; nod_ptr->sav.s += cpu_ptr->sav.s;
|
|
||||||
nod_ptr->cur.i += cpu_ptr->cur.i; nod_ptr->sav.i += cpu_ptr->sav.i;
|
|
||||||
nod_ptr->cur.w += cpu_ptr->cur.w; nod_ptr->sav.w += cpu_ptr->sav.w;
|
|
||||||
nod_ptr->cur.x += cpu_ptr->cur.x; nod_ptr->sav.x += cpu_ptr->sav.x;
|
|
||||||
nod_ptr->cur.y += cpu_ptr->cur.y; nod_ptr->sav.y += cpu_ptr->sav.y;
|
|
||||||
nod_ptr->cur.z += cpu_ptr->cur.z; nod_ptr->sav.z += cpu_ptr->sav.z;
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
/* yep, we re-value this repeatedly for each cpu encountered, but we
|
|
||||||
can then avoid a prior loop to selectively initialize each node */
|
|
||||||
nod_ptr->edge = sum_ptr->edge;
|
|
||||||
#endif
|
|
||||||
cpu_ptr->node = node;
|
|
||||||
#ifndef OFF_NUMASKIP
|
#ifndef OFF_NUMASKIP
|
||||||
nod_ptr->id = -1;
|
nod_ptr->id = -1;
|
||||||
#endif
|
#endif
|
||||||
|
/* note: the above call to Numa_node_of_cpu will produce a modest
|
||||||
|
* memory leak summarized as:
|
||||||
|
* ==1234== LEAK SUMMARY:
|
||||||
|
* ==1234== definitely lost: 512 bytes in 1 blocks
|
||||||
|
* ==1234== indirectly lost: 48 bytes in 2 blocks
|
||||||
|
* ==1234== ...
|
||||||
|
* it does *not* happen when PRETEND_NUMA has been defined
|
||||||
|
* [ thanks very much libnuma, for all the pain you've caused us ]
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} // end: for each cpu
|
|
||||||
|
|
||||||
Cpu_faux_tot = i; // tolerate cpus taken offline
|
return;
|
||||||
|
|
||||||
return cpus;
|
|
||||||
#undef sumSLOT
|
#undef sumSLOT
|
||||||
#undef totSLOT
|
#undef totSLOT
|
||||||
} // end: cpus_refresh
|
} // end: cpus_refresh
|
||||||
@ -3319,6 +3268,8 @@ static void before (char *me) {
|
|||||||
// prepare for new library API ...
|
// prepare for new library API ...
|
||||||
if (procps_meminfo_new(&mem_info) < 0)
|
if (procps_meminfo_new(&mem_info) < 0)
|
||||||
error_exit(N_txt(LIB_errormem_txt));
|
error_exit(N_txt(LIB_errormem_txt));
|
||||||
|
if (procps_stat_new(&sys_info) < 0)
|
||||||
|
error_exit(N_txt(LIB_errorsys_txt));
|
||||||
|
|
||||||
#ifndef OFF_HST_HASH
|
#ifndef OFF_HST_HASH
|
||||||
// prep for HST_t's put/get hashing optimizations
|
// prep for HST_t's put/get hashing optimizations
|
||||||
@ -5079,7 +5030,7 @@ all_done:
|
|||||||
* 2) modest smp boxes with room for each cpu's percentages
|
* 2) modest smp boxes with room for each cpu's percentages
|
||||||
* 3) massive smp guys leaving little or no room for process
|
* 3) massive smp guys leaving little or no room for process
|
||||||
* display and thus requiring the cpu summary toggle */
|
* display and thus requiring the cpu summary toggle */
|
||||||
static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
static void summary_hlp (struct procps_jiffs_hist *cpu, const char *pfx) {
|
||||||
/* we'll trim to zero if we get negative time ticks,
|
/* we'll trim to zero if we get negative time ticks,
|
||||||
which has happened with some SMP kernels (pre-2.4?)
|
which has happened with some SMP kernels (pre-2.4?)
|
||||||
and when cpus are dynamically added or removed */
|
and when cpus are dynamically added or removed */
|
||||||
@ -5087,22 +5038,16 @@ static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
|||||||
SIC_t u_frme, s_frme, n_frme, i_frme, w_frme, x_frme, y_frme, z_frme, tot_frme, tz;
|
SIC_t u_frme, s_frme, n_frme, i_frme, w_frme, x_frme, y_frme, z_frme, tot_frme, tz;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
u_frme = TRIMz(cpu->cur.u - cpu->sav.u);
|
u_frme = TRIMz(cpu->new.user - cpu->old.user);
|
||||||
s_frme = TRIMz(cpu->cur.s - cpu->sav.s);
|
s_frme = TRIMz(cpu->new.system - cpu->old.system);
|
||||||
n_frme = TRIMz(cpu->cur.n - cpu->sav.n);
|
n_frme = TRIMz(cpu->new.nice - cpu->old.nice);
|
||||||
i_frme = TRIMz(cpu->cur.i - cpu->sav.i);
|
i_frme = TRIMz(cpu->new.idle - cpu->old.idle);
|
||||||
w_frme = TRIMz(cpu->cur.w - cpu->sav.w);
|
w_frme = TRIMz(cpu->new.iowait - cpu->old.iowait);
|
||||||
x_frme = TRIMz(cpu->cur.x - cpu->sav.x);
|
x_frme = TRIMz(cpu->new.irq - cpu->old.irq);
|
||||||
y_frme = TRIMz(cpu->cur.y - cpu->sav.y);
|
y_frme = TRIMz(cpu->new.sirq - cpu->old.sirq);
|
||||||
z_frme = TRIMz(cpu->cur.z - cpu->sav.z);
|
z_frme = TRIMz(cpu->new.stolen - cpu->old.stolen);
|
||||||
tot_frme = u_frme + s_frme + n_frme + i_frme + w_frme + x_frme + y_frme + z_frme;
|
tot_frme = u_frme + s_frme + n_frme + i_frme + w_frme + x_frme + y_frme + z_frme;
|
||||||
#ifdef CPU_ZEROTICS
|
|
||||||
if (1 > tot_frme) tot_frme = 1;
|
|
||||||
#else
|
|
||||||
if (tot_frme < cpu->edge)
|
|
||||||
tot_frme = u_frme = s_frme = n_frme = i_frme = w_frme = x_frme = y_frme = z_frme = 0;
|
|
||||||
if (1 > tot_frme) i_frme = tot_frme = 1;
|
if (1 > tot_frme) i_frme = tot_frme = 1;
|
||||||
#endif
|
|
||||||
scale = 100.0 / (float)tot_frme;
|
scale = 100.0 / (float)tot_frme;
|
||||||
|
|
||||||
/* display some kinda' cpu state percentages
|
/* display some kinda' cpu state percentages
|
||||||
@ -5150,7 +5095,6 @@ static void summary_hlp (CPU_t *cpu, const char *pfx) {
|
|||||||
static void summary_show (void) {
|
static void summary_show (void) {
|
||||||
#define isROOM(f,n) (CHKw(w, f) && Msg_row + (n) < Screen_rows - 1)
|
#define isROOM(f,n) (CHKw(w, f) && Msg_row + (n) < Screen_rows - 1)
|
||||||
#define anyFLG 0xffffff
|
#define anyFLG 0xffffff
|
||||||
static CPU_t *smpcpu = NULL;
|
|
||||||
WIN_t *w = Curwin; // avoid gcc bloat with a local copy
|
WIN_t *w = Curwin; // avoid gcc bloat with a local copy
|
||||||
char tmp[MEDBUFSIZ];
|
char tmp[MEDBUFSIZ];
|
||||||
int i;
|
int i;
|
||||||
@ -5173,7 +5117,7 @@ static void summary_show (void) {
|
|||||||
, Frame_stopped, Frame_zombied));
|
, Frame_stopped, Frame_zombied));
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
|
|
||||||
smpcpu = cpus_refresh(smpcpu);
|
cpus_refresh();
|
||||||
|
|
||||||
#ifndef NUMA_DISABLE
|
#ifndef NUMA_DISABLE
|
||||||
if (!Numa_node_tot) goto numa_nope;
|
if (!Numa_node_tot) goto numa_nope;
|
||||||
@ -5181,11 +5125,11 @@ static void summary_show (void) {
|
|||||||
if (CHKw(w, View_CPUNOD)) {
|
if (CHKw(w, View_CPUNOD)) {
|
||||||
if (Numa_node_sel < 0) {
|
if (Numa_node_sel < 0) {
|
||||||
// display the 1st /proc/stat line, then the nodes (if room)
|
// display the 1st /proc/stat line, then the nodes (if room)
|
||||||
summary_hlp(&smpcpu[smp_num_cpus], N_txt(WORD_allcpus_txt));
|
summary_hlp(&Cpu_jiffs[smp_num_cpus], N_txt(WORD_allcpus_txt));
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
// display each cpu node's states
|
// display each cpu node's states
|
||||||
for (i = 0; i < Numa_node_tot; i++) {
|
for (i = 0; i < Numa_node_tot; i++) {
|
||||||
CPU_t *nod_ptr = &smpcpu[1 + smp_num_cpus + i];
|
struct procps_jiffs_hist *nod_ptr = &Cpu_jiffs[1 + smp_num_cpus + i];
|
||||||
if (!isROOM(anyFLG, 1)) break;
|
if (!isROOM(anyFLG, 1)) break;
|
||||||
#ifndef OFF_NUMASKIP
|
#ifndef OFF_NUMASKIP
|
||||||
if (nod_ptr->id) {
|
if (nod_ptr->id) {
|
||||||
@ -5200,13 +5144,13 @@ static void summary_show (void) {
|
|||||||
} else {
|
} else {
|
||||||
// display the node summary, then the associated cpus (if room)
|
// display the node summary, then the associated cpus (if room)
|
||||||
snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), Numa_node_sel);
|
snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), Numa_node_sel);
|
||||||
summary_hlp(&smpcpu[1 + smp_num_cpus + Numa_node_sel], tmp);
|
summary_hlp(&Cpu_jiffs[1 + smp_num_cpus + Numa_node_sel], tmp);
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
for (i = 0; i < Cpu_faux_tot; i++) {
|
for (i = 0; i < Cpu_faux_tot; i++) {
|
||||||
if (Numa_node_sel == smpcpu[i].node) {
|
if (Numa_node_sel == Numa_node_of_cpu(Cpu_jiffs[i].id)) {
|
||||||
if (!isROOM(anyFLG, 1)) break;
|
if (!isROOM(anyFLG, 1)) break;
|
||||||
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);
|
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_jiffs[i].id);
|
||||||
summary_hlp(&smpcpu[i], tmp);
|
summary_hlp(&Cpu_jiffs[i], tmp);
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5216,14 +5160,14 @@ numa_nope:
|
|||||||
#endif
|
#endif
|
||||||
if (CHKw(w, View_CPUSUM)) {
|
if (CHKw(w, View_CPUSUM)) {
|
||||||
// display just the 1st /proc/stat line
|
// display just the 1st /proc/stat line
|
||||||
summary_hlp(&smpcpu[Cpu_faux_tot], N_txt(WORD_allcpus_txt));
|
summary_hlp(&Cpu_jiffs[Cpu_faux_tot], N_txt(WORD_allcpus_txt));
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// display each cpu's states separately, screen height permitting...
|
// display each cpu's states separately, screen height permitting...
|
||||||
for (i = 0; i < Cpu_faux_tot; i++) {
|
for (i = 0; i < Cpu_faux_tot; i++) {
|
||||||
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);
|
snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), Cpu_jiffs[i].id);
|
||||||
summary_hlp(&smpcpu[i], tmp);
|
summary_hlp(&Cpu_jiffs[i], tmp);
|
||||||
Msg_row += 1;
|
Msg_row += 1;
|
||||||
if (!isROOM(anyFLG, 1)) break;
|
if (!isROOM(anyFLG, 1)) break;
|
||||||
}
|
}
|
||||||
|
40
top/top.h
40
top/top.h
@ -35,7 +35,6 @@
|
|||||||
//#define ATEOJ_RPTSTD /* report on misc stuff, at end-of-job */
|
//#define ATEOJ_RPTSTD /* report on misc stuff, at end-of-job */
|
||||||
//#define CASEUP_HEXES /* show any hex values in upper case */
|
//#define CASEUP_HEXES /* show any hex values in upper case */
|
||||||
//#define CASEUP_SUFIX /* show time/mem/cnts suffix in upper case */
|
//#define CASEUP_SUFIX /* show time/mem/cnts suffix in upper case */
|
||||||
//#define CPU_ZEROTICS /* tolerate few tics when cpu off vs. idle */
|
|
||||||
//#define EQUCOLHDRYES /* yes, do equalize column header lengths */
|
//#define EQUCOLHDRYES /* yes, do equalize column header lengths */
|
||||||
//#define INSP_JUSTNOT /* don't smooth unprintable right margins */
|
//#define INSP_JUSTNOT /* don't smooth unprintable right margins */
|
||||||
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
||||||
@ -81,10 +80,6 @@
|
|||||||
for nls support inclusion. They're identified with:
|
for nls support inclusion. They're identified with:
|
||||||
// nls_maybe */
|
// nls_maybe */
|
||||||
|
|
||||||
/* For initiating the topic of potential % CPU distortions due to
|
|
||||||
to kernel and/or cpu anomalies (see CPU_ZEROTICS), thanks to:
|
|
||||||
Jaromir Capik, <jcapik@redhat.com> - February, 2012 */
|
|
||||||
|
|
||||||
/* For the impetus and NUMA/Node prototype design, thanks to:
|
/* For the impetus and NUMA/Node prototype design, thanks to:
|
||||||
Lance Shelton <LShelton@fusionio.com> - April, 2013 */
|
Lance Shelton <LShelton@fusionio.com> - April, 2013 */
|
||||||
|
|
||||||
@ -176,13 +171,6 @@ char *strcasestr(const char *haystack, const char *needle);
|
|||||||
-- used at startup and for task/thread mode transitions */
|
-- used at startup and for task/thread mode transitions */
|
||||||
#define PROC_XTRA -1
|
#define PROC_XTRA -1
|
||||||
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
/* This is the % used in establishing the tics threshold below
|
|
||||||
which a cpu is treated as 'idle' rather than displaying
|
|
||||||
misleading state percentages */
|
|
||||||
#define TICS_EDGE 20
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* ##### Enum's and Typedef's ############################################ */
|
/* ##### Enum's and Typedef's ############################################ */
|
||||||
|
|
||||||
@ -268,32 +256,6 @@ typedef struct HST_t {
|
|||||||
} HST_t;
|
} HST_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* These 2 structures store a frame's cpu tics used in history
|
|
||||||
calculations. They exist primarily for SMP support but serve
|
|
||||||
all environments. */
|
|
||||||
typedef struct CT_t {
|
|
||||||
/* other kernels: u == user/us, n == nice/ni, s == system/sy, i == idle/id
|
|
||||||
2.5.41 kernel: w == IO-wait/wa (io wait time)
|
|
||||||
2.6.0 kernel: x == hi (hardware irq time), y == si (software irq time)
|
|
||||||
2.6.11 kernel: z == st (virtual steal time) */
|
|
||||||
TIC_t u, n, s, i, w, x, y, z; // as represented in /proc/stat
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
SIC_t tot; // total from /proc/stat line 1
|
|
||||||
#endif
|
|
||||||
} CT_t;
|
|
||||||
|
|
||||||
typedef struct CPU_t {
|
|
||||||
CT_t cur; // current frame's cpu tics
|
|
||||||
CT_t sav; // prior frame's cpu tics
|
|
||||||
#ifndef CPU_ZEROTICS
|
|
||||||
SIC_t edge; // tics adjustment threshold boundary
|
|
||||||
#endif
|
|
||||||
int id; // cpu number (0 - nn), or numa active flag
|
|
||||||
#ifndef NUMA_DISABLE
|
|
||||||
int node; // the numa node it belongs to
|
|
||||||
#endif
|
|
||||||
} CPU_t;
|
|
||||||
|
|
||||||
/* /////////////////////////////////////////////////////////////// */
|
/* /////////////////////////////////////////////////////////////// */
|
||||||
/* Special Section: multiple windows/field groups --------------- */
|
/* Special Section: multiple windows/field groups --------------- */
|
||||||
/* ( kind of a header within a header: constants, types & macros ) */
|
/* ( kind of a header within a header: constants, types & macros ) */
|
||||||
@ -730,7 +692,7 @@ typedef struct WIN_t {
|
|||||||
//atic inline void widths_resize (void);
|
//atic inline void widths_resize (void);
|
||||||
//atic void zap_fieldstab (void);
|
//atic void zap_fieldstab (void);
|
||||||
/*------ Library Interface ---------------------------------------------*/
|
/*------ Library Interface ---------------------------------------------*/
|
||||||
//atic CPU_t *cpus_refresh (CPU_t *cpus);
|
//atic void cpus_refresh (void);
|
||||||
#ifdef OFF_HST_HASH
|
#ifdef OFF_HST_HASH
|
||||||
//atic inline HST_t *hstbsrch (HST_t *hst, int max, int pid);
|
//atic inline HST_t *hstbsrch (HST_t *hst, int max, int pid);
|
||||||
#else
|
#else
|
||||||
|
@ -308,7 +308,6 @@ static void build_norm_nlstab (void) {
|
|||||||
Norm_nlstab[HELP_cmdline_fmt] = _(""
|
Norm_nlstab[HELP_cmdline_fmt] = _(""
|
||||||
" %s\n"
|
" %s\n"
|
||||||
"Usage:\n %s%s");
|
"Usage:\n %s%s");
|
||||||
Norm_nlstab[FAIL_statopn_fmt] = _("failed /proc/stat open: %s");
|
|
||||||
Norm_nlstab[FAIL_openlib_fmt] = _("failed openproc: %s");
|
Norm_nlstab[FAIL_openlib_fmt] = _("failed openproc: %s");
|
||||||
Norm_nlstab[BAD_delayint_fmt] = _("bad delay interval '%s'");
|
Norm_nlstab[BAD_delayint_fmt] = _("bad delay interval '%s'");
|
||||||
Norm_nlstab[BAD_niterate_fmt] = _("bad iterations argument '%s'");
|
Norm_nlstab[BAD_niterate_fmt] = _("bad iterations argument '%s'");
|
||||||
@ -326,7 +325,6 @@ static void build_norm_nlstab (void) {
|
|||||||
/* Translation Hint: Only the following words should be translated
|
/* Translation Hint: Only the following words should be translated
|
||||||
. secs (seconds), max (maximum), user, field, cols (columns)*/
|
. secs (seconds), max (maximum), user, field, cols (columns)*/
|
||||||
Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]");
|
Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]");
|
||||||
Norm_nlstab[FAIL_statget_txt] = _("failed /proc/stat read");
|
|
||||||
Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s");
|
Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s");
|
||||||
Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get");
|
Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get");
|
||||||
Norm_nlstab[FAIL_tty_set_fmt] = _("failed tty set: %s");
|
Norm_nlstab[FAIL_tty_set_fmt] = _("failed tty set: %s");
|
||||||
@ -473,6 +471,7 @@ static void build_norm_nlstab (void) {
|
|||||||
Norm_nlstab[WORD_abv_mem_txt] = _("Mem ");
|
Norm_nlstab[WORD_abv_mem_txt] = _("Mem ");
|
||||||
Norm_nlstab[WORD_abv_swp_txt] = _("Swap");
|
Norm_nlstab[WORD_abv_swp_txt] = _("Swap");
|
||||||
Norm_nlstab[LIB_errormem_txt] = _("library failed memory stats");
|
Norm_nlstab[LIB_errormem_txt] = _("library failed memory stats");
|
||||||
|
Norm_nlstab[LIB_errorsys_txt] = _("library failed system stats");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,22 +69,22 @@ enum norm_nls {
|
|||||||
COLORS_nomap_txt, DELAY_badarg_txt, DELAY_change_fmt, DELAY_secure_txt,
|
COLORS_nomap_txt, DELAY_badarg_txt, DELAY_change_fmt, DELAY_secure_txt,
|
||||||
DISABLED_cmd_txt, DISABLED_win_fmt, EXIT_signals_fmt, FAIL_alloc_c_txt,
|
DISABLED_cmd_txt, DISABLED_win_fmt, EXIT_signals_fmt, FAIL_alloc_c_txt,
|
||||||
FAIL_alloc_r_txt, FAIL_openlib_fmt, FAIL_rc_open_fmt, FAIL_re_nice_fmt,
|
FAIL_alloc_r_txt, FAIL_openlib_fmt, FAIL_rc_open_fmt, FAIL_re_nice_fmt,
|
||||||
FAIL_signals_fmt, FAIL_statget_txt, FAIL_statopn_fmt, FAIL_tty_get_txt,
|
FAIL_signals_fmt, FAIL_tty_get_txt, FAIL_tty_set_fmt, FAIL_widecpu_txt,
|
||||||
FAIL_tty_set_fmt, FAIL_widecpu_txt, FAIL_widepid_txt, FIND_no_find_fmt,
|
FAIL_widepid_txt, FIND_no_find_fmt, FIND_no_next_txt, FOREST_modes_fmt,
|
||||||
FIND_no_next_txt, FOREST_modes_fmt, FOREST_views_txt, GET_find_str_txt,
|
FOREST_views_txt, GET_find_str_txt, GET_max_task_fmt, GET_nice_num_fmt,
|
||||||
GET_max_task_fmt, GET_nice_num_fmt, GET_pid2kill_fmt, GET_pid2nice_fmt,
|
GET_pid2kill_fmt, GET_pid2nice_fmt, GET_sigs_num_fmt, GET_user_ids_txt,
|
||||||
GET_sigs_num_fmt, GET_user_ids_txt, HELP_cmdline_fmt, IRIX_curmode_fmt,
|
HELP_cmdline_fmt, IRIX_curmode_fmt, LIB_errormem_txt, LIB_errorsys_txt,
|
||||||
LIB_errormem_txt, LIMIT_exceed_fmt, MISSING_args_fmt, NAME_windows_fmt,
|
LIMIT_exceed_fmt, MISSING_args_fmt, NAME_windows_fmt, NOT_onsecure_txt,
|
||||||
NOT_onsecure_txt, NOT_smp_cpus_txt, NUMA_nodebad_txt, NUMA_nodeget_fmt,
|
NOT_smp_cpus_txt, NUMA_nodebad_txt, NUMA_nodeget_fmt, NUMA_nodenam_fmt,
|
||||||
NUMA_nodenam_fmt, NUMA_nodenot_txt, OFF_one_word_txt, ON_word_only_txt,
|
NUMA_nodenot_txt, OFF_one_word_txt, ON_word_only_txt, OSEL_casenot_txt,
|
||||||
OSEL_casenot_txt, OSEL_caseyes_txt, OSEL_errdelm_fmt, OSEL_errdups_txt,
|
OSEL_caseyes_txt, OSEL_errdelm_fmt, OSEL_errdups_txt, OSEL_errvalu_fmt,
|
||||||
OSEL_errvalu_fmt, OSEL_prompts_fmt, OSEL_statlin_fmt, RC_bad_entry_fmt,
|
OSEL_prompts_fmt, OSEL_statlin_fmt, RC_bad_entry_fmt, RC_bad_files_fmt,
|
||||||
RC_bad_files_fmt, SCROLL_coord_fmt, SELECT_clash_txt, THREADS_show_fmt,
|
SCROLL_coord_fmt, SELECT_clash_txt, THREADS_show_fmt, TIME_accumed_fmt,
|
||||||
TIME_accumed_fmt, UNKNOWN_cmds_txt, UNKNOWN_opts_fmt, USAGE_abbrev_txt,
|
UNKNOWN_cmds_txt, UNKNOWN_opts_fmt, USAGE_abbrev_txt, WORD_abv_mem_txt,
|
||||||
WORD_abv_mem_txt, WORD_abv_swp_txt, WORD_allcpus_txt, WORD_another_txt,
|
WORD_abv_swp_txt, WORD_allcpus_txt, WORD_another_txt, WORD_eachcpu_fmt,
|
||||||
WORD_eachcpu_fmt, WORD_exclude_txt, WORD_include_txt, WORD_noneone_txt,
|
WORD_exclude_txt, WORD_include_txt, WORD_noneone_txt, WORD_process_txt,
|
||||||
WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt,
|
WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt, XTRA_badflds_fmt,
|
||||||
XTRA_badflds_fmt, XTRA_fixwide_fmt, XTRA_warncfg_txt, XTRA_winsize_txt,
|
XTRA_fixwide_fmt, XTRA_warncfg_txt, XTRA_winsize_txt,
|
||||||
#ifndef INSP_OFFDEMO
|
#ifndef INSP_OFFDEMO
|
||||||
YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt,
|
YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt,
|
||||||
YINSP_deqtyp_txt, YINSP_dstory_txt,
|
YINSP_deqtyp_txt, YINSP_dstory_txt,
|
||||||
|
Loading…
Reference in New Issue
Block a user