mbox series

[PATCHSET,RFC,0/4] Propagate back queue status on accept

Message ID 20240509180627.204155-1-axboe@kernel.dk (mailing list archive)
Headers show
Series Propagate back queue status on accept | expand

Message

Jens Axboe May 9, 2024, 6 p.m. UTC
Hi,

With io_uring, one thing we can do is tell userspace whether or not
there's more data left in a socket after a receive is done. This is
useful for applications to now, and it also helps make multishot receive
requests more efficient by eliminating that last failed retry when the
socket has no more data left. This is propagated by setting the
IORING_CQE_F_SOCK_NONEMPTY flag, and is driven by setting
msghdr->msg_get_inq and having the protocol fill out msghdr->msg_inq in
that case.

For accept, there's a similar issue in that we'd like to know if there
are more connections to accept after the current one has been accepted.
Both because we can tell userspace about it, but also to drive multishot
accept retries more efficiently, similar to recv/recvmsg.

This series starts by changing the proto/proto_ops accept prototypes
to eliminate flags/errp/kern and replace it with a structure that
encompasses all of them.

Then patch 2 changes do_accept(), which io_uring uses, to take that
as well.

Patch 3 finally adds the basic is_empty argument to the struct,
and fills it in for TCP.

And finally patch 4 adds support for this in io_uring.

Comments welcome! Patchset is against current -git, with the io_uring
and net-next changes for 6.10 merged in. Branch can be found here:

https://git.kernel.dk/cgit/linux/log/?h=net-accept-more

 crypto/af_alg.c                    | 11 ++++++-----
 crypto/algif_hash.c                | 10 +++++-----
 drivers/xen/pvcalls-back.c         |  6 +++++-
 fs/ocfs2/cluster/tcp.c             |  5 ++++-
 include/crypto/if_alg.h            |  3 ++-
 include/linux/net.h                |  4 +++-
 include/linux/socket.h             |  3 ++-
 include/net/inet_common.h          |  4 ++--
 include/net/inet_connection_sock.h |  2 +-
 include/net/sock.h                 | 13 ++++++++++---
 io_uring/net.c                     | 26 ++++++++++++++++++++------
 net/atm/svc.c                      |  8 ++++----
 net/ax25/af_ax25.c                 |  6 +++---
 net/bluetooth/iso.c                |  4 ++--
 net/bluetooth/l2cap_sock.c         |  4 ++--
 net/bluetooth/rfcomm/sock.c        |  6 +++---
 net/bluetooth/sco.c                |  4 ++--
 net/core/sock.c                    |  4 ++--
 net/ipv4/af_inet.c                 | 10 +++++-----
 net/ipv4/inet_connection_sock.c    |  7 ++++---
 net/llc/af_llc.c                   |  7 +++----
 net/mptcp/protocol.c               |  8 ++++----
 net/netrom/af_netrom.c             |  6 +++---
 net/nfc/llcp_sock.c                |  4 ++--
 net/phonet/pep.c                   | 12 ++++++------
 net/phonet/socket.c                |  7 +++----
 net/rds/tcp_listen.c               |  6 +++++-
 net/rose/af_rose.c                 |  6 +++---
 net/sctp/socket.c                  |  8 ++++----
 net/smc/af_smc.c                   |  6 +++---
 net/socket.c                       | 15 ++++++++++-----
 net/tipc/socket.c                  | 10 ++++------
 net/unix/af_unix.c                 | 10 +++++-----
 net/vmw_vsock/af_vsock.c           |  6 +++---
 net/x25/af_x25.c                   |  4 ++--
 35 files changed, 147 insertions(+), 108 deletions(-)

Comments

Jakub Kicinski May 14, 2024, 12:13 a.m. UTC | #1
On Thu,  9 May 2024 12:00:25 -0600 Jens Axboe wrote:
> With io_uring, one thing we can do is tell userspace whether or not
> there's more data left in a socket after a receive is done. This is
> useful for applications to now, and it also helps make multishot receive
> requests more efficient by eliminating that last failed retry when the
> socket has no more data left. This is propagated by setting the
> IORING_CQE_F_SOCK_NONEMPTY flag, and is driven by setting
> msghdr->msg_get_inq and having the protocol fill out msghdr->msg_inq in
> that case.
> 
> For accept, there's a similar issue in that we'd like to know if there
> are more connections to accept after the current one has been accepted.
> Both because we can tell userspace about it, but also to drive multishot
> accept retries more efficiently, similar to recv/recvmsg.
> 
> This series starts by changing the proto/proto_ops accept prototypes
> to eliminate flags/errp/kern and replace it with a structure that
> encompasses all of them.

Acked-by: Jakub Kicinski <kuba@kernel.org>

Feel free to submit for 6.10, or LMK if you want me to send the first
3 to Linus.
Jens Axboe May 14, 2024, 12:24 a.m. UTC | #2
On 5/13/24 6:13 PM, Jakub Kicinski wrote:
> On Thu,  9 May 2024 12:00:25 -0600 Jens Axboe wrote:
>> With io_uring, one thing we can do is tell userspace whether or not
>> there's more data left in a socket after a receive is done. This is
>> useful for applications to now, and it also helps make multishot receive
>> requests more efficient by eliminating that last failed retry when the
>> socket has no more data left. This is propagated by setting the
>> IORING_CQE_F_SOCK_NONEMPTY flag, and is driven by setting
>> msghdr->msg_get_inq and having the protocol fill out msghdr->msg_inq in
>> that case.
>>
>> For accept, there's a similar issue in that we'd like to know if there
>> are more connections to accept after the current one has been accepted.
>> Both because we can tell userspace about it, but also to drive multishot
>> accept retries more efficiently, similar to recv/recvmsg.
>>
>> This series starts by changing the proto/proto_ops accept prototypes
>> to eliminate flags/errp/kern and replace it with a structure that
>> encompasses all of them.
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>
> 
> Feel free to submit for 6.10, or LMK if you want me to send the first
> 3 to Linus.

Thanks! I'll send them in later this merge window (post the net-next
changes).