From 4a44f9e3fa966476a142d134e4af677965953f9c Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 18 Jul 2018 00:00:00 -0500 Subject: [PATCH] top: ensure collapsed children cpu reported accurately 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 --- top/top.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index 49c44e60..81ec54b8 100644 --- 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;