aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>2024-03-05 08:42:54 -0500
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>2024-03-05 08:42:54 -0500
commit6b30db4e78a3ebe2c925c2336996aef894bf241a (patch)
tree4ba91699f7d5587cc4f25a47430475f8c33d1c57
parent9bd07c29b38b5005cbbd78033c78e5440db7ce20 (diff)
downloadlibrseq-6b30db4e78a3ebe2c925c2336996aef894bf241a.tar.gz
percpu allocator: Add flags argument for future extensions
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I4c507a99351c450ef2c6396af5391f019f8e3d91
-rw-r--r--include/rseq/percpu-alloc.h6
-rw-r--r--src/rseq-percpu-alloc.c8
-rw-r--r--tests/param_test.c12
3 files changed, 18 insertions, 8 deletions
diff --git a/include/rseq/percpu-alloc.h b/include/rseq/percpu-alloc.h
index 28362f8..95638af 100644
--- a/include/rseq/percpu-alloc.h
+++ b/include/rseq/percpu-alloc.h
@@ -56,6 +56,9 @@ struct rseq_percpu_pool;
* after rseq_percpu_pool_create() returns. The caller keeps ownership
* of @mmap_attr.
*
+ * Argument @flags is currently expected to be 0. This is for future
+ * extensions.
+ *
* Returns a pointer to the created percpu pool. Return NULL on error,
* with errno set accordingly:
* EINVAL: Invalid argument.
@@ -70,7 +73,8 @@ struct rseq_percpu_pool;
*/
struct rseq_percpu_pool *rseq_percpu_pool_create(size_t item_len,
size_t percpu_len, int max_nr_cpus,
- const struct rseq_mmap_attr *mmap_attr);
+ const struct rseq_mmap_attr *mmap_attr,
+ int flags);
/*
* rseq_percpu_pool_destroy: Destroy a per-cpu memory pool.
diff --git a/src/rseq-percpu-alloc.c b/src/rseq-percpu-alloc.c
index 052ea01..eced0f7 100644
--- a/src/rseq-percpu-alloc.c
+++ b/src/rseq-percpu-alloc.c
@@ -208,7 +208,8 @@ int default_munmap_func(void *priv __attribute__((unused)), void *ptr, size_t le
struct rseq_percpu_pool *rseq_percpu_pool_create(size_t item_len,
size_t percpu_len, int max_nr_cpus,
- const struct rseq_mmap_attr *mmap_attr)
+ const struct rseq_mmap_attr *mmap_attr,
+ int flags)
{
void *(*mmap_func)(void *priv, size_t len);
int (*munmap_func)(void *priv, void *ptr, size_t len);
@@ -218,6 +219,11 @@ struct rseq_percpu_pool *rseq_percpu_pool_create(size_t item_len,
unsigned int i;
int order;
+ if (flags) {
+ errno = EINVAL;
+ return NULL;
+ }
+
/* Make sure each item is large enough to contain free list pointers. */
if (item_len < sizeof(void *))
item_len = sizeof(void *);
diff --git a/tests/param_test.c b/tests/param_test.c
index 54ee067..a8fb1b9 100644
--- a/tests/param_test.c
+++ b/tests/param_test.c
@@ -500,7 +500,7 @@ static void test_percpu_spinlock(void)
struct rseq_percpu_pool *mempool;
mempool = rseq_percpu_pool_create(sizeof(struct spinlock_test_data),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();
@@ -595,7 +595,7 @@ static void test_percpu_inc(void)
struct rseq_percpu_pool *mempool;
mempool = rseq_percpu_pool_create(sizeof(struct inc_test_data),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();
@@ -768,7 +768,7 @@ static void test_percpu_list(void)
struct rseq_percpu_pool *mempool;
mempool = rseq_percpu_pool_create(sizeof(struct percpu_list),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();
@@ -979,7 +979,7 @@ static void test_percpu_buffer(void)
struct rseq_percpu_pool *mempool;
mempool = rseq_percpu_pool_create(sizeof(struct percpu_buffer),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();
@@ -1219,7 +1219,7 @@ static void test_percpu_memcpy_buffer(void)
struct rseq_percpu_pool *mempool;
mempool = rseq_percpu_pool_create(sizeof(struct percpu_memcpy_buffer),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();
@@ -1453,7 +1453,7 @@ void *test_membarrier_manager_thread(void *arg)
int ret;
mempool = rseq_percpu_pool_create(sizeof(struct percpu_list),
- PERCPU_POOL_LEN, CPU_SETSIZE, NULL);
+ PERCPU_POOL_LEN, CPU_SETSIZE, NULL, 0);
if (!mempool) {
perror("rseq_percpu_pool_create");
abort();