diff mbox series

[RFC,net-next,5/6] net: Add a way to copy skbs without affect cache

Message ID 1652241268-46732-6-git-send-email-jdamato@fastly.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Nontemporal copies in unix socket write path | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 5643 this patch: 5644
netdev/cc_maintainers warning 4 maintainers not CCed: arjunroy@google.com imagedong@tencent.com willemb@google.com talalahmad@google.com
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 5887 this patch: 5888
netdev/checkpatch warning CHECK: Alignment should match open parenthesis
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Joe Damato May 11, 2022, 3:54 a.m. UTC
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 mbox series

Patch

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