mempool: Introduce rseq_mempool_get_max_nr_cpus
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 9 Mar 2024 14:14:39 +0000 (09:14 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 9 Mar 2024 14:14:39 +0000 (09:14 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibd5a7abf40e56d8e57c7b51a5dd9495c51bd9624

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

index 3bfff1a2e51c418ffc019968c389100db232b28c..1b3c9444f0618cc2ef911a2f9ed3634e9080c8b9 100644 (file)
@@ -470,6 +470,15 @@ int rseq_mempool_attr_set_global(struct rseq_mempool_attr *attr, size_t stride);
  */
 int rseq_mempool_range_init_numa(void *addr, size_t len, int cpu, int numa_flags);
 
+/*
+ * rseq_mempool_get_max_nr_cpus: Get the max_nr_cpus value configured for a pool.
+ *
+ * Returns a value >= 0 for a per-cpu pool.
+ * Returns -1, errno=EINVAL if the mempool is NULL or if the pool has a
+ * global pool type.
+ */
+int rseq_mempool_get_max_nr_cpus(struct rseq_mempool *mempool);
+
 #ifdef __cplusplus
 }
 #endif
index a7f57d634e8c1620433c3282a60245f84f06605f..d0ed49290ce996b58036cee37ad13185b69a0821 100644 (file)
@@ -872,3 +872,12 @@ int rseq_mempool_attr_set_global(struct rseq_mempool_attr *attr,
        attr->max_nr_cpus = 0;
        return 0;
 }
+
+int rseq_mempool_get_max_nr_cpus(struct rseq_mempool *mempool)
+{
+       if (!mempool || mempool->attr.type != MEMPOOL_TYPE_PERCPU) {
+               errno = EINVAL;
+               return -1;
+       }
+       return mempool->attr.max_nr_cpus;
+}
This page took 0.026269 seconds and 4 git commands to generate.