* [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
@ 2024-12-17 10:56 Yajun Deng
2024-12-17 11:09 ` Eric Dumazet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yajun Deng @ 2024-12-17 10:56 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms; +Cc: netdev, linux-kernel, Yajun Deng
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)
+#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 |
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
2024-12-17 10:56 [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER Yajun Deng
@ 2024-12-17 11:09 ` Eric Dumazet
2024-12-20 13:42 ` kernel test robot
2024-12-21 0:05 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-12-17 11:09 UTC (permalink / raw)
To: Yajun Deng; +Cc: davem, kuba, pabeni, horms, netdev, linux-kernel
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
2024-12-17 10:56 [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER Yajun Deng
2024-12-17 11:09 ` Eric Dumazet
@ 2024-12-20 13:42 ` kernel test robot
2024-12-21 0:05 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-12-20 13:42 UTC (permalink / raw)
To: Yajun Deng, davem, edumazet, kuba, pabeni, horms
Cc: oe-kbuild-all, netdev, linux-kernel, Yajun Deng
Hi Yajun,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Yajun-Deng/sock-make-SKB_FRAG_PAGE_ORDER-equal-to-PAGE_ALLOC_COSTLY_ORDER/20241217-185748
base: net-next/main
patch link: https://lore.kernel.org/r/20241217105659.2215649-1-yajun.deng%40linux.dev
patch subject: [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20241220/202412202122.04V0tnNx-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241220/202412202122.04V0tnNx-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412202122.04V0tnNx-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from arch/openrisc/include/asm/page.h:18,
from arch/openrisc/include/asm/processor.h:19,
from arch/openrisc/include/asm/thread_info.h:22,
from include/linux/thread_info.h:60,
from include/asm-generic/preempt.h:5,
from ./arch/openrisc/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:79,
from include/linux/spinlock.h:56,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from include/linux/highmem.h:5,
from include/linux/bvec.h:10,
from include/linux/skbuff.h:17,
from include/linux/ip.h:16,
from include/net/ip.h:22,
from include/linux/errqueue.h:6,
from net/core/sock.c:91:
net/core/sock.c: In function 'skb_page_frag_refill':
>> include/vdso/page.h:15:25: warning: conversion from 'long unsigned int' to '__u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Woverflow]
15 | #define PAGE_SIZE (_AC(1,UL) << CONFIG_PAGE_SHIFT)
| ^
net/core/sock.c:3044:39: note: in expansion of macro 'PAGE_SIZE'
3044 | pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER;
| ^~~~~~~~~
vim +15 include/vdso/page.h
efe8419ae78d65 Vincenzo Frascino 2024-10-14 14
efe8419ae78d65 Vincenzo Frascino 2024-10-14 @15 #define PAGE_SIZE (_AC(1,UL) << CONFIG_PAGE_SHIFT)
efe8419ae78d65 Vincenzo Frascino 2024-10-14 16
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
2024-12-17 10:56 [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER Yajun Deng
2024-12-17 11:09 ` Eric Dumazet
2024-12-20 13:42 ` kernel test robot
@ 2024-12-21 0:05 ` kernel test robot
2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-12-21 0:05 UTC (permalink / raw)
To: Yajun Deng, davem, edumazet, kuba, pabeni, horms
Cc: oe-kbuild-all, netdev, linux-kernel, Yajun Deng
Hi Yajun,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Yajun-Deng/sock-make-SKB_FRAG_PAGE_ORDER-equal-to-PAGE_ALLOC_COSTLY_ORDER/20241217-185748
base: net-next/main
patch link: https://lore.kernel.org/r/20241217105659.2215649-1-yajun.deng%40linux.dev
patch subject: [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER
config: openrisc-randconfig-r122-20241220 (https://download.01.org/0day-ci/archive/20241221/202412210700.fAOJ9ocm-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.2.0
reproduce: (https://download.01.org/0day-ci/archive/20241221/202412210700.fAOJ9ocm-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412210700.fAOJ9ocm-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
net/core/sock.c:2496:9: sparse: sparse: context imbalance in 'sk_clone_lock' - wrong count at exit
net/core/sock.c:2500:6: sparse: sparse: context imbalance in 'sk_free_unlock_clone' - unexpected unlock
>> net/core/sock.c:3044:49: sparse: sparse: cast truncates bits from constant value (10000 becomes 0)
vim +3044 net/core/sock.c
5640f7685831e08 Eric Dumazet 2012-09-23 3013
400dfd3ae899849 Eric Dumazet 2013-10-17 3014 /**
400dfd3ae899849 Eric Dumazet 2013-10-17 3015 * skb_page_frag_refill - check that a page_frag contains enough room
400dfd3ae899849 Eric Dumazet 2013-10-17 3016 * @sz: minimum size of the fragment we want to get
400dfd3ae899849 Eric Dumazet 2013-10-17 3017 * @pfrag: pointer to page_frag
82d5e2b8b466d5b Eric Dumazet 2014-09-08 3018 * @gfp: priority for memory allocation
400dfd3ae899849 Eric Dumazet 2013-10-17 3019 *
400dfd3ae899849 Eric Dumazet 2013-10-17 3020 * Note: While this allocator tries to use high order pages, there is
400dfd3ae899849 Eric Dumazet 2013-10-17 3021 * no guarantee that allocations succeed. Therefore, @sz MUST be
400dfd3ae899849 Eric Dumazet 2013-10-17 3022 * less or equal than PAGE_SIZE.
400dfd3ae899849 Eric Dumazet 2013-10-17 3023 */
d9b2938aabf757d Eric Dumazet 2014-08-27 3024 bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t gfp)
5640f7685831e08 Eric Dumazet 2012-09-23 3025 {
5640f7685831e08 Eric Dumazet 2012-09-23 3026 if (pfrag->page) {
fe896d1878949ea Joonsoo Kim 2016-03-17 3027 if (page_ref_count(pfrag->page) == 1) {
5640f7685831e08 Eric Dumazet 2012-09-23 3028 pfrag->offset = 0;
5640f7685831e08 Eric Dumazet 2012-09-23 3029 return true;
5640f7685831e08 Eric Dumazet 2012-09-23 3030 }
400dfd3ae899849 Eric Dumazet 2013-10-17 3031 if (pfrag->offset + sz <= pfrag->size)
5640f7685831e08 Eric Dumazet 2012-09-23 3032 return true;
5640f7685831e08 Eric Dumazet 2012-09-23 3033 put_page(pfrag->page);
5640f7685831e08 Eric Dumazet 2012-09-23 3034 }
5640f7685831e08 Eric Dumazet 2012-09-23 3035
5640f7685831e08 Eric Dumazet 2012-09-23 3036 pfrag->offset = 0;
af87ed7a96a9372 Yajun Deng 2024-12-17 3037 if (!static_branch_unlikely(&net_high_order_alloc_disable_key)) {
d0164adc89f6bb3 Mel Gorman 2015-11-06 3038 /* Avoid direct reclaim but allow kswapd to wake */
d0164adc89f6bb3 Mel Gorman 2015-11-06 3039 pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) |
d0164adc89f6bb3 Mel Gorman 2015-11-06 3040 __GFP_COMP | __GFP_NOWARN |
d0164adc89f6bb3 Mel Gorman 2015-11-06 3041 __GFP_NORETRY,
d9b2938aabf757d Eric Dumazet 2014-08-27 3042 SKB_FRAG_PAGE_ORDER);
d9b2938aabf757d Eric Dumazet 2014-08-27 3043 if (likely(pfrag->page)) {
d9b2938aabf757d Eric Dumazet 2014-08-27 @3044 pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER;
d9b2938aabf757d Eric Dumazet 2014-08-27 3045 return true;
d9b2938aabf757d Eric Dumazet 2014-08-27 3046 }
d9b2938aabf757d Eric Dumazet 2014-08-27 3047 }
d9b2938aabf757d Eric Dumazet 2014-08-27 3048 pfrag->page = alloc_page(gfp);
d9b2938aabf757d Eric Dumazet 2014-08-27 3049 if (likely(pfrag->page)) {
d9b2938aabf757d Eric Dumazet 2014-08-27 3050 pfrag->size = PAGE_SIZE;
5640f7685831e08 Eric Dumazet 2012-09-23 3051 return true;
5640f7685831e08 Eric Dumazet 2012-09-23 3052 }
400dfd3ae899849 Eric Dumazet 2013-10-17 3053 return false;
400dfd3ae899849 Eric Dumazet 2013-10-17 3054 }
400dfd3ae899849 Eric Dumazet 2013-10-17 3055 EXPORT_SYMBOL(skb_page_frag_refill);
400dfd3ae899849 Eric Dumazet 2013-10-17 3056
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-21 0:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-17 10:56 [PATCH net-next] sock: make SKB_FRAG_PAGE_ORDER equal to PAGE_ALLOC_COSTLY_ORDER Yajun Deng
2024-12-17 11:09 ` Eric Dumazet
2024-12-20 13:42 ` kernel test robot
2024-12-21 0:05 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox