]> granicus.if.org Git - procps-ng/commitdiff
library: lower addr resolution cost for TICS_ALL_DELTA
authorJim Warner <james.warner@comcast.net>
Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Sat, 24 Apr 2021 01:11:03 +0000 (11:11 +1000)
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 <james.warner@comcast.net>
proc/pids.c

index bc4761bf44e39a33b2fdfde66de6fbfb1e3b9a75..77e5b071826b8101dffd92d68768fa8dfa5f0aa9 100644 (file)
@@ -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