]> granicus.if.org Git - procps-ng/commitdiff
top: adapt former PRETEND8CPUS #define as PRETEND48CPU
authorJim Warner <james.warner@comcast.net>
Sun, 24 May 2020 16:25:01 +0000 (11:25 -0500)
committerCraig Small <csmall@dropbear.xyz>
Thu, 28 May 2020 09:49:40 +0000 (19:49 +1000)
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 <james.warner@comcast.net>
top/top.c
top/top.h

index f59af63034e99a2c86db27f95b37f50b20b3ee8b..f5076e40b7062de41da1af1c9f7232d56c5074b2 100644 (file)
--- 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;
             }
          }
index f0ce564b465ce4298e787f6cfff8163a4b611074..3decada69e23b1c4b7ae260d6e8bf1f36d3db04c 100644 (file)
--- 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 */