From: Joe Damato <jdamato@fastly.com>
To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
linux-kernel@vger.kernel.org, x86@kernel.org,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>
Cc: Joe Damato <jdamato@fastly.com>
Subject: [RFC,net-next 6/6] net: unix: Add MSG_NTCOPY
Date: Tue, 10 May 2022 20:54:27 -0700 [thread overview]
Message-ID: <1652241268-46732-7-git-send-email-jdamato@fastly.com> (raw)
In-Reply-To: <1652241268-46732-1-git-send-email-jdamato@fastly.com>
Add a new sendmsg flag, MSG_NTCOPY, which user programs can use to signal
to the kernel that data copied into the kernel during sendmsg should be
done so using nontemporal copies, if it is supported by the architecture.
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
include/linux/socket.h | 1 +
net/unix/af_unix.c | 13 +++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 12085c9..c9b10aa 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -318,6 +318,7 @@ struct ucred {
* plain text and require encryption
*/
+#define MSG_NTCOPY 0x2000000 /* Use a non-temporal copy */
#define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */
#define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */
#define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e1dd9e9..ccbd643 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1907,7 +1907,11 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg,
skb_put(skb, len - data_len);
skb->data_len = data_len;
skb->len = len;
- err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, len);
+ if (msg->msg_flags & MSG_NTCOPY)
+ err = skb_copy_datagram_from_iter_nocache(skb, 0, &msg->msg_iter, len);
+ else
+ err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, len);
+
if (err)
goto out_free;
@@ -2167,7 +2171,12 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg,
skb_put(skb, size - data_len);
skb->data_len = data_len;
skb->len = size;
- err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size);
+
+ if (msg->msg_flags & MSG_NTCOPY)
+ err = skb_copy_datagram_from_iter_nocache(skb, 0, &msg->msg_iter, size);
+ else
+ err = skb_copy_datagram_from_iter(skb, 0, &msg->msg_iter, size);
+
if (err) {
kfree_skb(skb);
goto out_err;
--
2.7.4
next prev parent reply other threads:[~2022-05-11 3:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-11 3:54 [RFC,net-next,x86 0/6] Nontemporal copies in unix socket write path Joe Damato
2022-05-11 3:54 ` [RFC,net-next,x86 1/6] arch, x86, uaccess: Add nontemporal copy functions Joe Damato
2022-05-11 3:54 ` [RFC,net-next 2/6] iov_iter: Allow custom copyin function Joe Damato
2022-05-11 3:54 ` [RFC,net-next 3/6] iov_iter: Add a nocache copy iov iterator Joe Damato
2022-05-11 3:54 ` [RFC,net-next 4/6] net: Add a struct for managing copy functions Joe Damato
2022-05-11 3:54 ` [RFC,net-next 5/6] net: Add a way to copy skbs without affect cache Joe Damato
2022-05-11 3:54 ` Joe Damato [this message]
2022-05-11 23:25 ` [RFC,net-next,x86 0/6] Nontemporal copies in unix socket write path Jakub Kicinski
2022-05-12 1:01 ` Joe Damato
2022-05-12 19:46 ` Jakub Kicinski
2022-05-12 22:53 ` Joe Damato
2022-05-12 23:12 ` Jakub Kicinski
2022-05-31 6:04 ` Christoph Hellwig
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=1652241268-46732-7-git-send-email-jdamato@fastly.com \
--to=jdamato@fastly.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=x86@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
all inboxes | Powered by JetHome®