]> granicus.if.org Git - procps-ng/commitdiff
library: changes to some numa stuff in that <stat> api
authorJim Warner <james.warner@comcast.net>
Wed, 24 Jun 2020 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Thu, 25 Jun 2020 10:08:22 +0000 (20:08 +1000)
Now that we may be getting serious with documentation,
that stat module was revisited with an eye toward user
friendliness. Heck, even this author puzzled over some
of the existing notes and naming conventions employed.

So, this patch will adjust some identifiers and expand
the notes to (hopefully) better serve potential users.

The most significant change was making the STAT_TIC_ID
always valid for numa nodes, even if any are inactive.

Thus the -22222 special STAT_NODE_INVALID constant now
is applied only to STAT_TIC_NUMA_NODE. It will be used
on the cpu summary and reaps with STAT_REAP_CPUS_ONLY.
And it will also mark any numa node that was inactive.

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/stat.c
proc/stat.h

index c837dd4b500218926826cc3eced9c1234efa80f7..d889f554177472d8374aadbec7a4c860746e8ab2 100644 (file)
@@ -493,7 +493,8 @@ static int stat_make_numa_hist (
     memset(info->nodes.hist.tics, 0, info->nodes.hist.n_alloc * sizeof(struct hist_tic));
     nod_ptr = info->nodes.hist.tics;
     for (i = 0; i < info->nodes.total; i++) {
-        nod_ptr->id = nod_ptr->numa_node = STAT_NODE_INVALID;
+        nod_ptr->numa_node = STAT_NODE_INVALID;
+        nod_ptr->id = i;
         ++nod_ptr;
     }
 
@@ -519,8 +520,7 @@ static int stat_make_numa_hist (
             nod_ptr->new.xusr += cpu_ptr->new.xusr;  nod_ptr->old.xusr += cpu_ptr->old.xusr;
             nod_ptr->new.xsys += cpu_ptr->new.xsys;  nod_ptr->old.xsys += cpu_ptr->old.xsys;
 
-            cpu_ptr->numa_node = node;
-            nod_ptr->id = node;
+            cpu_ptr->numa_node = nod_ptr->numa_node = node;
             nod_ptr->count++; ;
         }
     }
@@ -866,7 +866,7 @@ PROCPS_EXPORT int procps_stat_new (
     p->refcount = 1;
 
     p->results.cpus = &p->cpus.result;
-    p->results.nodes = &p->nodes.result;
+    p->results.numa = &p->nodes.result;
 
     // these 3 are for reap, sharing a single set of items
     p->cpu_summary.items = p->cpus.fetch.items = p->nodes.fetch.items = &p->reap_items;
@@ -1010,7 +1010,7 @@ PROCPS_EXPORT struct stat_reaped *procps_stat_reap (
     errno = EINVAL;
     if (info == NULL || items == NULL)
         return NULL;
-    if (what != STAT_REAP_CPUS_ONLY && what != STAT_REAP_CPUS_AND_NODES)
+    if (what != STAT_REAP_CPUS_ONLY && what != STAT_REAP_NUMA_NODES_TOO)
         return NULL;
 
 #ifdef ENFORCE_LOGICAL
@@ -1048,7 +1048,7 @@ PROCPS_EXPORT struct stat_reaped *procps_stat_reap (
             if (0 > stat_stacks_fetch(info, &info->cpus))
                 return NULL;
             break;
-        case STAT_REAP_CPUS_AND_NODES:
+        case STAT_REAP_NUMA_NODES_TOO:
             /* note: if we're doing numa at all, we must do this numa history |
                before we build (fetch) cpu stacks since that stat_read_failed |
                guy always marks (temporarily) all the cpu node ids as invalid | */
index 9da05fe0d86eb19e94edc714e8c65ab9517b3a49..b4f19b210d2b6cbcfafbad393567fe067f215f29 100644 (file)
@@ -28,8 +28,8 @@ enum stat_item {
     STAT_extra,                   //        ( reset to zero )
                                   //  returns        origin, see proc(5)
                                   //  -------        -------------------
-    STAT_TIC_ID,                  //    s_int        /proc/stat
-    STAT_TIC_NUMA_NODE,           //    s_int      [ ID based, see: numa(3) ]
+    STAT_TIC_ID,                  //    s_int        /proc/stat, cpu or numa node id
+    STAT_TIC_NUMA_NODE,           //    s_int      [ CPU ID based, see: numa(3) ]
     STAT_TIC_NUM_CONTRIBUTORS,    //    s_int      [ total CPUs contributing to TIC counts ]
 
     STAT_TIC_USER,                //  ull_int        /proc/stat
@@ -82,7 +82,7 @@ enum stat_item {
 
 enum stat_reap_type {
     STAT_REAP_CPUS_ONLY,
-    STAT_REAP_CPUS_AND_NODES
+    STAT_REAP_NUMA_NODES_TOO
 };
 
 enum stat_sort_order {
@@ -113,13 +113,17 @@ struct stat_reap {
 struct stat_reaped {
     struct stat_stack *summary;
     struct stat_reap *cpus;
-    struct stat_reap *nodes;
+    struct stat_reap *numa;
 };
 
 
+    // STAT_TIC_ID value for /proc/stat cpu summary
 #define STAT_SUMMARY_ID    -11111
+    // STAT_TIC_NUMA_NODE value for STAT_REAP_CPUS_ONLY or
+    // for STAT_REAP_NUMA_NODES_TOO when node was inactive
 #define STAT_NODE_INVALID  -22222
 
+
 #define STAT_GET( info, actual_enum, type ) ( { \
     struct stat_result *r = procps_stat_get( info, actual_enum ); \
     r ? r->result . type : 0; } )