From 2ca99a2ee4538ea7662555b2190cf12064456542 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 24 May 2020 11:25:01 -0500 Subject: [PATCH] top: adapt former PRETEND8CPUS #define as PRETEND48CPU This patch simply allows for better testing of our two new toggles: '4' (2 abreast) plus '!' (combined cpus). It had previously been dropped under the newlib branch since top no longer managed cpus. However, now that we have those new toggles, it seemed worth the efforts to once again re-imagine then implement such a provision. Signed-off-by: Jim Warner --- top/top.c | 23 ++++++++++++++++++++++- top/top.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index f59af630..f5076e40 100644 --- a/top/top.c +++ b/top/top.c @@ -2336,8 +2336,12 @@ static void cpus_refresh (void) { Numa_node_tot = Stat_reap->nodes->total; Numa_node_sel = -1; } - if (Stat_reap->cpus->total && Stat_reap->cpus->total != Cpu_cnt) + if (Stat_reap->cpus->total && Stat_reap->cpus->total != Cpu_cnt) { Cpu_cnt = Stat_reap->cpus->total; +#ifdef PRETEND48CPU + Cpu_cnt = 48; +#endif + } return; } // end: cpus_refresh @@ -3233,6 +3237,9 @@ static void before (char *me) { error_exit(fmtmk(N_fmt(LIB_errorcpu_fmt),__LINE__, strerror(errno))); Numa_node_tot = Stat_reap->nodes->total; Cpu_cnt = Stat_reap->cpus->total; +#ifdef PRETEND48CPU + Cpu_cnt = 48; +#endif // prepare for memory stats from new library API ... if ((rc = procps_meminfo_new(&Mem_ctx))) @@ -5516,7 +5523,11 @@ numa_oops: if (i == Numa_node_tot) goto numa_oops; snprintf(tmp, sizeof(tmp), N_fmt(NUMA_nodenam_fmt), Numa_node_sel); Msg_row += cpu_tics(Stat_reap->nodes->stacks[Numa_node_sel], tmp, 1); +#ifdef PRETEND48CPU + for (i = 0; i < Stat_reap->cpus->total; i++) { +#else for (i = 0; i < Cpu_cnt; i++) { +#endif if (Numa_node_sel == CPU_VAL(stat_NU, i)) { if (!isROOM(anyFLG, 1)) break; snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), CPU_VAL(stat_ID, i)); @@ -5534,13 +5545,23 @@ numa_nope: // display each cpu's states separately, screen height permitting... if (w->combine_cpus) { for (i = 0; i < Cpu_cnt; i++) { +#ifdef PRETEND48CPU + Stat_reap->summary->head[stat_ID].result.s_int = i; + Msg_row += cpu_unify(Stat_reap->summary, (i+1 >= Cpu_cnt)); +#else Msg_row += cpu_unify(Stat_reap->cpus->stacks[i], (i+1 >= Cpu_cnt)); +#endif if (!isROOM(anyFLG, 1)) break; } } else { for (i = 0; i < Cpu_cnt; i++) { +#ifdef PRETEND48CPU + snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), i); + Msg_row += cpu_tics(Stat_reap->summary, tmp, (i+1 >= Cpu_cnt)); +#else snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), CPU_VAL(stat_ID, i)); Msg_row += cpu_tics(Stat_reap->cpus->stacks[i], tmp, (i+1 >= Cpu_cnt)); +#endif if (!isROOM(anyFLG, 1)) break; } } diff --git a/top/top.h b/top/top.h index f0ce564b..3decada6 100644 --- a/top/top.h +++ b/top/top.h @@ -38,6 +38,7 @@ //#define OFF_STDERROR /* disable our stderr buffering (redirect) */ //#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */ //#define OFF_XTRAWIDE /* disable our extra wide multi-byte logic */ +//#define PRETEND48CPU /* pretend we're smp with 48 ticsers (sic) */ //#define PRETENDNOCAP /* use a terminal without essential caps */ //#define QUICK_GRAPHS /* use fast algorithm, accept +2% distort */ //#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */