Attention is currently required from: jolly.
Hello Jenkins Builder, laforge, pespin,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/40493?usp=email
to look at the new patch set (#12).
The following approvals got outdated and were removed:
Verified+1 by Jenkins Builder
The change is no longer submittable: Verified is unsatisfied now.
Change subject: Add multiple messages buffers to io_uring write operations
......................................................................
Add multiple messages buffers to io_uring write operations
Multiple message buffers can be writen by sending a single SQE when
using io_uring. If there is less data written, the completely written
buffers are removed and the partly written buffers are truncated.
Afterwards they are re-queued for next write operation.
Having more than one buffer is optional and the number can be controlled
via environment variable.
Related: OS#6705
Change-Id: I8c4e0a785cf66becd7fb5b2caf718c9724b56686
---
M src/core/osmo_io.c
M src/core/osmo_io_uring.c
2 files changed, 103 insertions(+), 46 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/40493/12
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40493?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I8c4e0a785cf66becd7fb5b2caf718c9724b56686
Gerrit-Change-Number: 40493
Gerrit-PatchSet: 12
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Attention is currently required from: jolly.
Hello Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmocore/+/40854?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Verified-1 by Jenkins Builder
Change subject: osmo_io: Add unit test to verify segmentation process
......................................................................
osmo_io: Add unit test to verify segmentation process
Change-Id: I7d8feba9c8e8386c9fd144669f6ccd01d6bbbabb
---
M tests/osmo_io/osmo_io_test.c
M tests/osmo_io/osmo_io_test.ok
2 files changed, 126 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/40854/2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40854?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7d8feba9c8e8386c9fd144669f6ccd01d6bbbabb
Gerrit-Change-Number: 40854
Gerrit-PatchSet: 2
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Jenkins Builder has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmocore/+/40854?usp=email )
Change subject: osmo_io: Add unit test to verify segmentation process
......................................................................
Patch Set 1:
(1 comment)
File tests/osmo_io/osmo_io_test.c:
Robot Comment from checkpatch (run ID ):
https://gerrit.osmocom.org/c/libosmocore/+/40854/comment/efd1b6d6_da5c03ad?… :
PS1, Line 274: if (seg_number == 1) {
braces {} are not necessary for any arm of this statement
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40854?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I7d8feba9c8e8386c9fd144669f6ccd01d6bbbabb
Gerrit-Change-Number: 40854
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-CC: Jenkins Builder
Gerrit-Comment-Date: Fri, 08 Aug 2025 14:07:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Attention is currently required from: laforge, pespin.
jolly has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmocore/+/40725?usp=email )
Change subject: Automatically increase io_uring, if too small.
......................................................................
Patch Set 10:
(7 comments)
Commit Message:
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/e95cf057_9b995286?… :
PS9, Line 23: to determine when all submissions are completed.
> Sounds like an easy thing to add right? It makes sense to implement this either her eor on a follow- […]
I added a counter in a different patch and destry old rings, once empty. I hope that all cancelled SQE will be completed, not only the cancellation SQEs. If not, the ring would not be destroyed, so this would not cause any harm.
File src/core/osmo_io_internal.h:
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/a700383a_0fecc145?… :
PS9, Line 110: bool read_enabled;
> (At some point it may make sense to properly put all these fields into a "read" and "write" substruc […]
There is a later patch that does this.
File src/core/osmo_io_uring.c:
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/64de0ab5_adfed9dc?… :
PS2, Line 175:
> ok, then please mention this fact explicitly in this c ommit in a TODO-comment and also in the commi […]
I added the comments. I think that a counter cannot be used, as we don't know if we get one or two CQEs after cancelling an SQE. We always get the CQE for the cancellation SQE. If an SQE gets completed while sending a cancellation, we get two CQEs.
File src/core/osmo_io_uring.c:
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/123a753e_15996863?… :
PS9, Line 126: g_ring = talloc_zero(OTC_GLOBAL, struct osmo_io_uring);
> are you sure OTC_GLOBAL is defined at this point? Or is it actually NULL? […]
IT is definitly defined and not NULL.
The contructor in context.c
"static __attribute__((constructor(101))) void on_dso_load_ctx(void)"
has higher priority than any other constructor, including the initialization of osmo_io_uring.
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/3368db83_9e78fefb?… :
PS9, Line 175: g_io_uring_size *= 2;
> Once you move this to an unsigned, you can do "<< 1" here. […]
Done, see previous patch.
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/c1be736e_aafa80c0?… :
PS9, Line 208: /* All subsequent read SQEs must be on the same ring. */
> This should imho go inside iofd_uring_get_sqe(), based on "current_ring" being passed to it.
iofd_uring_get_sqe() has no knowledge about the iofd, so it doesn't know if there are SQEs already submitted to a different ring than the current one.
(iofd->u.uring.read_ring)
https://gerrit.osmocom.org/c/libosmocore/+/40725/comment/69b446a2_baf1f6fc?… :
PS9, Line 282: while (iofd->u.uring.reads_submitted < ((iofd->u.uring.num_read_sqes) ? : g_io_uring_read_sqes)) {
> why is the g_io_uring_read_sqes reference needed here? How can iofd have num_read_sqes = 0, and if i […]
g_io_uring_read_sques is 1 by default. This can be changed by environment variable, to allow benchmarking. The user may also define the number of of SQEs via API. This should override the default or what has been set by envrironment variable.
if iofd instance is created, num_read_sqes (read.num_sques now) is not set by the user, so that it is 0.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40725?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id9230146acc8d54bfd44834e783c31b37bd64bca
Gerrit-Change-Number: 40725
Gerrit-PatchSet: 10
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 08 Aug 2025 13:57:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: jolly <andreas(a)eversberg.eu>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: pespin.
jolly has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmocore/+/40782?usp=email )
Change subject: Add environment variable to set io_uring size
......................................................................
Patch Set 3:
(5 comments)
File src/core/osmo_io_uring.c:
https://gerrit.osmocom.org/c/libosmocore/+/40782/comment/1151667d_1b343984?… :
PS1, Line 111: g_io_uring_size = atoi(env);
> This should be parsed with osmo_str_to_int() to make sure we don't use some weird value as a result […]
Done
File src/core/osmo_io_uring.c:
https://gerrit.osmocom.org/c/libosmocore/+/40782/comment/c7a16338_69ba78d6?… :
PS2, Line 66: static int g_io_uring_size = IOFD_URING_INITIAL_SIZE;
> size_t
Actually "unsigned int".
https://gerrit.osmocom.org/c/libosmocore/+/40782/comment/a0644196_69463f83?… :
PS2, Line 111: rc = osmo_str_to_int(&g_io_uring_size, env, 10, 1, 32768);
> I wonder where 32768 comes from :D
This is the maximum. I added a comment.
https://gerrit.osmocom.org/c/libosmocore/+/40782/comment/35f4b3c6_8164f3c4?… :
PS2, Line 116: if ((g_io_uring_size & (g_io_uring_size - 1))) {
> if (g_io_uring_size & 0x01)
This condition hits at an odd value. We need a condition that hits if it is not a power of two.
https://gerrit.osmocom.org/c/libosmocore/+/40782/comment/66a2c722_52ae26fc?… :
PS2, Line 117: fprintf(stderr, "Error: Initial io_uring size must be a positive power of two.\n");
> Is this really needed as per io_uring API?
It is not required, because the setup function will round it up to the power of two. Without the check the user would believe that the ring size equals the env settings.
--
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: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I55289d9282e13aa1bf82f3931c85c196752f1484
Gerrit-Change-Number: 40782
Gerrit-PatchSet: 3
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 08 Aug 2025 13:57:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Attention is currently required from: laforge.
jolly has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmocore/+/40760?usp=email )
Change subject: osmo-io: Put together message buffers when dequeued from tx queue
......................................................................
Patch Set 4:
(1 comment)
File src/core/osmo_io.c:
https://gerrit.osmocom.org/c/libosmocore/+/40760/comment/2ec59388_27c8ad09?… :
PS3, Line 261: * There can be empty buffers, when a msghdr is queued to the front with incomplete write. */
> do we have some unit test coverage for those rather hard-to-trigger code paths? I think it's hard to […]
I tried to trigger an incomplete write, so that it is re-queued in front of the tx_queue. With regular non-nblocking IO it is possible to have partly written buffers, but with io_uring this seems not to happen. This means that this condition is never true, as there is no msghdr with unused write buffers in front of another msghdr.
I prefer to remove it, since it is just an optimization. It is not required, even if io_uring would return an incomplete write.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40760?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I97c366211dd266fd58ec252890ec017d6d334534
Gerrit-Change-Number: 40760
Gerrit-PatchSet: 4
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Fri, 08 Aug 2025 13:57:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/40855?usp=email )
Change subject: Remove old empty io_uring
......................................................................
Remove old empty io_uring
A previous patch creates a new io_uring, if it becomes too small to
store all SQEs. When all SQEs of the old ring are completed, the old
ring will be destroyed.
A counter is incremented whenever an SQE is submitted to an io_uring.
The counter is decrements whenever a CQE is received and handled. This
counter will determine when a ring is empty and can be destroyed.
Related: OS#6705
Change-Id: Id2d2a0400ad442198c684ea0ead4eaeaead4c53d
---
M src/core/osmo_io_uring.c
1 file changed, 27 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/55/40855/1
diff --git a/src/core/osmo_io_uring.c b/src/core/osmo_io_uring.c
index 1a817dd..a867968 100644
--- a/src/core/osmo_io_uring.c
+++ b/src/core/osmo_io_uring.c
@@ -65,7 +65,7 @@
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_size = IOFD_URING_INITIAL_SIZE;
static int g_io_uring_read_sqes = 1;
@@ -73,6 +73,7 @@
struct osmo_fd event_ofd;
struct io_uring ring;
struct llist_head cancel_queue;
+ unsigned int in_flight;
};
static __thread struct osmo_io_uring *g_ring = NULL;
@@ -167,13 +168,27 @@
}
}
+static void osmo_iofd_uring_exit(struct osmo_io_uring *ring)
+{
+ LOGP(DLIO, LOGL_DEBUG, "Old empty io_uring will be destroyed.");
+
+ io_uring_queue_exit(&ring->ring);
+
+ osmo_fd_unregister(&ring->event_ofd);
+ close(ring->event_ofd.fd);
+
+ talloc_free(ring);
+}
+
static struct io_uring_sqe *iofd_uring_get_sqe(bool current_ring)
{
struct io_uring_sqe *sqe;
sqe = io_uring_get_sqe(&g_ring->ring);
- if (sqe)
+ if (sqe) {
+ g_ring->in_flight++;
return sqe;
+ }
if (g_io_uring_size < IOFD_URING_MAXIMUM_SIZE) {
LOGP(DLIO, LOGL_NOTICE, "io_uring too small to handle all SQEs with its current size of %d. "
@@ -197,6 +212,7 @@
sqe = io_uring_get_sqe(&g_ring->ring);
OSMO_ASSERT(sqe);
+ g_ring->in_flight++;
return sqe;
}
@@ -424,6 +440,7 @@
struct osmo_io_uring *orig_ring = container_of(ring, struct osmo_io_uring, ring);
while (io_uring_peek_cqe(ring, &cqe) == 0) {
+ orig_ring->in_flight--;
msghdr = io_uring_cqe_get_data(cqe);
if (!msghdr) {
@@ -448,13 +465,18 @@
}
/* If there are unsubmitted cancel SQEs, try to queue them now. */
- if (OSMO_LIKELY(llist_empty(&orig_ring->cancel_queue)))
+ if (OSMO_LIKELY(llist_empty(&orig_ring->cancel_queue))) {
+ /* Old ring is empty, remove it. */
+ if (OSMO_UNLIKELY(orig_ring != g_ring && orig_ring->in_flight == 0))
+ osmo_iofd_uring_exit(orig_ring);
return;
+ }
llist_for_each_entry_safe(msghdr, msghdr2, &orig_ring->cancel_queue, list) {
struct io_uring_sqe *sqe;
sqe = io_uring_get_sqe(&orig_ring->ring);
if (!sqe)
break;
+ orig_ring->in_flight++;
io_uring_sqe_set_data(sqe, NULL);
LOGP(DLIO, LOGL_DEBUG, "Cancelling queued read/write\n");
io_uring_prep_cancel(sqe, msghdr, 0);
@@ -462,7 +484,6 @@
msghdr->in_cancel_queue = false;
}
io_uring_submit(&orig_ring->ring);
-
}
/*! will submit the next to-be-transmitted message for given iofd */
@@ -584,6 +605,7 @@
/* If the submission queue is full, use cancel queue. We cannot cancel SQEs on the new ring. */
sqe = io_uring_get_sqe(&ring->ring);
if (sqe) {
+ ring->in_flight++;
io_uring_sqe_set_data(sqe, NULL);
LOGPIO(iofd, LOGL_DEBUG, "Cancelling read\n");
io_uring_prep_cancel(sqe, msghdr, 0);
@@ -614,6 +636,7 @@
/* If the submission queue is full, use cancel queue. We cannot cancel SQEs on the new ring. */
sqe = io_uring_get_sqe(&ring->ring);
if (sqe) {
+ ring->in_flight++;
io_uring_sqe_set_data(sqe, NULL);
LOGPIO(iofd, LOGL_DEBUG, "Cancelling write\n");
io_uring_prep_cancel(sqe, msghdr, 0);
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/40855?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id2d2a0400ad442198c684ea0ead4eaeaead4c53d
Gerrit-Change-Number: 40855
Gerrit-PatchSet: 1
Gerrit-Owner: jolly <andreas(a)eversberg.eu>