Commit Graph

15 Commits

Author SHA1 Message Date
Harald Welte 5215cb93e3 HACK: Allow io_uring_submit batching just ahead of poll
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.

Change-Id: Ia27ada909df246f21d110d8ae0b40229aacd579d
2024-03-19 22:10:08 +01:00
Andreas Eversberg 9c0004ad0d Fix file descriptor that is passed to io_uring_register_eventfd()
Fix Change-Id I03752c0114cc6fad0c31fff6fff43072f36a50a7

Change-Id: Ie085c7cb3eb57e0da10485be8f90208cb41b0073
2024-03-14 13:10:35 +01:00
Vadim Yanitskiy 61906936f9 core: fix missing '\n' in iofd_uring_connected_cb()
Change-Id: I43df86cdbd3e52d4f8f7bc0e48478b6f9b288e9f
2024-03-14 09:11:11 +00:00
Harald Welte 9c604f4738 io_uring: check all operations in osmo_iofd_uring_init()
check all operations in osmo_iofd_uring_init() and panic if any of them
fails.

Change-Id: I03752c0114cc6fad0c31fff6fff43072f36a50a7
2024-03-14 08:22:28 +01:00
Harald Welte 5fcfbe0c69 io_uring: more verbose error messages if io_uring setup fails
"Assert failed 0 osmo_io_uring.c:94" is rather useless in terms of an
error message.  Let's improve upon that.

Change-Id: I0ac9ae59e99c3704b3ce33919c9e7d11024476e3
2024-03-14 08:22:28 +01:00
Andreas Eversberg ada88ce655 osmo_io_uring: Check if osmo_fd_register fails at iofd_uring_notify_connected()
If it fails, do not set the IOFD_FLAG_NOTIFY_CONNECTED flag and log an
error message.

Closes: Coverity CID#349579
Change-Id: I34e8cc9a2b9df0c624841e5f9268a15c32418da1
2024-03-02 09:29:10 +00:00
Andreas Eversberg 0f123aa6fc osmo_io_uring: Detach msghdr from iofd before calling iofd_handle_send_completion()
msghdr must be detached, because subsequent callback at
iofd_handle_send_completion() may destroy the iofd (which in turn
frees this msghdr, if still attached) and frees the msghdr, causing a
double free.

Related: OS#5751
Change-Id: Ia349f73de2145fa360b20dd40deb73a8ffc71f07
2024-02-29 09:15:38 +01:00
Andreas Eversberg 8db6009a3a osmo_io_uring: Cancel pending request, free msghdr on completion
There is always a completion after cancelling a uring request.

Because uring requests use msghdr pointer as user data, we cannot just
free the msghdr after cancelling. Upon completion (received after
cancelling), the user data still points to the msghdr. To prevent a
use-after-free bug, msghdr is not freed, but detached from iofd
instance. Then upon completion, the msghdr (if it was detached from
iofd) is freed.

Additionally it is not required to keep IOFD_FLAG_IN_CALLBACK set
anymore, if there is a msghdr attached to iofd. As described above,
all msghdr get detached, if iofd is freed (uring request get cancelled)
during callback.

Related: OS#5751
Change-Id: Ic253f085dd6362db85f029f46350951472210a02
2024-02-28 16:43:07 +01:00
Andreas Eversberg d7256c6c19 osmo_io: Use poll/select to notify socket connection at osmo_io_uring.c
In order to receive a connect notification from SCTP socket,
poll/select event must be used instead of a write notification via
io_uring completion event.

Once the connect notification has been received, subsequent write
notifications via io_uring are used.

Change-Id: I4eca9ea72beb0d6ea4d44cce81ed620033f07270
Related: OS#5751
2024-02-28 16:42:58 +01:00
Harald Welte 1047ed7255 osmo_io: sendmsg/recvmsg support
Add support osmo_io operations resembling sendmsg() and recvmsg() socket
operations.  This is what will enable the implementation of higher-layer
functions like equivalents of sctp_recvmsg() and sctp_send() in
libosmo-netif and/or other users.

Change-Id: I89eb519b22d21011d61a7855b2364bc3c295df82
Related: OS#5751
2024-02-28 16:42:57 +01:00
Andreas Eversberg 848faf9256 osmo_io: Move notify_connected function to backend
This relocation is necessary as the backend (osmo_io_fd or
osmo_io_uring) requires a different approach in handling connect
notifications. As a result, a function call has been introduced to
struct iofd_backend_ops.

In a subsequent patch, the process for the osmo_io_uring backend will
be modified to handle SCTP connect notifications using poll/select.

If connect notification is requested using poll/select, the file
descriptior must be registered to osmo_fd, using osmo_fd_register. If
read / write notification is requested by application, the file
descriptior must be registered also. A flag is used prevent calling
osmo_fd_register / osmo_fd_unregister multiple times, which would cause
a crash.

Change-Id: I905ec85210570aff8addadfc9603335d04eb057a
Related: OS#5751
2024-02-28 16:42:53 +01:00
Daniel Willmann 84611881c9 osmo_io: Factor out and use common send function from backend
This handles reenqueuing a message on EAGAIN and incomplete write

Change-Id: I6da2653d32aedd0e7872be0cf90a841b56462e59
2023-11-30 14:27:39 +01:00
Harald Welte 987a86af88 io_uring: add some more source code comments/docs
Change-Id: I8ba77a18b51f67a9edbd1fa488b9791f8bf6e40a
2023-11-22 12:20:12 +00:00
Daniel Willmann ec7d491589 osmo_io: Use local variable to reference msghdr->msg
Change-Id: I336ef7a5460dd18bf8e0f4ac5e97747f9fec5a35
2023-08-31 14:28:13 +00:00
Daniel Willmann f91d2aac9d osmo_io: Add io_uring backend
Change-Id: I5152129eb84b31ccc9e02bc2a5c5bdb046d331bc
2023-08-24 17:33:19 +02:00