laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/40782?usp=email )

Change subject: Add environment variable to set io_uring size
......................................................................

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(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  lynxis lazus: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified




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 https://gerrit.osmocom.org/c/libosmocore/+/40782?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I55289d9282e13aa1bf82f3931c85c196752f1484
Gerrit-Change-Number: 40782
Gerrit-PatchSet: 8
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: lynxis lazus <lyn...@fe80.eu>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>

Reply via email to