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 5/6] net: Add a way to copy skbs without affect cache
Date: Tue, 10 May 2022 20:54:26 -0700 [thread overview]
Message-ID: <1652241268-46732-6-git-send-email-jdamato@fastly.com> (raw)
In-Reply-To: <1652241268-46732-1-git-send-email-jdamato@fastly.com>
Add an skb_copier, skb_nocache_copier, which contains function pointers to
nontemporal copy routines.
Using skb_nocache_copier and do_skb_copy_datagram implement
skb_copy_datagram_from_iter_nocache. This function is intended to be used
by callers which would like to copy data into SKBs using nontemporal
instructions to avoid the CPU cache.
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
include/linux/skbuff.h | 2 ++
net/core/datagram.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 97de40b..32c0cba 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3918,6 +3918,8 @@ int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset,
struct ahash_request *hash);
int skb_copy_datagram_from_iter(struct sk_buff *skb, int offset,
struct iov_iter *from, int len);
+int skb_copy_datagram_from_iter_nocache(struct sk_buff *skb, int offset,
+ struct iov_iter *from, int len);
int zerocopy_sg_from_iter(struct sk_buff *skb, struct iov_iter *frm);
void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
void __skb_free_datagram_locked(struct sock *sk, struct sk_buff *skb, int len);
diff --git a/net/core/datagram.c b/net/core/datagram.c
index a87c41b..da8557b 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -543,6 +543,11 @@ struct skb_copier skb_copier = {
.copy_page_from_iter = copy_page_from_iter
};
+struct skb_copier skb_nocache_copier = {
+ .copy_from_iter = copy_from_iter_nocache,
+ .copy_page_from_iter = copy_page_from_iter_nocache
+};
+
static int do_skb_copy_datagram(struct sk_buff *skb, int offset,
struct iov_iter *from, int len, struct skb_copier copier)
{
@@ -611,6 +616,13 @@ static int do_skb_copy_datagram(struct sk_buff *skb, int offset,
return -EFAULT;
}
+int skb_copy_datagram_from_iter_nocache(struct sk_buff *skb, int offset,
+ struct iov_iter *from, int len)
+{
+ return do_skb_copy_datagram(skb, offset, from, len, skb_nocache_copier);
+}
+EXPORT_SYMBOL(skb_copy_datagram_from_iter_nocache);
+
/**
* skb_copy_datagram_from_iter - Copy a datagram from an iov_iter.
* @skb: buffer to copy
--
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 ` Joe Damato [this message]
2022-05-11 3:54 ` [RFC,net-next 6/6] net: unix: Add MSG_NTCOPY Joe Damato
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-6-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®