rseq: Introduce rseq_get_max_nr_cpus
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 9 Mar 2024 14:40:27 +0000 (09:40 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 9 Mar 2024 14:40:27 +0000 (09:40 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie7d24470994b3a6ec805bfec7111ff3492b46997

include/rseq/rseq.h
src/rseq-mempool.c
src/rseq.c

index ea795c4cdea74142a9419628e65ca448efb4cc1c..8db0b899b2d24a4606df4c4704f8596e6bdde714 100644 (file)
@@ -128,6 +128,14 @@ int32_t rseq_fallback_current_node(void);
  */
 bool rseq_available(unsigned int query);
 
+/*
+ * rseq_get_max_nr_cpus: Get the max_nr_cpus auto-detected value.
+ *
+ * Returns the max_nr_cpus auto-detected at pool creation when invoked
+ * with @nr_max_cpus=0 argument.
+ */
+int rseq_get_max_nr_cpus(void);
+
 /*
  * Values returned can be either the current CPU number, -1 (rseq is
  * uninitialized), or -2 (rseq initialization has failed).
index d0ed49290ce996b58036cee37ad13185b69a0821..e2e22a6a51f49c8629575daeb60f3cfe923cf411 100644 (file)
@@ -20,7 +20,7 @@
 #endif
 
 #include "rseq-utils.h"
-#include "smp.h"
+#include <rseq/rseq.h>
 
 /*
  * rseq-mempool.c: rseq CPU-Local Storage (CLS) memory allocator.
@@ -537,7 +537,7 @@ struct rseq_mempool *rseq_mempool_create(const char *pool_name,
                }
                if (attr.max_nr_cpus == 0) {
                        /* Auto-detect */
-                       attr.max_nr_cpus = get_possible_cpus_array_len();
+                       attr.max_nr_cpus = rseq_get_max_nr_cpus();
                        if (attr.max_nr_cpus == 0) {
                                errno = EINVAL;
                                return NULL;
index af5c5de310b3b3f83a8b837c68ba30456ae06c2a..ae72eaa22f556b64a0d763eaa179e9e4960c0162 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/auxvec.h>
 
 #include <rseq/rseq.h>
+#include "smp.h"
 
 #ifndef AT_RSEQ_FEATURE_SIZE
 # define AT_RSEQ_FEATURE_SIZE          27
@@ -288,3 +289,8 @@ int32_t rseq_fallback_current_node(void)
        }
        return (int32_t) node_id;
 }
+
+int rseq_get_max_nr_cpus(void)
+{
+       return get_possible_cpus_array_len();
+}
This page took 0.025153 seconds and 4 git commands to generate.