diff options
author | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2024-03-09 09:14:39 -0500 |
---|---|---|
committer | Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | 2024-03-09 09:14:39 -0500 |
commit | 6037d364c820f2189151087a29037b3dc55d3870 (patch) | |
tree | 7e5f65710ea3a05a0807d0cd2ccfcf1241cb17a8 | |
parent | c6fd3981cbad0498f0e1f8c2b9d9fe09b7c993f2 (diff) | |
download | librseq-6037d364c820f2189151087a29037b3dc55d3870.tar.gz |
mempool: Introduce rseq_mempool_get_max_nr_cpus
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ibd5a7abf40e56d8e57c7b51a5dd9495c51bd9624
-rw-r--r-- | include/rseq/mempool.h | 9 | ||||
-rw-r--r-- | src/rseq-mempool.c | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/rseq/mempool.h b/include/rseq/mempool.h index 3bfff1a..1b3c944 100644 --- a/include/rseq/mempool.h +++ b/include/rseq/mempool.h @@ -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 diff --git a/src/rseq-mempool.c b/src/rseq-mempool.c index a7f57d6..d0ed492 100644 --- a/src/rseq-mempool.c +++ b/src/rseq-mempool.c @@ -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; +} |