From 0f691226ecaf706fbf7f1a28c9430bced88a3004 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 21 Apr 2021 00:00:00 -0500 Subject: [PATCH] library: lower addr resolution cost for TICS_ALL_DELTA Rather than run risks of more expensive and repetitive address resolution, we will establish this local index for a one time cost and avoid any potential gcc bloat. [ this commit was made in pursuit of a bug involving ] [ the distortion of elapsed task tics. but, it turns ] [ out these changes had nothing to do with that bug. ] [ however, the patch is being retained as desirable. ] Signed-off-by: Jim Warner --- proc/pids.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/proc/pids.c b/proc/pids.c index bc4761bf..77e5b071 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -626,23 +626,23 @@ static inline int pids_make_hist ( struct pids_info *info, proc_t *p) { - #define nSLOT info->hist->num_tasks TIC_t tics; HST_t *h; + int slot = info->hist->num_tasks; - if (nSLOT + 1 >= Hr(HHist_siz)) { + if (slot + 1 >= Hr(HHist_siz)) { Hr(HHist_siz) += NEWOLD_GROW; Hr(PHist_sav) = realloc(Hr(PHist_sav), sizeof(HST_t) * Hr(HHist_siz)); Hr(PHist_new) = realloc(Hr(PHist_new), sizeof(HST_t) * Hr(HHist_siz)); if (!Hr(PHist_sav) || !Hr(PHist_new)) return 0; } - Hr(PHist_new[nSLOT].pid) = p->tid; - Hr(PHist_new[nSLOT].maj) = p->maj_flt; - Hr(PHist_new[nSLOT].min) = p->min_flt; - Hr(PHist_new[nSLOT].tics) = tics = (p->utime + p->stime); + Hr(PHist_new[slot].pid) = p->tid; + Hr(PHist_new[slot].maj) = p->maj_flt; + Hr(PHist_new[slot].min) = p->min_flt; + Hr(PHist_new[slot].tics) = tics = (p->utime + p->stime); - pids_histput(info, nSLOT); + pids_histput(info, slot); if ((h = pids_histget(info, p->tid))) { p->pcpu = tics - h->tics; @@ -650,9 +650,8 @@ static inline int pids_make_hist ( p->min_delta = p->min_flt - h->min; } - nSLOT++; + info->hist->num_tasks++; return 1; - #undef nSLOT } // end: pids_make_hist