public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, Jakub Kicinski <[email protected]>,
	Paolo Abeni <[email protected]>,
	"David S . Miller" <[email protected]>
Cc: [email protected], [email protected],
	[email protected], Stefan Metzmacher <[email protected]>
Subject: [PATCH for-6.1 1/3] net: flag sockets supporting msghdr originated zerocopy
Date: Fri, 21 Oct 2022 11:16:39 +0100	[thread overview]
Message-ID: <3dafafab822b1c66308bb58a0ac738b1e3f53f74.1666346426.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

We need an efficient way in io_uring to check whether a socket supports
zerocopy with msghdr provided ubuf_info. Add a new flag into the struct
socket flags fields.

Cc: <[email protected]> # 6.0
Signed-off-by: Pavel Begunkov <[email protected]>
---
 include/linux/net.h | 1 +
 net/ipv4/tcp.c      | 1 +
 net/ipv4/udp.c      | 1 +
 3 files changed, 3 insertions(+)

diff --git a/include/linux/net.h b/include/linux/net.h
index 711c3593c3b8..18d942bbdf6e 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -41,6 +41,7 @@ struct net;
 #define SOCK_NOSPACE		2
 #define SOCK_PASSCRED		3
 #define SOCK_PASSSEC		4
+#define SOCK_SUPPORT_ZC		5
 
 #ifndef ARCH_HAS_SOCKET_TYPES
 /**
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 0c51abeee172..aeb7b9eaddc7 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -457,6 +457,7 @@ void tcp_init_sock(struct sock *sk)
 	WRITE_ONCE(sk->sk_sndbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[1]));
 	WRITE_ONCE(sk->sk_rcvbuf, READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_rmem[1]));
 
+	set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
 	sk_sockets_allocated_inc(sk);
 }
 EXPORT_SYMBOL(tcp_init_sock);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index d63118ce5900..03616fc5162c 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1620,6 +1620,7 @@ int udp_init_sock(struct sock *sk)
 {
 	skb_queue_head_init(&udp_sk(sk)->reader_queue);
 	sk->sk_destruct = udp_destruct_sock;
+	set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(udp_init_sock);
-- 
2.38.0


  reply	other threads:[~2022-10-21 10:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-21 10:16 [PATCH for-6.1 0/3] fail io_uring zc with sockets not supporting it Pavel Begunkov
2022-10-21 10:16 ` Pavel Begunkov [this message]
2022-10-21 16:14   ` [PATCH for-6.1 1/3] net: flag sockets supporting msghdr originated zerocopy Jakub Kicinski
2022-10-22 15:57     ` Pavel Begunkov
2022-10-22 16:07       ` Jens Axboe
2022-10-24 12:49         ` Stefan Metzmacher
2022-10-24 14:12           ` Stefan Metzmacher
2022-10-24 17:00             ` Pavel Begunkov
2022-10-24 17:45               ` Stefan Metzmacher
2022-10-21 10:16 ` [PATCH for-6.1 2/3] io_uring/net: fail zc send when unsupported by socket Pavel Begunkov
2022-10-21 10:16 ` [PATCH for-6.1 3/3] io_uring/net: fail zc sendmsg " Pavel Begunkov
2022-10-21 10:27 ` [PATCH for-6.1 0/3] fail io_uring zc with sockets not supporting it Stefan Metzmacher
2022-10-21 10:42   ` Pavel Begunkov
2022-10-21 12:49     ` Stefan Metzmacher
2022-10-24 20:40 ` patchwork-bot+netdevbpf
2022-10-24 21:15   ` Jakub Kicinski

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=3dafafab822b1c66308bb58a0ac738b1e3f53f74.1666346426.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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