diff mbox series

[RFC,5/8] skbuff: remove compound_head() related function calling

Message ID 20231113130041.58124-6-linyunsheng@huawei.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series A possible proposal for intergating dmabuf to page pool | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6218 this patch: 6218
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 2385 this patch: 2385
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6571 this patch: 6571
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 41 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yunsheng Lin Nov. 13, 2023, 1 p.m. UTC
As we have ensured that the page for the skb frag is
always a base page or head page for a compound page, we
can remove some compound_head() related function.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
 include/linux/skbuff.h | 8 +++++---
 net/core/skbuff.c      | 4 +---
 2 files changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 3e2f806c8ed8..1889b0968be0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2473,13 +2473,15 @@  static inline void skb_len_add(struct sk_buff *skb, int delta)
 static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
 					struct page *page, int off, int size)
 {
-	__skb_fill_page_desc_noacc(skb_shinfo(skb), i, page, off, size);
+	skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+	skb_frag_fill_page_desc(frag, page, off, size);
 
 	/* Propagate page pfmemalloc to the skb if we can. The problem is
 	 * that not all callers have unique ownership of the page but rely
 	 * on page_is_pfmemalloc doing the right thing(tm).
 	 */
-	page = compound_head(page);
+	page = frag->bv_page;
 	if (page_is_pfmemalloc(page))
 		skb->pfmemalloc	= true;
 }
@@ -3429,7 +3431,7 @@  static inline struct page *skb_frag_page(const skb_frag_t *frag)
  */
 static inline void __skb_frag_ref(skb_frag_t *frag)
 {
-	get_page(skb_frag_page(frag));
+	page_ref_inc(skb_frag_page(frag));
 }
 
 /**
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index b157efea5dea..ada3da4fe221 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -896,8 +896,6 @@  bool napi_pp_put_page(struct page *page, bool napi_safe)
 	bool allow_direct = false;
 	struct page_pool *pp;
 
-	page = compound_head(page);
-
 	/* page->pp_magic is OR'ed with PP_SIGNATURE after the allocation
 	 * in order to preserve any existing bits, such as bit 0 for the
 	 * head page of compound page and bit 1 for pfmemalloc page, so
@@ -939,7 +937,7 @@  static bool skb_pp_recycle(struct sk_buff *skb, void *data, bool napi_safe)
 {
 	if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
 		return false;
-	return napi_pp_put_page(virt_to_page(data), napi_safe);
+	return napi_pp_put_page(virt_to_head_page(data), napi_safe);
 }
 
 static void skb_kfree_head(void *head, unsigned int end_offset)