diff mbox series

[net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER

Message ID 20241217105659.2215649-1-yajun.deng@linux.dev (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 15 this patch: 15
netdev/build_tools success Errors and warnings before: 0 (+23) this patch: 0 (+23)
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 16422 this patch: 16422
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: 2596 this patch: 2596
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 13 this patch: 13
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-12-17--21-00 (tests: 883)

Commit Message

Yajun Deng Dec. 17, 2024, 10:56 a.m. UTC
The SKB_FRAG_PAGE_ORDER will be 3 if PAGE_SIZE is 4096, and less than 3
if it is not. So it will increase the number of memory allocations if
PAGE_SIZE is greater than 4096.

alloc_pages() only relates to the order, if an order is less than or equal
to PAGE_ALLOC_COSTLY_ORDER, it will get the page from rmqueue_pcplist() in
rmqueue(). So there's no need for the order to be less than
PAGE_ALLOC_COSTLY_ORDER.

To decrease the number of memory allocations, make SKB_FRAG_PAGE_ORDER
equal to PAGE_ALLOC_COSTLY_ORDER even if PAGE_SIZE isn't 4096.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 include/net/sock.h | 2 +-
 net/core/sock.c    | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

Eric Dumazet Dec. 17, 2024, 11:09 a.m. UTC | #1
On Tue, Dec 17, 2024 at 11:56 AM Yajun Deng <yajun.deng@linux.dev> wrote:
>
> The SKB_FRAG_PAGE_ORDER will be 3 if PAGE_SIZE is 4096, and less than 3
> if it is not. So it will increase the number of memory allocations if
> PAGE_SIZE is greater than 4096.
>
> alloc_pages() only relates to the order, if an order is less than or equal
> to PAGE_ALLOC_COSTLY_ORDER, it will get the page from rmqueue_pcplist() in
> rmqueue(). So there's no need for the order to be less than
> PAGE_ALLOC_COSTLY_ORDER.
>
> To decrease the number of memory allocations, make SKB_FRAG_PAGE_ORDER
> equal to PAGE_ALLOC_COSTLY_ORDER even if PAGE_SIZE isn't 4096.
>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
>  include/net/sock.h | 2 +-
>  net/core/sock.c    | 3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 7464e9f9f47c..a33645226577 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2853,7 +2853,7 @@ extern __u32 sysctl_rmem_max;
>  extern __u32 sysctl_wmem_default;
>  extern __u32 sysctl_rmem_default;
>
> -#define SKB_FRAG_PAGE_ORDER    get_order(32768)

We do not want to allow some programs to work on arches with 64K page
sizes, and not work on 4K page sizes.

Please post your precise use case.
diff mbox series

Patch

diff --git a/include/net/sock.h b/include/net/sock.h
index 7464e9f9f47c..a33645226577 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2853,7 +2853,7 @@  extern __u32 sysctl_rmem_max;
 extern __u32 sysctl_wmem_default;
 extern __u32 sysctl_rmem_default;
 
-#define SKB_FRAG_PAGE_ORDER	get_order(32768)
+#define SKB_FRAG_PAGE_ORDER	PAGE_ALLOC_COSTLY_ORDER
 DECLARE_STATIC_KEY_FALSE(net_high_order_alloc_disable_key);
 
 static inline int sk_get_wmem0(const struct sock *sk, const struct proto *proto)
diff --git a/net/core/sock.c b/net/core/sock.c
index 74729d20cd00..0db306f4216c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3014,8 +3014,7 @@  bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t gfp)
 	}
 
 	pfrag->offset = 0;
-	if (SKB_FRAG_PAGE_ORDER &&
-	    !static_branch_unlikely(&net_high_order_alloc_disable_key)) {
+	if (!static_branch_unlikely(&net_high_order_alloc_disable_key)) {
 		/* Avoid direct reclaim but allow kswapd to wake */
 		pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) |
 					  __GFP_COMP | __GFP_NOWARN |