Advertisement
Guest User

Untitled

a guest
Jun 5th, 2025
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. diff --git a/src/backend/storage/aio/method_io_uring.c b/src/backend/storage/aio/method_io_uring.c
  2. index c719ba2727a..f2c1ad3ef81 100644
  3. --- a/src/backend/storage/aio/method_io_uring.c
  4. +++ b/src/backend/storage/aio/method_io_uring.c
  5. @@ -29,6 +29,7 @@
  6.  
  7. #ifdef IOMETHOD_IO_URING_ENABLED
  8.  
  9. +#include <sys/mman.h>
  10. #include <liburing.h>
  11.  
  12. #include "miscadmin.h"
  13. @@ -128,6 +129,8 @@ pgaio_uring_shmem_init(bool first_time)
  14. {
  15. int TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS - MAX_IO_WORKERS;
  16. bool found;
  17. + size_t ring_sizes;
  18. + void *ring_ptr, *cur;
  19.  
  20. pgaio_uring_contexts = (PgAioUringContext *)
  21. ShmemInitStruct("AioUring", pgaio_uring_shmem_size(), &found);
  22. @@ -135,10 +138,15 @@ pgaio_uring_shmem_init(bool first_time)
  23. if (found)
  24. return;
  25.  
  26. + ring_sizes = 16 * 1024 * 1024;
  27. + ring_ptr = mmap(NULL, ring_sizes, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS|MAP_HUGETLB, -1, 0);
  28. + cur = ring_ptr;
  29. +
  30. for (int contextno = 0; contextno < TotalProcs; contextno++)
  31. {
  32. PgAioUringContext *context = &pgaio_uring_contexts[contextno];
  33. int ret;
  34. + struct io_uring_params p = { .flags = IORING_SETUP_NO_MMAP, };
  35.  
  36. /*
  37. * Right now a high TotalProcs will cause problems in two ways:
  38. @@ -158,7 +166,7 @@ pgaio_uring_shmem_init(bool first_time)
  39. * be worth using that - also need to evaluate if that causes
  40. * noticeable additional contention?
  41. */
  42. - ret = io_uring_queue_init(io_max_concurrency, &context->io_uring_ring, 0);
  43. + ret = io_uring_queue_init_mem(io_max_concurrency, &context->io_uring_ring, &p, cur, ring_sizes);
  44. if (ret < 0)
  45. {
  46. char *hint = NULL;
  47. @@ -190,7 +198,8 @@ pgaio_uring_shmem_init(bool first_time)
  48. errmsg("could not setup io_uring queue: %m"),
  49. hint != NULL ? errhint("%s", hint) : 0);
  50. }
  51. -
  52. + ring_sizes -= ret;
  53. + cur += ret;
  54. LWLockInitialize(&context->completion_lock, LWTRANCHE_AIO_URING_COMPLETION);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement