laforge submitted this change.
Add environment variable to set io_uring size
The term "LIBOSMO_IO_URING_INITIAL_SIZE" is related to the following
patch, which will increment the size of the io_uring automatically if
the initial size is too small.
Related: OS#6705
Change-Id: I55289d9282e13aa1bf82f3931c85c196752f1484
---
M src/core/osmo_io_uring.c
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/core/osmo_io_uring.c b/src/core/osmo_io_uring.c
index 1eaa5e6..48f6f0d 100644
--- a/src/core/osmo_io_uring.c
+++ b/src/core/osmo_io_uring.c
@@ -52,15 +52,21 @@
#include "osmo_io_internal.h"
-#define IOFD_URING_ENTRIES 4096
+#define IOFD_URING_INITIAL_SIZE 4096
+/* 32768 refers to the IORING_MAX_ENTRIES of the kernel (io_uring/io_uring.h). */
+#define IOFD_URING_MAXIMUM_SIZE 32768
#define OSMO_IO_URING_BATCH "LIBOSMO_IO_URING_BATCH"
+#define OSMO_IO_URING_INITIAL_SIZE "LIBOSMO_IO_URING_INITIAL_SIZE"
+
#define OSMO_IO_URING_READ_SQE "LIBOSMO_IO_URING_READ_SQE"
bool g_io_uring_batch = false;
bool g_io_uring_submit_needed = false;
+static unsigned int g_io_uring_size = IOFD_URING_INITIAL_SIZE;
+
static int g_io_uring_read_sqes = 1;
struct osmo_io_uring {
@@ -103,7 +109,22 @@
if ((env = getenv(OSMO_IO_URING_BATCH)))
g_io_uring_batch = true;
- rc = io_uring_queue_init(IOFD_URING_ENTRIES, &g_ring.ring, 0);
+ if ((env = getenv(OSMO_IO_URING_INITIAL_SIZE))) {
+ int env_value;
+ rc = osmo_str_to_int(&env_value, env, 10, 1, IOFD_URING_MAXIMUM_SIZE);
+ if (rc < 0) {
+ fprintf(stderr, "Error: Initial io_uring size out of range (1..%d).\n",
+ IOFD_URING_MAXIMUM_SIZE);
+ exit(1);
+ }
+ if ((env_value & (env_value - 1))) {
+ fprintf(stderr, "Error: Initial io_uring size must be a positive power of two.\n");
+ exit(1);
+ }
+ g_io_uring_size = env_value;
+ }
+
+ rc = io_uring_queue_init(g_io_uring_size, &g_ring.ring, 0);
if (rc < 0)
osmo_panic("failure during io_uring_queue_init(): %s\n", strerror(-rc));
To view, visit change 40782. To unsubscribe, or for help writing mail filters, visit settings.