From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, Stefan Metzmacher <metze@samba.org>,
io-uring@vger.kernel.org
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH for-6.1 1/2] io_uring/net: fail zc send for unsupported protocols
Date: Thu, 20 Oct 2022 13:53:34 +0100 [thread overview]
Message-ID: <2177dc51-ec7d-6065-c320-76fb0f79b542@gmail.com> (raw)
In-Reply-To: <ed49aa87-5481-ae92-2488-e959121e8869@kernel.dk>
On 10/20/22 13:49, Jens Axboe wrote:
> On 10/20/22 2:13 AM, Stefan Metzmacher wrote:
>> Hi Pavel,
>>
>>> If a protocol doesn't support zerocopy it will silently fall back to
>>> copying. This type of behaviour has always been a source of troubles
>>> so it's better to fail such requests instead. For now explicitly
>>> whitelist supported protocols in io_uring, which should be turned later
>>> into a socket flag.
>>>
>>> Cc: <stable@vger.kernel.org> # 6.0
>>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
>>> ---
>>> io_uring/net.c | 9 +++++++++
>>> 1 file changed, 9 insertions(+)
>>>
>>> diff --git a/io_uring/net.c b/io_uring/net.c
>>> index 8c7226b5bf41..28127f1de1f0 100644
>>> --- a/io_uring/net.c
>>> +++ b/io_uring/net.c
>>> @@ -120,6 +120,13 @@ static void io_netmsg_recycle(struct io_kiocb *req, unsigned int issue_flags)
>>> }
>>> }
>>> +static inline bool io_sock_support_zc(struct socket *sock)
>>> +{
>>> + return likely(sock->sk && sk_fullsock(sock->sk) &&
>>> + (sock->sk->sk_protocol == IPPROTO_TCP ||
>>> + sock->sk->sk_protocol == IPPROTO_UDP));
>>> +}
>>
>> Can we please make this more generic (at least for 6.1, which is likely be an lts release)
>>
>> It means my out of tree smbdirect driver would not be able to provide SENDMSG_ZC.
>>
>> Currently sk_setsockopt has this logic:
>>
>> case SO_ZEROCOPY:
>> if (sk->sk_family == PF_INET || sk->sk_family == PF_INET6) {
>> if (!(sk_is_tcp(sk) ||
>> (sk->sk_type == SOCK_DGRAM &&
>> sk->sk_protocol == IPPROTO_UDP)))
>> ret = -EOPNOTSUPP;
>> } else if (sk->sk_family != PF_RDS) {
>> ret = -EOPNOTSUPP;
>> }
>> if (!ret) {
>> if (val < 0 || val > 1)
>> ret = -EINVAL;
>> else
>> sock_valbool_flag(sk, SOCK_ZEROCOPY, valbool);
>> }
>> break;
>>
>> Maybe the socket creation code could set
>> unsigned char skc_so_zerocopy_supported:1;
>> and/or
>> unsigned char skc_zerocopy_msg_ubuf_supported:1;
>>
>> In order to avoid the manual complex tests.
>
> I agree that would be cleaner, even for 6.1. Let's drop these two
> for now.
As I mentioned let's drop, but if not for smb I do think it's
better as doesn't require changes in multiple /net files.
--
Pavel Begunkov
next prev parent reply other threads:[~2022-10-20 12:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1666229889.git.asml.silence@gmail.com>
[not found] ` <ee7c163db8cea65b208d327610a6a96f936c1c6f.1666229889.git.asml.silence@gmail.com>
2022-10-20 9:13 ` [PATCH for-6.1 1/2] io_uring/net: fail zc send for unsupported protocols Stefan Metzmacher
2022-10-20 12:48 ` Pavel Begunkov
2022-10-20 13:05 ` Stefan Metzmacher
2022-10-20 12:49 ` Jens Axboe
2022-10-20 12:53 ` Pavel Begunkov [this message]
2022-10-20 12:59 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2177dc51-ec7d-6065-c320-76fb0f79b542@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=metze@samba.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).