From 7df87ea7cfedef095646ea64bae79ea6121cca83 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sat, 20 Aug 2016 00:00:00 -0500 Subject: [PATCH] top: when setting library flags favor stat over status Long ago, in a galaxy far away, top was convinced that /proc/stat was to be favored over /proc/status if some field could be satisfied with either. This was done to avoid extra costs of 64-bit math for 32-bit platforms. Well, its time to acknowledge the prevalence of 64-bit platforms. And in such an environment there is a large hidden cost currently if using status instead of stat. In fact, that cost difference can be as high as 1400%. So, this commit will coax top into favoring that least costly route while also fixing an EU_TGD library flag. [ this patch parallels similar changes to newlib top ] Signed-off-by: Jim Warner --- top/top.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/top/top.c b/top/top.c index c95985aa..48a6b715 100644 --- a/top/top.c +++ b/top/top.c @@ -1772,7 +1772,7 @@ static FLD_t Fieldstab[] = { { -1, -1, A_left, SF(CGR), L_CGROUP }, { -1, -1, A_left, SF(SGD), L_status }, { -1, -1, A_left, SF(SGN), L_SUPGRP }, - { 0, -1, A_right, SF(TGD), L_status }, + { 0, -1, A_right, SF(TGD), L_NONE }, { 5, -1, A_right, SF(OOA), L_OOM }, { 4, -1, A_right, SF(OOM), L_OOM }, { -1, -1, A_left, SF(ENV), L_ENVIRON }, @@ -1965,8 +1965,10 @@ static void build_headers (void) { #endif // finalize/touchup the libproc PROC_FILLxxx flags for current config... - if ((Frames_libflags & L_EITHER) && !(Frames_libflags & L_stat)) - Frames_libflags |= L_status; + if (Frames_libflags & L_EITHER) { + if (!(Frames_libflags & (L_stat | L_status))) + Frames_libflags |= L_stat; + } if (!Frames_libflags) Frames_libflags = L_DEFAULT; if (Monpidsidx) Frames_libflags |= PROC_PID; } // end: build_headers