mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Damato <jdamato@fastly.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Joe Damato <jdamato@fastly.com>
Subject: [RFC,net-next v2 8/8] net: tcp: Support MSG_NTCOPY
Date: Sun, 12 Jun 2022 01:57:57 -0700	[thread overview]
Message-ID: <1655024280-23827-9-git-send-email-jdamato@fastly.com> (raw)
In-Reply-To: <1655024280-23827-1-git-send-email-jdamato@fastly.com>

Support non-temporal copies in the TCP sendmsg path. Previously, the only
way to enable non-temporal copies was to enable them for the entire
interface (via ethtool).

This change allows user programs to request non-temporal copies for
specific sendmsg calls.

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 include/net/sock.h | 2 +-
 net/ipv4/tcp.c     | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 0063e84..b666ecd 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2200,7 +2200,7 @@ static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
 		if (!csum_and_copy_from_iter_full(to, copy, &csum, from))
 			return -EFAULT;
 		skb->csum = csum_block_add(skb->csum, csum, offset);
-	} else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) {
+	} else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY || iov_iter_copy_is_nt(from)) {
 		if (!copy_from_iter_full_nocache(to, copy, from))
 			return -EFAULT;
 	} else if (!copy_from_iter_full(to, copy, from))
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 14ebb4e..5b36e00 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1201,6 +1201,8 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 
 	flags = msg->msg_flags;
 
+	msg_set_iter_copy_type(msg);
+
 	if (flags & MSG_ZEROCOPY && size && sock_flag(sk, SOCK_ZEROCOPY)) {
 		skb = tcp_write_queue_tail(sk);
 		uarg = msg_zerocopy_realloc(sk, size, skb_zcopy(skb));
-- 
2.7.4


      parent reply	other threads:[~2022-06-12  9:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-12  8:57 [RFC,net-next,x86 v2 0/8] Nontemporal copies in sendmsg path Joe Damato
2022-06-12  8:57 ` [RFC,x86 v2 1/8] arch, x86, uaccess: Add nontemporal copy functions Joe Damato
2022-06-12  8:57 ` [RFC,iov_iter v2 2/8] iov_iter: Introduce iter_copy_type Joe Damato
2022-06-12  8:57 ` [RFC,iov_iter v2 3/8] iov_iter: add copyin_iovec helper Joe Damato
2022-06-13  4:25   ` Al Viro
2022-06-13  6:32     ` Joe Damato
2022-06-13  7:53   ` David Laight
2022-06-13 14:42     ` Joe Damato
2022-06-13 15:31       ` David Laight
2022-06-12  8:57 ` [RFC,net-next v2 4/8] net: Add MSG_NTCOPY sendmsg flag Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 5/8] net: unix: Support MSG_NTCOPY Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 6/8] net: ip: " Joe Damato
2022-06-12  8:57 ` [RFC,net-next v2 7/8] net: udplite: " Joe Damato
2022-06-12  8:57 ` Joe Damato [this message]

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=1655024280-23827-9-git-send-email-jdamato@fastly.com \
    --to=jdamato@fastly.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yoshfuji@linux-ipv6.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®