Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/backend/storage/aio/method_io_uring.c b/src/backend/storage/aio/method_io_uring.c
- index c719ba2727a..f2c1ad3ef81 100644
- --- a/src/backend/storage/aio/method_io_uring.c
- +++ b/src/backend/storage/aio/method_io_uring.c
- @@ -29,6 +29,7 @@
- #ifdef IOMETHOD_IO_URING_ENABLED
- +#include <sys/mman.h>
- #include <liburing.h>
- #include "miscadmin.h"
- @@ -128,6 +129,8 @@ pgaio_uring_shmem_init(bool first_time)
- {
- int TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS - MAX_IO_WORKERS;
- bool found;
- + size_t ring_sizes;
- + void *ring_ptr, *cur;
- pgaio_uring_contexts = (PgAioUringContext *)
- ShmemInitStruct("AioUring", pgaio_uring_shmem_size(), &found);
- @@ -135,10 +138,15 @@ pgaio_uring_shmem_init(bool first_time)
- if (found)
- return;
- + ring_sizes = 16 * 1024 * 1024;
- + ring_ptr = mmap(NULL, ring_sizes, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS|MAP_HUGETLB, -1, 0);
- + cur = ring_ptr;
- +
- for (int contextno = 0; contextno < TotalProcs; contextno++)
- {
- PgAioUringContext *context = &pgaio_uring_contexts[contextno];
- int ret;
- + struct io_uring_params p = { .flags = IORING_SETUP_NO_MMAP, };
- /*
- * Right now a high TotalProcs will cause problems in two ways:
- @@ -158,7 +166,7 @@ pgaio_uring_shmem_init(bool first_time)
- * be worth using that - also need to evaluate if that causes
- * noticeable additional contention?
- */
- - ret = io_uring_queue_init(io_max_concurrency, &context->io_uring_ring, 0);
- + ret = io_uring_queue_init_mem(io_max_concurrency, &context->io_uring_ring, &p, cur, ring_sizes);
- if (ret < 0)
- {
- char *hint = NULL;
- @@ -190,7 +198,8 @@ pgaio_uring_shmem_init(bool first_time)
- errmsg("could not setup io_uring queue: %m"),
- hint != NULL ? errhint("%s", hint) : 0);
- }
- -
- + ring_sizes -= ret;
- + cur += ret;
- LWLockInitialize(&context->completion_lock, LWTRANCHE_AIO_URING_COMPLETION);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement