]> granicus.if.org Git - procps-ng/commitdiff
top: reduce function call overhead in the NUMA support
authorJim Warner <james.warner@comcast.net>
Mon, 13 May 2013 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 18 May 2013 23:40:41 +0000 (09:40 +1000)
Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c
top/top.h

index 01ea383544dc884f2b457592af52199ef4b126bf..042e5fe72ec38f80bc42a32f139082a1b992f07e 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -2406,6 +2406,7 @@ static CPU_t *cpus_refresh (CPU_t *cpus) {
 #ifndef NUMA_DISABLE
       if (Numa_node_tot
       && -1 < (node = Numa_node_of_cpu(cpus[i].id))) {
+         cpus[i].node = node;
          node += (sumSLOT + 1);
          cpus[node].cur.u += cpus[i].cur.u;
          cpus[node].cur.n += cpus[i].cur.n;
@@ -5037,7 +5038,7 @@ static void summary_show (void) {
             summary_hlp(&smpcpu[1 + smp_num_cpus + Numa_node_sel], tmp);
             Msg_row += 1;
             for (i = 0; i < Cpu_faux_tot; i++) {
-               if (Numa_node_sel == Numa_node_of_cpu(smpcpu[i].id)) {
+               if (Numa_node_sel == smpcpu[i].node) {
                   if (!isROOM(anyFLG, 1)) break;
                   snprintf(tmp, sizeof(tmp), N_fmt(WORD_eachcpu_fmt), smpcpu[i].id);
                   summary_hlp(&smpcpu[i], tmp);
index 7c595348212719cd62e7d9ef5a3092066280dabb..01434ed0eec2dc52b63eac8b49ea56244b2ce0fe 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -276,6 +276,9 @@ typedef struct CPU_t {
    SIC_t edge;                    // tics adjustment threshold boundary
 #endif
    int id;                        // the cpu id number (0 - nn)
+#ifndef NUMA_DISABLE
+   int node;                      // the numa node it belongs to
+#endif
 } CPU_t;
 
         /* /////////////////////////////////////////////////////////////// */