Skip to content
Success

Changes

Summary

  1. Allow io_uring_submit batching just ahead of poll/select (details)
  2. Avoid reusing pending buffer; append incoming data instead (details)
  3. osmo_io: Add unit test to verify segmentation process (details)
  4. Add multiple messages buffers to struct iofd_msghdr (details)
  5. Add multiple messages buffers to io_uring read operations (details)
  6. Add multiple messages buffers to io_uring write operations (details)
  7. osmo-io: Put together message buffers when dequeued from tx queue (details)
  8. Send multiple read/recvfrom/recvmsg SQEs in advance (details)
  9. Add environment variable to set io_uring size (details)
  10. Automatically increase io_uring, if too small. (details)
  11. Remove old empty io_uring (details)
  12. Put all io_uring related read and write states into sub structures (details)
Commit 6b851c3bb04ca368dec916d59f5ec4aadf0ad6bc by laforge
Allow io_uring_submit batching just ahead of poll/select

Let's add a mode (enabled via the LIBOSMO_IO_URING_BATCH environment
variable), where we don't call io_uring_submit() after every operation
we add to the submission queue.  Rather, do that once before we go into
poll.

This should massively reduce the amount of io_uring_enter() syscalls
we're seeing.

Related: OS#6705
Change-Id: Id34fe2ced32c63d15b14810e145744f7509064cc
The file was modifiedsrc/core/osmo_io_uring.c
The file was modifiedsrc/core/select.c
Commit 01ae6dbed8c15182ad262bbab50ba4d23f3aaaa8 by laforge
Avoid reusing pending buffer; append incoming data instead

When reading from a stream, a single read may return only part of a
message segment. In such cases, the partial data was stored in
'iofd->pending' and reused for subsequent reads to complete the message.

With upcoming changes that submit multiple read SQEs to io_uring,
each read uses its own pre-submitted buffer. Reusing 'iofd->pending' for
submitting next read is not possible, as the next read buffer is already
submitted.

Instead, create a new msgb which is used for the read operation and,
once completed, memcopy to the existing pending buffer, allowing message
segments to accumulate until complete.

Change-Id: I08df9736ccc5e9a7df61ca6dcf94629ee010752f
The file was modifiedsrc/core/osmo_io_poll.c
The file was modifiedsrc/core/osmo_io.c
The file was modifiedsrc/core/osmo_io_internal.h
The file was modifiedsrc/core/osmo_io_uring.c
Commit 086ee51de416ae5276b4b185c055831e16c0ef85 by laforge
osmo_io: Add unit test to verify segmentation process

Change-Id: I7d8feba9c8e8386c9fd144669f6ccd01d6bbbabb
The file was modifiedtests/osmo_io/osmo_io_test.c
The file was modifiedtests/osmo_io/osmo_io_test.ok
Commit 7c10401b3553fe19c4b010d91e15bc0bd4f46e3b by laforge
Add multiple messages buffers to struct iofd_msghdr

This is a prerequisite for transfering multiple buffers with a single
SQE or CQE when using osmo_io with io_uring.

The message buffers at struct iofd_msghr, as well as the io vectors are
arrays. A maximum number is stored, as well as the current number.

As this patch does not implement multiple buffers yet, only index 0 of a
message buffer is used. (msg[0])

Having more than one buffer is optional and the number can be controlled
via environment variable.

Related: OS#6705
Change-Id: I4fb1067de4615cc22cc6caf99b481491e7f2ef92
The file was modifiedsrc/core/libosmocore.map
The file was modifiedsrc/core/osmo_io_internal.h
The file was modifiedsrc/core/osmo_io_poll.c
The file was modifiedinclude/osmocom/core/osmo_io.h
The file was modifiedsrc/core/osmo_io.c
The file was modifiedsrc/core/osmo_io_uring.c
Commit 76ace3ef1999551944e173e7b48d7b259abf4322 by laforge
Add multiple messages buffers to io_uring read operations

Multiple message buffers can be read by receiving a single CQE when
using io_uring. If there is less data available than available buffers,
not all buffers will be filled.

Having more than one buffer is optional and the number can be controlled
via environment variable.

Related: OS#6705
Change-Id: Ic4544b8fcbad5a266db748d6864d3ae93ee06bce
The file was modifiedsrc/core/osmo_io_uring.c
The file was modifiedsrc/core/osmo_io.c
Commit 2e75e6892765155d55bc2bfedc5000949d6eaa89 by laforge
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
The file was modifiedsrc/core/osmo_io.c
The file was modifiedsrc/core/osmo_io_uring.c
Commit 3c2a02db40046933b143a69d75cb2691a1208fbd by laforge
osmo-io: Put together message buffers when dequeued from tx queue

Write operations may be incomplete. osmo-io processs will remove
complete message buffers after a write operation from msghdr and put
the msghdr with the remaining buffers back into tx_queue.

If the user requests multiple messages buffers per write operation, the
msghdr of an incomplete write may have less message buffers than the
user requested. The remaining buffers are buffers are taken from next
msghdr in the queue, if exists.

Change-Id: I97c366211dd266fd58ec252890ec017d6d334534
The file was modifiedsrc/core/osmo_io.c
Commit 8a1588aa71cdd49e8db8c2bc9722766338e6ed6a by laforge
Send multiple read/recvfrom/recvmsg SQEs in advance

Multiple read or recvfrom operations can be submitted via SQEs when
using io_uring. This allows reading multiple packet / more data between
calls of osmo_select_main() the main loop.

Having more than one SQE submitted is optional and the number can be
controlled via environment variable.

Related: OS#6705
Change-Id: Id50a8900fa2fe6de553e5025feae7e1e8d501e30
The file was modifiedsrc/core/osmo_io_uring.c
The file was modifiedsrc/core/libosmocore.map
The file was modifiedsrc/core/osmo_io.c
The file was modifiedinclude/osmocom/core/osmo_io.h
The file was modifiedsrc/core/osmo_io_internal.h
Commit aa980b74961ed4f392d766a95a77f27789943f26 by laforge
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
The file was modifiedsrc/core/osmo_io_uring.c
Commit a63991d41cc41959d71c1d98413cc3349a7c7305 by laforge
Automatically increase io_uring, if too small.

The ring may be too small to store all SQEs before the kernel can
handle them. If this happens, a new ring is allocated with twice of the
size of the old ring. The old ring will not be destroyed, as it still
contains uncompleted elements. Some of them may never be completed.

A pointer to the current ring will be stored within the msghdr
structure. It is used when cancelling an SQE. The cancellation must be
performed in the same ring where it was created.

It is quite unlikely that the old ring cannot store the cancellation
SQE. If this happens, the cancellation is queued and submitted, once
the ring can store it.

The old ring will not be removed, because there is currently no counter
to determine when all submissions are completed.

Related: OS#6705
Change-Id: Id9230146acc8d54bfd44834e783c31b37bd64bca
The file was modifiedsrc/core/osmo_io_uring.c
The file was modifiedsrc/core/osmo_io_internal.h
Commit 56a346335f36a6c0aea60b7c0f32409116bbafe1 by laforge
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 decremented 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
The file was modifiedsrc/core/osmo_io_uring.c
Commit 7d7c6bee96d81e31f205ce593b4e9b8042994653 by laforge
Put all io_uring related read and write states into sub structures

Related: OS#6705
Change-Id: I3cf4ab6d9aebf5532ad174c90c7b0e9633491c88
The file was modifiedsrc/core/osmo_io_internal.h
The file was modifiedsrc/core/osmo_io.c
The file was modifiedsrc/core/osmo_io_uring.c