diff mbox series

[net-next] net: introduce a config option to tweak MAX_SKB_FRAGS

Message ID 20230321033704.936685-1-eric.dumazet@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: introduce a config option to tweak MAX_SKB_FRAGS | 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
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 fail Errors and warnings before: 5281 this patch: 5292
netdev/cc_maintainers warning 1 maintainers not CCed: imagedong@tencent.com
netdev/build_clang fail Errors and warnings before: 1037 this patch: 1041
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 fail Errors and warnings before: 5489 this patch: 5493
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Eric Dumazet March 21, 2023, 3:37 a.m. UTC
From: Eric Dumazet <edumazet@google.com>

Currently, MAX_SKB_FRAGS value is 17.

For standard tcp sendmsg() traffic, no big deal because tcp_sendmsg()
attempts order-3 allocations, stuffing 32768 bytes per frag.

But with zero copy, we use order-0 pages.

For BIG TCP to show its full potential, we add a config option
to be able to fit up to 45 segments per skb.

This is also needed for BIG TCP rx zerocopy, as zerocopy currently
does not support skbs with frag list.

We have used MAX_SKB_FRAGS=45 value for years [1] at Google before
we deployed 4K MTU, with no adverse effect, other than
a recent issue in mlx4, fixed in commit 26782aad00cc
("net/mlx4: MLX4_TX_BOUNCE_BUFFER_SIZE depends on MAX_SKB_FRAGS")

[1] Back then, goal was to be able to receive full size (64KB) GRO
packets without the frag_list overhead.

By default we keep the old/legacy value of 17 until we get
more coverage for the updated values.

Sizes of struct skb_shared_info on 64bit arches:

MAX_SKB_FRAGS | sizeof(struct skb_shared_info)
==============================================
         17     320
         21     320+64  = 384
         25     320+128 = 448
         29     320+192 = 512
         33     320+256 = 576
         37     320+320 = 640
         41     320+384 = 704
         45     320+448 = 768

This inflation might cause problems for drivers assuming they could pack
both the incoming packet and skb_shared_info in half a page, using build_skb().

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/skbuff.h | 14 ++------------
 net/Kconfig            | 12 ++++++++++++
 2 files changed, 14 insertions(+), 12 deletions(-)

Comments

Eric Dumazet March 21, 2023, 3:40 a.m. UTC | #1
On Mon, Mar 20, 2023 at 8:37 PM Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> From: Eric Dumazet <edumazet@google.com>
>
> Currently, MAX_SKB_FRAGS value is 17.
>
> For standard tcp sendmsg() traffic, no big deal because tcp_sendmsg()
> attempts order-3 allocations, stuffing 32768 bytes per frag.


Hmm... for some reason this old patch triggers a build error in
net/packet/af_packet.c, let me sort this out.
kernel test robot March 21, 2023, 6:33 a.m. UTC | #2
Hi Eric,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
patch link:    https://lore.kernel.org/r/20230321033704.936685-1-eric.dumazet%40gmail.com
patch subject: [PATCH net-next] net: introduce a config option to tweak MAX_SKB_FRAGS
config: i386-randconfig-a004-20230320 (https://download.01.org/0day-ci/archive/20230321/202303211426.xE59ciyg-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d0eaa3eabce1c80d067a739749e4253546417722
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
        git checkout d0eaa3eabce1c80d067a739749e4253546417722
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash net/packet/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303211426.xE59ciyg-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> net/packet/af_packet.c:2626:11: warning: format specifies type 'unsigned long' but the argument has type 'int' [-Wformat]
                                  MAX_SKB_FRAGS);
                                  ^~~~~~~~~~~~~
   include/linux/printk.h:498:33: note: expanded from macro 'pr_err'
           printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
                                  ~~~     ^~~~~~~~~~~
   include/linux/printk.h:455:60: note: expanded from macro 'printk'
   #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
                                                       ~~~    ^~~~~~~~~~~
   include/linux/printk.h:427:19: note: expanded from macro 'printk_index_wrap'
                   _p_func(_fmt, ##__VA_ARGS__);                           \
                           ~~~~    ^~~~~~~~~~~
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^~~~~~~~~~~~~~~~~~~~
   ./include/generated/autoconf.h:2539:30: note: expanded from macro 'CONFIG_MAX_SKB_FRAGS'
   #define CONFIG_MAX_SKB_FRAGS 17
                                ^~
   1 warning generated.


vim +2626 net/packet/af_packet.c

16cc1400456a4d Willem de Bruijn      2016-02-03  2565  
69e3c75f4d541a Johann Baudy          2009-05-18  2566  static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
8d39b4a6b83c14 Willem de Bruijn      2016-02-03  2567  		void *frame, struct net_device *dev, void *data, int tp_len,
c14ac9451c3483 Soheil Hassas Yeganeh 2016-04-02  2568  		__be16 proto, unsigned char *addr, int hlen, int copylen,
c14ac9451c3483 Soheil Hassas Yeganeh 2016-04-02  2569  		const struct sockcm_cookie *sockc)
69e3c75f4d541a Johann Baudy          2009-05-18  2570  {
184f489e9b8c40 Daniel Borkmann       2013-04-16  2571  	union tpacket_uhdr ph;
8d39b4a6b83c14 Willem de Bruijn      2016-02-03  2572  	int to_write, offset, len, nr_frags, len_max;
69e3c75f4d541a Johann Baudy          2009-05-18  2573  	struct socket *sock = po->sk.sk_socket;
69e3c75f4d541a Johann Baudy          2009-05-18  2574  	struct page *page;
69e3c75f4d541a Johann Baudy          2009-05-18  2575  	int err;
69e3c75f4d541a Johann Baudy          2009-05-18  2576  
69e3c75f4d541a Johann Baudy          2009-05-18  2577  	ph.raw = frame;
69e3c75f4d541a Johann Baudy          2009-05-18  2578  
69e3c75f4d541a Johann Baudy          2009-05-18  2579  	skb->protocol = proto;
69e3c75f4d541a Johann Baudy          2009-05-18  2580  	skb->dev = dev;
69e3c75f4d541a Johann Baudy          2009-05-18  2581  	skb->priority = po->sk.sk_priority;
2d37a186cedc51 Eric Dumazet          2009-10-01  2582  	skb->mark = po->sk.sk_mark;
3d0ba8c03ca9c4 Richard Cochran       2018-07-03  2583  	skb->tstamp = sockc->transmit_time;
8f932f762e7928 Willem de Bruijn      2018-12-17  2584  	skb_setup_tx_timestamp(skb, sockc->tsflags);
5cd8d46ea1562b Willem de Bruijn      2018-11-20  2585  	skb_zcopy_set_nouarg(skb, ph.raw);
69e3c75f4d541a Johann Baudy          2009-05-18  2586  
ae641949df01b8 Herbert Xu            2011-11-18  2587  	skb_reserve(skb, hlen);
69e3c75f4d541a Johann Baudy          2009-05-18  2588  	skb_reset_network_header(skb);
c1aad275b0293d Jason Wang            2013-03-25  2589  
69e3c75f4d541a Johann Baudy          2009-05-18  2590  	to_write = tp_len;
69e3c75f4d541a Johann Baudy          2009-05-18  2591  
69e3c75f4d541a Johann Baudy          2009-05-18  2592  	if (sock->type == SOCK_DGRAM) {
69e3c75f4d541a Johann Baudy          2009-05-18  2593  		err = dev_hard_header(skb, dev, ntohs(proto), addr,
69e3c75f4d541a Johann Baudy          2009-05-18  2594  				NULL, tp_len);
69e3c75f4d541a Johann Baudy          2009-05-18  2595  		if (unlikely(err < 0))
69e3c75f4d541a Johann Baudy          2009-05-18  2596  			return -EINVAL;
1d036d25e5609b Willem de Bruijn      2016-02-03  2597  	} else if (copylen) {
9ed988cd591500 Willem de Bruijn      2016-03-09  2598  		int hdrlen = min_t(int, copylen, tp_len);
9ed988cd591500 Willem de Bruijn      2016-03-09  2599  
69e3c75f4d541a Johann Baudy          2009-05-18  2600  		skb_push(skb, dev->hard_header_len);
1d036d25e5609b Willem de Bruijn      2016-02-03  2601  		skb_put(skb, copylen - dev->hard_header_len);
9ed988cd591500 Willem de Bruijn      2016-03-09  2602  		err = skb_store_bits(skb, 0, data, hdrlen);
69e3c75f4d541a Johann Baudy          2009-05-18  2603  		if (unlikely(err))
69e3c75f4d541a Johann Baudy          2009-05-18  2604  			return err;
9ed988cd591500 Willem de Bruijn      2016-03-09  2605  		if (!dev_validate_header(dev, skb->data, hdrlen))
9ed988cd591500 Willem de Bruijn      2016-03-09  2606  			return -EINVAL;
69e3c75f4d541a Johann Baudy          2009-05-18  2607  
9ed988cd591500 Willem de Bruijn      2016-03-09  2608  		data += hdrlen;
9ed988cd591500 Willem de Bruijn      2016-03-09  2609  		to_write -= hdrlen;
69e3c75f4d541a Johann Baudy          2009-05-18  2610  	}
69e3c75f4d541a Johann Baudy          2009-05-18  2611  
69e3c75f4d541a Johann Baudy          2009-05-18  2612  	offset = offset_in_page(data);
69e3c75f4d541a Johann Baudy          2009-05-18  2613  	len_max = PAGE_SIZE - offset;
69e3c75f4d541a Johann Baudy          2009-05-18  2614  	len = ((to_write > len_max) ? len_max : to_write);
69e3c75f4d541a Johann Baudy          2009-05-18  2615  
69e3c75f4d541a Johann Baudy          2009-05-18  2616  	skb->data_len = to_write;
69e3c75f4d541a Johann Baudy          2009-05-18  2617  	skb->len += to_write;
69e3c75f4d541a Johann Baudy          2009-05-18  2618  	skb->truesize += to_write;
14afee4b6092fd Reshetova, Elena      2017-06-30  2619  	refcount_add(to_write, &po->sk.sk_wmem_alloc);
69e3c75f4d541a Johann Baudy          2009-05-18  2620  
69e3c75f4d541a Johann Baudy          2009-05-18  2621  	while (likely(to_write)) {
69e3c75f4d541a Johann Baudy          2009-05-18  2622  		nr_frags = skb_shinfo(skb)->nr_frags;
69e3c75f4d541a Johann Baudy          2009-05-18  2623  
69e3c75f4d541a Johann Baudy          2009-05-18  2624  		if (unlikely(nr_frags >= MAX_SKB_FRAGS)) {
40d4e3dfc2f56a Eric Dumazet          2009-07-21  2625  			pr_err("Packet exceed the number of skb frags(%lu)\n",
69e3c75f4d541a Johann Baudy          2009-05-18 @2626  			       MAX_SKB_FRAGS);
69e3c75f4d541a Johann Baudy          2009-05-18  2627  			return -EFAULT;
69e3c75f4d541a Johann Baudy          2009-05-18  2628  		}
69e3c75f4d541a Johann Baudy          2009-05-18  2629  
0af55bb58f8fa7 Changli Gao           2010-12-01  2630  		page = pgv_to_page(data);
0af55bb58f8fa7 Changli Gao           2010-12-01  2631  		data += len;
69e3c75f4d541a Johann Baudy          2009-05-18  2632  		flush_dcache_page(page);
69e3c75f4d541a Johann Baudy          2009-05-18  2633  		get_page(page);
0af55bb58f8fa7 Changli Gao           2010-12-01  2634  		skb_fill_page_desc(skb, nr_frags, page, offset, len);
69e3c75f4d541a Johann Baudy          2009-05-18  2635  		to_write -= len;
69e3c75f4d541a Johann Baudy          2009-05-18  2636  		offset = 0;
69e3c75f4d541a Johann Baudy          2009-05-18  2637  		len_max = PAGE_SIZE;
69e3c75f4d541a Johann Baudy          2009-05-18  2638  		len = ((to_write > len_max) ? len_max : to_write);
69e3c75f4d541a Johann Baudy          2009-05-18  2639  	}
69e3c75f4d541a Johann Baudy          2009-05-18  2640  
75c65772c3d184 Maxim Mikityanskiy    2019-02-21  2641  	packet_parse_headers(skb, sock);
efdfa2f7848f64 Daniel Borkmann       2015-11-11  2642  
69e3c75f4d541a Johann Baudy          2009-05-18  2643  	return tp_len;
69e3c75f4d541a Johann Baudy          2009-05-18  2644  }
69e3c75f4d541a Johann Baudy          2009-05-18  2645
Tariq Toukan March 21, 2023, 7:13 a.m. UTC | #3
On 21/03/2023 5:37, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Currently, MAX_SKB_FRAGS value is 17.
> 
> For standard tcp sendmsg() traffic, no big deal because tcp_sendmsg()
> attempts order-3 allocations, stuffing 32768 bytes per frag.
> 
> But with zero copy, we use order-0 pages.
> 
> For BIG TCP to show its full potential, we add a config option
> to be able to fit up to 45 segments per skb.
> 
> This is also needed for BIG TCP rx zerocopy, as zerocopy currently
> does not support skbs with frag list.
> 
> We have used MAX_SKB_FRAGS=45 value for years [1] at Google before
> we deployed 4K MTU, with no adverse effect, other than
> a recent issue in mlx4, fixed in commit 26782aad00cc
> ("net/mlx4: MLX4_TX_BOUNCE_BUFFER_SIZE depends on MAX_SKB_FRAGS")
> 
> [1] Back then, goal was to be able to receive full size (64KB) GRO
> packets without the frag_list overhead.
> 
> By default we keep the old/legacy value of 17 until we get
> more coverage for the updated values.
> 
> Sizes of struct skb_shared_info on 64bit arches:
> 
> MAX_SKB_FRAGS | sizeof(struct skb_shared_info)
> ==============================================
>           17     320
>           21     320+64  = 384
>           25     320+128 = 448
>           29     320+192 = 512
>           33     320+256 = 576
>           37     320+320 = 640
>           41     320+384 = 704
>           45     320+448 = 768
> 
> This inflation might cause problems for drivers assuming they could pack
> both the incoming packet and skb_shared_info in half a page, using build_skb().
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>   include/linux/skbuff.h | 14 ++------------
>   net/Kconfig            | 12 ++++++++++++
>   2 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index fe661011644b8f468ff5e92075a6624f0557584c..43726ca7d20f232461a4d2e5b984032806e9c13e 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -345,18 +345,8 @@ struct sk_buff_head {
>   
>   struct sk_buff;
>   
> -/* To allow 64K frame to be packed as single skb without frag_list we
> - * require 64K/PAGE_SIZE pages plus 1 additional page to allow for
> - * buffers which do not start on a page boundary.
> - *
> - * Since GRO uses frags we allocate at least 16 regardless of page
> - * size.
> - */
> -#if (65536/PAGE_SIZE + 1) < 16
> -#define MAX_SKB_FRAGS 16UL

Default value now changes for this case.
Shouldn't we preserve it?

> -#else
> -#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1)
> -#endif
> +#define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
> +
>   extern int sysctl_max_skb_frags;
>   
>   /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
> diff --git a/net/Kconfig b/net/Kconfig
> index 48c33c2221999e575c83a409ab773b9cc3656eab..f806722bccf450c62e07bfdb245e5195ac4a156d 100644
> --- a/net/Kconfig
> +++ b/net/Kconfig
> @@ -251,6 +251,18 @@ config PCPU_DEV_REFCNT
>   	  network device refcount are using per cpu variables if this option is set.
>   	  This can be forced to N to detect underflows (with a performance drop).
>   
> +config MAX_SKB_FRAGS
> +	int "Maximum number of fragments per skb_shared_info"
> +	range 17 45
> +	default 17
> +	help
> +	  Having more fragments per skb_shared_info can help GRO efficiency.
> +	  This helps BIG TCP workloads, but might expose bugs in some
> +	  legacy drivers.
> +	  This also increases memory overhead of small packets,
> +	  and in drivers using build_skb().
> +	  If unsure, say 17.
> +
>   config RPS
>   	bool
>   	depends on SMP && SYSFS
kernel test robot March 21, 2023, 7:14 a.m. UTC | #4
Hi Eric,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
patch link:    https://lore.kernel.org/r/20230321033704.936685-1-eric.dumazet%40gmail.com
patch subject: [PATCH net-next] net: introduce a config option to tweak MAX_SKB_FRAGS
config: loongarch-randconfig-r014-20230319 (https://download.01.org/0day-ci/archive/20230321/202303211503.hDK3soqh-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d0eaa3eabce1c80d067a739749e4253546417722
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
        git checkout d0eaa3eabce1c80d067a739749e4253546417722
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash net/packet/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303211503.hDK3soqh-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:22,
                    from arch/loongarch/include/asm/bug.h:59,
                    from include/linux/bug.h:5,
                    from include/linux/thread_info.h:13,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/loongarch/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/spinlock.h:56,
                    from include/linux/ipc.h:5,
                    from include/uapi/linux/sem.h:5,
                    from include/linux/sem.h:5,
                    from include/linux/compat.h:14,
                    from include/linux/ethtool.h:17,
                    from net/packet/af_packet.c:51:
   net/packet/af_packet.c: In function 'tpacket_fill_skb':
>> include/linux/kern_levels.h:5:25: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'int' [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:427:25: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:498:9: note: in expansion of macro 'printk'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~
   include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR        KERN_SOH "3"    /* error conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:498:16: note: in expansion of macro 'KERN_ERR'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |                ^~~~~~~~
   net/packet/af_packet.c:2625:25: note: in expansion of macro 'pr_err'
    2625 |                         pr_err("Packet exceed the number of skb frags(%lu)\n",
         |                         ^~~~~~


vim +5 include/linux/kern_levels.h

314ba3520e513a Joe Perches 2012-07-30  4  
04d2c8c83d0e3a Joe Perches 2012-07-30 @5  #define KERN_SOH	"\001"		/* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30  6  #define KERN_SOH_ASCII	'\001'
04d2c8c83d0e3a Joe Perches 2012-07-30  7
kernel test robot March 21, 2023, 7:24 a.m. UTC | #5
Hi Eric,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
patch link:    https://lore.kernel.org/r/20230321033704.936685-1-eric.dumazet%40gmail.com
patch subject: [PATCH net-next] net: introduce a config option to tweak MAX_SKB_FRAGS
config: riscv-randconfig-r016-20230319 (https://download.01.org/0day-ci/archive/20230321/202303211550.hxkdeVey-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/d0eaa3eabce1c80d067a739749e4253546417722
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
        git checkout d0eaa3eabce1c80d067a739749e4253546417722
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/bus/mhi/host/ kernel/bpf/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303211550.hxkdeVey-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from drivers/bus/mhi/host/init.c:15:
   In file included from include/linux/mhi.h:12:
>> include/linux/skbuff.h:593:19: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           skb_frag_t      frags[MAX_SKB_FRAGS];
                                 ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   1 error generated.
--
   In file included from drivers/bus/mhi/host/main.c:13:
   In file included from include/linux/mhi.h:12:
>> include/linux/skbuff.h:593:19: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           skb_frag_t      frags[MAX_SKB_FRAGS];
                                 ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   drivers/bus/mhi/host/main.c:803:13: warning: parameter 'event_quota' set but not used [-Wunused-but-set-parameter]
                                u32 event_quota)
                                    ^
   1 warning and 1 error generated.
--
   In file included from kernel/bpf/core.c:21:
   In file included from include/linux/filter.h:12:
>> include/linux/skbuff.h:593:19: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           skb_frag_t      frags[MAX_SKB_FRAGS];
                                 ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   kernel/bpf/core.c:1632:12: warning: no previous prototype for function 'bpf_probe_read_kernel' [-Wmissing-prototypes]
   u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr)
              ^
   kernel/bpf/core.c:1632:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr)
   ^
   static 
   1 warning and 1 error generated.
--
   In file included from kernel/bpf/btf.c:19:
   In file included from include/linux/bpf_verifier.h:9:
   In file included from include/linux/filter.h:12:
>> include/linux/skbuff.h:593:19: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           skb_frag_t      frags[MAX_SKB_FRAGS];
                                 ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
>> include/linux/skmsg.h:32:23: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           DECLARE_BITMAP(copy, MAX_MSG_FRAGS + 2);
                                ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:39:27: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           struct scatterlist              data[MAX_MSG_FRAGS + 2];
                                                ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:151:45: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           return end >= start ? end - start : end + (NR_MSG_FRAG_IDS - start);
                                                      ^
   include/linux/skmsg.h:17:28: note: expanded from macro 'NR_MSG_FRAG_IDS'
   #define NR_MSG_FRAG_IDS                 (MAX_MSG_FRAGS + 1)
                                            ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:177:47: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           BUILD_BUG_ON(ARRAY_SIZE(msg->sg.data) - 1 != NR_MSG_FRAG_IDS);
                                                        ^
   include/linux/skmsg.h:17:28: note: expanded from macro 'NR_MSG_FRAG_IDS'
   #define NR_MSG_FRAG_IDS                 (MAX_MSG_FRAGS + 1)
                                            ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:179:31: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           sg_init_marker(msg->sg.data, NR_MSG_FRAG_IDS);
                                        ^
   include/linux/skmsg.h:17:28: note: expanded from macro 'NR_MSG_FRAG_IDS'
   #define NR_MSG_FRAG_IDS                 (MAX_MSG_FRAGS + 1)
                                            ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:201:57: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           return sk_msg_iter_dist(msg->sg.start, msg->sg.end) == MAX_MSG_FRAGS;
                                                                  ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:254:2: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
           sk_msg_iter_next(msg, end);
           ^
   include/linux/skmsg.h:173:2: note: expanded from macro 'sk_msg_iter_next'
           sk_msg_iter_var_next(msg->sg.which)
           ^
   include/linux/skmsg.h:165:14: note: expanded from macro 'sk_msg_iter_var_next'
                   if (var == NR_MSG_FRAG_IDS)             \
                              ^
   include/linux/skmsg.h:17:28: note: expanded from macro 'NR_MSG_FRAG_IDS'
   #define NR_MSG_FRAG_IDS                 (MAX_MSG_FRAGS + 1)
                                            ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'
   #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
                         ^
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h:264:3: error: use of undeclared identifier 'CONFIG_MAX_SKB_FRAGS'
                   sk_msg_iter_var_next(i);
                   ^
   include/linux/skmsg.h:165:14: note: expanded from macro 'sk_msg_iter_var_next'
                   if (var == NR_MSG_FRAG_IDS)             \
                              ^
   include/linux/skmsg.h:17:28: note: expanded from macro 'NR_MSG_FRAG_IDS'
   #define NR_MSG_FRAG_IDS                 (MAX_MSG_FRAGS + 1)
                                            ^
   include/linux/skmsg.h:16:25: note: expanded from macro 'MAX_MSG_FRAGS'
   #define MAX_MSG_FRAGS                   MAX_SKB_FRAGS
                                           ^
   include/linux/skbuff.h:348:23: note: expanded from macro 'MAX_SKB_FRAGS'


vim +/CONFIG_MAX_SKB_FRAGS +593 include/linux/skbuff.h

6f89dbce8e11344 Sowmini Varadhan 2018-02-15  565  
^1da177e4c3f415 Linus Torvalds   2005-04-16  566  /* This data is invariant across clones and lives at
^1da177e4c3f415 Linus Torvalds   2005-04-16  567   * the end of the header data, ie. at skb->end.
^1da177e4c3f415 Linus Torvalds   2005-04-16  568   */
^1da177e4c3f415 Linus Torvalds   2005-04-16  569  struct skb_shared_info {
06b4feb37e64e54 Jonathan Lemon   2021-01-06  570  	__u8		flags;
de8f3a83b0a0fdd Daniel Borkmann  2017-09-25  571  	__u8		meta_len;
de8f3a83b0a0fdd Daniel Borkmann  2017-09-25  572  	__u8		nr_frags;
9f42f126154786e Ian Campbell     2012-01-05  573  	__u8		tx_flags;
7967168cefdbc63 Herbert Xu       2006-06-22  574  	unsigned short	gso_size;
7967168cefdbc63 Herbert Xu       2006-06-22  575  	/* Warning: this field is not always filled in (UFO)! */
7967168cefdbc63 Herbert Xu       2006-06-22  576  	unsigned short	gso_segs;
^1da177e4c3f415 Linus Torvalds   2005-04-16  577  	struct sk_buff	*frag_list;
ac45f602ee3d1b6 Patrick Ohly     2009-02-12  578  	struct skb_shared_hwtstamps hwtstamps;
7f564528a480084 Steffen Klassert 2017-04-08  579  	unsigned int	gso_type;
09c2d251b707236 Willem de Bruijn 2014-08-04  580  	u32		tskey;
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  581  
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  582  	/*
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  583  	 * Warning : all fields before dataref are cleared in __alloc_skb()
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  584  	 */
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  585  	atomic_t	dataref;
d16697cb6261d4c Lorenzo Bianconi 2022-01-21  586  	unsigned int	xdp_frags_size;
ec7d2f2cf3a1b76 Eric Dumazet     2010-05-05  587  
69e3c75f4d541a6 Johann Baudy     2009-05-18  588  	/* Intermediate layers must ensure that destructor_arg
69e3c75f4d541a6 Johann Baudy     2009-05-18  589  	 * remains valid until skb destructor */
69e3c75f4d541a6 Johann Baudy     2009-05-18  590  	void *		destructor_arg;
a6686f2f382b13f Shirley Ma       2011-07-06  591  
fed66381d65a351 Eric Dumazet     2010-07-22  592  	/* must be last field, see pskb_expand_head() */
fed66381d65a351 Eric Dumazet     2010-07-22 @593  	skb_frag_t	frags[MAX_SKB_FRAGS];
^1da177e4c3f415 Linus Torvalds   2005-04-16  594  };
^1da177e4c3f415 Linus Torvalds   2005-04-16  595
kernel test robot March 21, 2023, 7:24 a.m. UTC | #6
Hi Eric,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
patch link:    https://lore.kernel.org/r/20230321033704.936685-1-eric.dumazet%40gmail.com
patch subject: [PATCH net-next] net: introduce a config option to tweak MAX_SKB_FRAGS
config: sparc-randconfig-r004-20230319 (https://download.01.org/0day-ci/archive/20230321/202303211526.EFNmCcfA-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d0eaa3eabce1c80d067a739749e4253546417722
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
        git checkout d0eaa3eabce1c80d067a739749e4253546417722
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sparc SHELL=/bin/bash arch/sparc/kernel/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303211526.EFNmCcfA-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/net/net_namespace.h:43,
                    from include/linux/inet.h:42,
                    from arch/sparc/kernel/setup_64.c:27:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: error: parameter 'i' set but not used [-Werror=unused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
   arch/sparc/kernel/setup_64.c: At top level:
   arch/sparc/kernel/setup_64.c:615:13: error: no previous prototype for 'alloc_irqstack_bootmem' [-Werror=missing-prototypes]
     615 | void __init alloc_irqstack_bootmem(void)
         |             ^~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors
--
   In file included from include/linux/if_ether.h:19,
                    from include/linux/etherdevice.h:20,
                    from arch/sparc/kernel/idprom.c:13:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: error: parameter 'i' set but not used [-Werror=unused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: error: parameter 'f' set but not used [-Werror=unused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
   cc1: all warnings being treated as errors


vim +/i +2392 include/linux/skbuff.h

^1da177e4c3f41 Linus Torvalds 2005-04-16  2390  
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2391  static inline void __skb_fill_page_desc_noacc(struct skb_shared_info *shinfo,
84ce071e38a6e2 Pavel Begunkov 2022-07-12 @2392  					      int i, struct page *page,
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2393  					      int off, int size)
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2394  {
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2395  	skb_frag_t *frag = &shinfo->frags[i];
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2396  
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2397  	/*
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2398  	 * Propagate page pfmemalloc to the skb if we can. The problem is
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2399  	 * that not all callers have unique ownership of the page but rely
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2400  	 * on page_is_pfmemalloc doing the right thing(tm).
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2401  	 */
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2402  	frag->bv_page		  = page;
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2403  	frag->bv_offset		  = off;
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2404  	skb_frag_size_set(frag, size);
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2405  }
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2406
kernel test robot March 21, 2023, 7:24 a.m. UTC | #7
Hi Eric,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
patch link:    https://lore.kernel.org/r/20230321033704.936685-1-eric.dumazet%40gmail.com
patch subject: [PATCH net-next] net: introduce a config option to tweak MAX_SKB_FRAGS
config: alpha-randconfig-r011-20230319 (https://download.01.org/0day-ci/archive/20230321/202303211526.aQcBIvfK-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d0eaa3eabce1c80d067a739749e4253546417722
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Eric-Dumazet/net-introduce-a-config-option-to-tweak-MAX_SKB_FRAGS/20230321-113826
        git checkout d0eaa3eabce1c80d067a739749e4253546417722
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash init/ kernel/bpf/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303211526.aQcBIvfK-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/net/net_namespace.h:43,
                    from init/main.c:104:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: warning: parameter 'i' set but not used [-Wunused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
   init/main.c: At top level:
   init/main.c:775:20: warning: no previous prototype for 'arch_post_acpi_subsys_init' [-Wmissing-prototypes]
     775 | void __init __weak arch_post_acpi_subsys_init(void) { }
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
   init/main.c:787:20: warning: no previous prototype for 'mem_encrypt_init' [-Wmissing-prototypes]
     787 | void __init __weak mem_encrypt_init(void) { }
         |                    ^~~~~~~~~~~~~~~~
   init/main.c:789:20: warning: no previous prototype for 'poking_init' [-Wmissing-prototypes]
     789 | void __init __weak poking_init(void) { }
         |                    ^~~~~~~~~~~
--
   In file included from include/net/net_namespace.h:43,
                    from include/linux/inet.h:42,
                    from include/linux/sunrpc/msg_prot.h:205,
                    from include/linux/sunrpc/auth.h:14,
                    from include/linux/nfs_fs.h:31,
                    from init/do_mounts.c:22:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: warning: parameter 'i' set but not used [-Wunused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
--
   In file included from include/linux/filter.h:12,
                    from kernel/bpf/core.c:21:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: warning: parameter 'i' set but not used [-Wunused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
   kernel/bpf/core.c: At top level:
   kernel/bpf/core.c:1632:12: warning: no previous prototype for 'bpf_probe_read_kernel' [-Wmissing-prototypes]
    1632 | u64 __weak bpf_probe_read_kernel(void *dst, u32 size, const void *unsafe_ptr)
         |            ^~~~~~~~~~~~~~~~~~~~~
--
   In file included from include/linux/filter.h:12,
                    from include/linux/bpf_verifier.h:9,
                    from kernel/bpf/btf.c:19:
   include/linux/skbuff.h:348:23: error: 'CONFIG_MAX_SKB_FRAGS' undeclared here (not in a function); did you mean 'MAX_SKB_FRAGS'?
     348 | #define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
         |                       ^~~~~~~~~~~~~~~~~~~~
   include/linux/skbuff.h:593:31: note: in expansion of macro 'MAX_SKB_FRAGS'
     593 |         skb_frag_t      frags[MAX_SKB_FRAGS];
         |                               ^~~~~~~~~~~~~
   include/linux/skbuff.h: In function '__skb_fill_page_desc_noacc':
>> include/linux/skbuff.h:2392:51: warning: parameter 'i' set but not used [-Wunused-but-set-parameter]
    2392 |                                               int i, struct page *page,
         |                                               ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_ref':
>> include/linux/skbuff.h:3380:58: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3380 | static inline void skb_frag_ref(struct sk_buff *skb, int f)
         |                                                      ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_unref':
   include/linux/skbuff.h:3411:60: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3411 | static inline void skb_frag_unref(struct sk_buff *skb, int f)
         |                                                        ~~~~^
   include/linux/skbuff.h: In function 'skb_frag_set_page':
   include/linux/skbuff.h:3478:63: warning: parameter 'f' set but not used [-Wunused-but-set-parameter]
    3478 | static inline void skb_frag_set_page(struct sk_buff *skb, int f,
         |                                                           ~~~~^
   In file included from <command-line>:
   include/linux/skmsg.h: In function 'sk_msg_init':
   include/linux/build_bug.h:16:51: error: bit-field '<anonymous>' width not an integer constant
      16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
         |                                                   ^
   include/linux/compiler_types.h:377:23: note: in definition of macro '__compiletime_assert'
     377 |                 if (!(condition))                                       \
         |                       ^~~~~~~~~
   include/linux/compiler_types.h:397:9: note: in expansion of macro '_compiletime_assert'
     397 |         _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |         BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |         ^~~~~~~~~~~~~~~~
   include/linux/skmsg.h:177:9: note: in expansion of macro 'BUILD_BUG_ON'
     177 |         BUILD_BUG_ON(ARRAY_SIZE(msg->sg.data) - 1 != NR_MSG_FRAG_IDS);
         |         ^~~~~~~~~~~~
   include/linux/compiler.h:232:33: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     232 | #define __must_be_array(a)      BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
         |                                 ^~~~~~~~~~~~~~~~~
   include/linux/kernel.h:55:59: note: in expansion of macro '__must_be_array'
      55 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
         |                                                           ^~~~~~~~~~~~~~~
   include/linux/skmsg.h:177:22: note: in expansion of macro 'ARRAY_SIZE'
     177 |         BUILD_BUG_ON(ARRAY_SIZE(msg->sg.data) - 1 != NR_MSG_FRAG_IDS);
         |                      ^~~~~~~~~~
   In file included from kernel/bpf/btf.c:23:
   include/linux/skmsg.h: In function 'sk_msg_xfer':
>> include/linux/skmsg.h:183:36: warning: parameter 'which' set but not used [-Wunused-but-set-parameter]
     183 |                                int which, u32 size)
         |                                ~~~~^~~~~
   include/linux/skmsg.h: In function 'sk_msg_elem':
   include/linux/skmsg.h:209:71: warning: parameter 'which' set but not used [-Wunused-but-set-parameter]
     209 | static inline struct scatterlist *sk_msg_elem(struct sk_msg *msg, int which)
         |                                                                   ~~~~^~~~~
   include/linux/skmsg.h: In function 'sk_msg_elem_cpy':
   include/linux/skmsg.h:214:74: warning: parameter 'which' set but not used [-Wunused-but-set-parameter]
     214 | static inline struct scatterlist sk_msg_elem_cpy(struct sk_msg *msg, int which)
         |                                                                      ~~~~^~~~~
   kernel/bpf/btf.c: In function 'btf_seq_show':
   kernel/bpf/btf.c:7101:29: warning: function 'btf_seq_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    7101 |         seq_vprintf((struct seq_file *)show->target, fmt, args);
         |                             ^~~~~~~~
   kernel/bpf/btf.c: In function 'btf_snprintf_show':
   kernel/bpf/btf.c:7138:9: warning: function 'btf_snprintf_show' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
    7138 |         len = vsnprintf(show->target, ssnprintf->len_left, fmt, args);
         |         ^~~


vim +/i +2392 include/linux/skbuff.h

^1da177e4c3f41 Linus Torvalds 2005-04-16  2390  
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2391  static inline void __skb_fill_page_desc_noacc(struct skb_shared_info *shinfo,
84ce071e38a6e2 Pavel Begunkov 2022-07-12 @2392  					      int i, struct page *page,
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2393  					      int off, int size)
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2394  {
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2395  	skb_frag_t *frag = &shinfo->frags[i];
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2396  
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2397  	/*
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2398  	 * Propagate page pfmemalloc to the skb if we can. The problem is
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2399  	 * that not all callers have unique ownership of the page but rely
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2400  	 * on page_is_pfmemalloc doing the right thing(tm).
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2401  	 */
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2402  	frag->bv_page		  = page;
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2403  	frag->bv_offset		  = off;
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2404  	skb_frag_size_set(frag, size);
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2405  }
84ce071e38a6e2 Pavel Begunkov 2022-07-12  2406
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index fe661011644b8f468ff5e92075a6624f0557584c..43726ca7d20f232461a4d2e5b984032806e9c13e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -345,18 +345,8 @@  struct sk_buff_head {
 
 struct sk_buff;
 
-/* To allow 64K frame to be packed as single skb without frag_list we
- * require 64K/PAGE_SIZE pages plus 1 additional page to allow for
- * buffers which do not start on a page boundary.
- *
- * Since GRO uses frags we allocate at least 16 regardless of page
- * size.
- */
-#if (65536/PAGE_SIZE + 1) < 16
-#define MAX_SKB_FRAGS 16UL
-#else
-#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1)
-#endif
+#define MAX_SKB_FRAGS CONFIG_MAX_SKB_FRAGS
+
 extern int sysctl_max_skb_frags;
 
 /* Set skb_shinfo(skb)->gso_size to this in case you want skb_segment to
diff --git a/net/Kconfig b/net/Kconfig
index 48c33c2221999e575c83a409ab773b9cc3656eab..f806722bccf450c62e07bfdb245e5195ac4a156d 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -251,6 +251,18 @@  config PCPU_DEV_REFCNT
 	  network device refcount are using per cpu variables if this option is set.
 	  This can be forced to N to detect underflows (with a performance drop).
 
+config MAX_SKB_FRAGS
+	int "Maximum number of fragments per skb_shared_info"
+	range 17 45
+	default 17
+	help
+	  Having more fragments per skb_shared_info can help GRO efficiency.
+	  This helps BIG TCP workloads, but might expose bugs in some
+	  legacy drivers.
+	  This also increases memory overhead of small packets,
+	  and in drivers using build_skb().
+	  If unsure, say 17.
+
 config RPS
 	bool
 	depends on SMP && SYSFS