From 10503c03d426f2b37f9237149debfed77d413c68 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 1 Jun 2016 00:00:00 -0500 Subject: [PATCH] top: make more responsive when toggling cpu off/online Using the 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 --- top/top.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/top/top.c b/top/top.c index e8a1a782..db3ed6ef 100644 --- 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 /*###### Inspect Other Output ##########################################*/