]> granicus.if.org Git - procps-ng/commitdiff
top: make more responsive when toggling cpu off/online
authorJim Warner <james.warner@comcast.net>
Wed, 1 Jun 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Tue, 7 Jun 2016 10:49:30 +0000 (20:49 +1000)
Using the <STAT> api under the newlib branch, that top
program is very responsive to changes in the number of
on-line cpus. However under the master branch this top
program is very responsive only to losses of some cpu.

When a cpu is brought back on-line potential delays of
60 seconds could be encountered. That delay was simply
an attempt to reduce costs and reflected the erroneous
assumption that adding a cpu required physical effort.

So without redesigning the cpu refresh code to emulate
that of newlib, this commit just reduces the potential
delay to 3 seconds (the same that is used for memory).

[ As an aside, if one wants to have their confidence ]
[ in that htop program badly shaken, try taking some ]
[ cpus off-line & on-line again while it is running. ]

[ Poor ol' htop just continues to report results for ]
[ whatever were the cpus when started. Nice feature, ]
[ but I wonder where those phantom results are from. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index e8a1a7825c170fa9281982e35cf9f6f5de6859fa..db3ed6ef5587eda87bbbd4f72eadf9c01d72cc4f 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -2694,30 +2694,26 @@ static void procs_refresh (void) {
          * portion of libproc.  In support of those hotpluggable resources,
          * the sampling frequencies are reduced so as to minimize overhead. */
 static void sysinfo_refresh (int forced) {
-   static time_t mem_secs, cpu_secs;
+   static time_t sav_secs;
    time_t cur_secs;
 
    if (forced)
-      mem_secs = cpu_secs = 0;
+      sav_secs = 0;
    cur_secs = time(NULL);
 
    /*** hotplug_acclimated ***/
-   if (3 <= cur_secs - mem_secs) {
+   if (3 <= cur_secs - sav_secs) {
       meminfo();
-      mem_secs = cur_secs;
-   }
 #ifndef PRETEND8CPUS
-   /*** hotplug_acclimated ***/
-   if (60 <= cur_secs - cpu_secs) {
       cpuinfo();
       Cpu_faux_tot = smp_num_cpus;
-      cpu_secs = cur_secs;
 #ifndef NUMA_DISABLE
       if (Libnuma_handle)
          Numa_node_tot = Numa_max_node() + 1;
 #endif
-   }
 #endif
+      sav_secs = cur_secs;
+   }
 } // end: sysinfo_refresh
 \f
 /*######  Inspect Other Output  ##########################################*/