From 11b87c73edb16d4e4fcbebd9c93e69fb47973116 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 7c7903e50dff8719408b2a95d75f94ec1407aff7 Signed-off-by: Jim Warner --- top/top.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/top/top.c b/top/top.c index ad508a97..ee8d265e 100644 --- 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