mbox series

[for-6.1,0/3] fail io_uring zc with sockets not supporting it

Message ID cover.1666346426.git.asml.silence@gmail.com (mailing list archive)
Headers show
Series fail io_uring zc with sockets not supporting it | expand

Message

Pavel Begunkov Oct. 21, 2022, 10:16 a.m. UTC
Some sockets don't care about msghdr::ubuf_info and would execute the
request by copying data. Such fallback behaviour was always a pain in
my experience, so we'd rather want to fail such requests and have a more
robust api in the future.

Mark struct socket that support it with a new SOCK_SUPPORT_ZC flag.
I'm not entirely sure it's the best place for the flag but at least
we don't have to do a bunch of extra dereferences in the hot path.

P.S. patches 2 and 3 are not combined for backporting purposes.

Pavel Begunkov (3):
  net: flag sockets supporting msghdr originated zerocopy
  io_uring/net: fail zc send when unsupported by socket
  io_uring/net: fail zc sendmsg when unsupported by socket

 include/linux/net.h | 1 +
 io_uring/net.c      | 4 ++++
 net/ipv4/tcp.c      | 1 +
 net/ipv4/udp.c      | 1 +
 4 files changed, 7 insertions(+)

Comments

Stefan Metzmacher Oct. 21, 2022, 10:27 a.m. UTC | #1
Hi Pavel,

> Some sockets don't care about msghdr::ubuf_info and would execute the
> request by copying data. Such fallback behaviour was always a pain in
> my experience, so we'd rather want to fail such requests and have a more
> robust api in the future.
> 
> Mark struct socket that support it with a new SOCK_SUPPORT_ZC flag.
> I'm not entirely sure it's the best place for the flag but at least
> we don't have to do a bunch of extra dereferences in the hot path.

I'd give the flag another name that indicates msg_ubuf and
have a 2nd flag that can indicate support for SO_ZEROCOPY in sk_setsockopt()

The SO_ZEROCOPY version is also provided by AF_RDS.

metze
Pavel Begunkov Oct. 21, 2022, 10:42 a.m. UTC | #2
On 10/21/22 11:27, Stefan Metzmacher wrote:
> Hi Pavel,
> 
>> Some sockets don't care about msghdr::ubuf_info and would execute the
>> request by copying data. Such fallback behaviour was always a pain in
>> my experience, so we'd rather want to fail such requests and have a more
>> robust api in the future.
>>
>> Mark struct socket that support it with a new SOCK_SUPPORT_ZC flag.
>> I'm not entirely sure it's the best place for the flag but at least
>> we don't have to do a bunch of extra dereferences in the hot path.
> 
> I'd give the flag another name that indicates msg_ubuf and

Could be renamed, e.g. SOCK_SUPPORT_MSGHDR_UBUF or maybe
SOCK_SUPPORT_EXTERNAL_UBUF

> have a 2nd flag that can indicate support for SO_ZEROCOPY in sk_setsockopt()

There is absolutely no reason to introduce a second flag here, it has
nothing to do with SO_ZEROCOPY.

> The SO_ZEROCOPY version is also provided by AF_RDS.
Stefan Metzmacher Oct. 21, 2022, 12:49 p.m. UTC | #3
Am 21.10.22 um 12:42 schrieb Pavel Begunkov:
> On 10/21/22 11:27, Stefan Metzmacher wrote:
>> Hi Pavel,
>>
>>> Some sockets don't care about msghdr::ubuf_info and would execute the
>>> request by copying data. Such fallback behaviour was always a pain in
>>> my experience, so we'd rather want to fail such requests and have a more
>>> robust api in the future.
>>>
>>> Mark struct socket that support it with a new SOCK_SUPPORT_ZC flag.
>>> I'm not entirely sure it's the best place for the flag but at least
>>> we don't have to do a bunch of extra dereferences in the hot path.
>>
>> I'd give the flag another name that indicates msg_ubuf and
> 
> Could be renamed, e.g. SOCK_SUPPORT_MSGHDR_UBUF 

That's good or SOCK_SUPPORT_ZC_MSGHDR_UBUF.

>> have a 2nd flag that can indicate support for SO_ZEROCOPY in sk_setsockopt()
> 
> There is absolutely no reason to introduce a second flag here, it has
> nothing to do with SO_ZEROCOPY.

I meant as a separate change to replace the hard coded logic in
sk_setsockopt()... But I don't care much about it, it's unlikely
that I ever want to use SO_ZEROCOPY...

metze
patchwork-bot+netdevbpf@kernel.org Oct. 24, 2022, 8:40 p.m. UTC | #4
Hello:

This series was applied to netdev/net.git (master)
by Jens Axboe <axboe@kernel.dk>:

On Fri, 21 Oct 2022 11:16:38 +0100 you wrote:
> Some sockets don't care about msghdr::ubuf_info and would execute the
> request by copying data. Such fallback behaviour was always a pain in
> my experience, so we'd rather want to fail such requests and have a more
> robust api in the future.
> 
> Mark struct socket that support it with a new SOCK_SUPPORT_ZC flag.
> I'm not entirely sure it's the best place for the flag but at least
> we don't have to do a bunch of extra dereferences in the hot path.
> 
> [...]

Here is the summary with links:
  - [for-6.1,1/3] net: flag sockets supporting msghdr originated zerocopy
    https://git.kernel.org/netdev/net/c/e993ffe3da4b
  - [for-6.1,2/3] io_uring/net: fail zc send when unsupported by socket
    https://git.kernel.org/netdev/net/c/edf81438799c
  - [for-6.1,3/3] io_uring/net: fail zc sendmsg when unsupported by socket
    https://git.kernel.org/netdev/net/c/cc767e7c6913

You are awesome, thank you!
Jakub Kicinski Oct. 24, 2022, 9:15 p.m. UTC | #5
On Mon, 24 Oct 2022 20:40:38 +0000 patchwork-bot+netdevbpf@kernel.org
wrote:
> Here is the summary with links:
>   - [for-6.1,1/3] net: flag sockets supporting msghdr originated zerocopy
>     https://git.kernel.org/netdev/net/c/e993ffe3da4b
>   - [for-6.1,2/3] io_uring/net: fail zc send when unsupported by socket
>     https://git.kernel.org/netdev/net/c/edf81438799c
>   - [for-6.1,3/3] io_uring/net: fail zc sendmsg when unsupported by socket
>     https://git.kernel.org/netdev/net/c/cc767e7c6913

Ugh, ignore, looks like we forgot to drop this series from our PW 
and bot thought we've applied it when we forwarded the tree.