]> 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:27:44 +0000 (21:27 +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 3da7318683d2fea10526384e0a4368a378b486a5

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

index 49c44e60e927be930937c771133baa40e32f19b7..81ec54b83dd8a3659b2510a350b758a0652f39ce 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -6001,7 +6001,9 @@ static const char *task_show (const WIN_t *q, const int idx) {
          case EU_CPU:
          {  float u = (float)p->pcpu;
 #ifndef TREE_VCPUOFF
-            // Hide_cpu entry is always zero, unless we're a collapsed parent
+ #ifndef TREE_VWINALL
+            if (q == Curwin)   // note: the following is NOT indented
+ #endif
             if (CHKw(q, Show_FOREST)) u += Hide_cpu[idx];
             u *= Frame_etscale;
             if (p->pad_2 != 'x' && u > 100.0 * p->nlwp) u = 100.0 * p->nlwp;