]> granicus.if.org Git - procps-ng/commitdiff
top: ensure collapsed children cpu reported accurately
authorJim Warner <james.warner@comcast.net>
Wed, 18 Jul 2018 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 1 Aug 2018 11:38:44 +0000 (21:38 +1000)
Parent tasks with collapsed children should have their
cpu reflect any unseen tasks only under the following:

1) When built without TREE_VCPUOFF having been defined

2) Exclusively when 'Show_FOREST' display mode was set

3) And only under the current window when in alternate
display mode (except if TREE_VWINALL has been defined)

So, this commit just ensures these objectives are met.

Reference(s):
. issue that began odyssey
https://gitlab.com/procps-ng/procps/issues/99
. original cpu implementation
commit 7c7903e50dff8719408b2a95d75f94ec1407aff7

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

index ad508a9786db4515abb9f30e27e7c879db60dd5e..ee8d265e5e8f2ed61484e666c93c65041671d241 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -5590,8 +5590,10 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
          {  float u = (float)rSv(EU_CPU, s_int);
             int n = rSv(EU_THD, s_int);
 #ifndef TREE_VCPUOFF
-            // this eu_TREE_ADD is always zero, unless we're a collapsed parent
-            u += rSv(eu_TREE_ADD, u_int);
+ #ifndef TREE_VWINALL
+            if (q == Curwin)   // note: the following is NOT indented
+ #endif
+            if (CHKw(q, Show_FOREST)) u += rSv(eu_TREE_ADD, u_int);
             u *= Frame_etscale;
             if (rSv(eu_TREE_HID, s_ch) != 'x' && u > 100.0 * n) u = 100.0 * n;
 #else