From: Jim Warner Date: Wed, 18 Jul 2018 05:00:00 +0000 (-0500) Subject: top: ensure collapsed children cpu reported accurately X-Git-Tag: v3.3.16~43 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a44f9e3fa966476a142d134e4af677965953f9c;p=procps-ng 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 --- 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;