Re: [PATCH net-next 09/15] net: increase MAX_SKB_FRAGS
From: Eric Dumazet <edumazet@google.com>
Date: 2022-02-03 19:54:59
Subsystem:
networking [general], the rest · Maintainers:
"David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
On Thu, Feb 3, 2022 at 11:20 AM Eric Dumazet [off-list ref] wrote:
Another issue with CONFIG_ options is that they are integer. Trying the following did not work #define MAX_SKB_FRAGS ((unsigned long)CONFIG_MAX_SKB_FRAGS) Because in some places we have #if ( MAX_SKB_FRAGS > ...) (MAX_SKB_FRAGS is UL currently, making it an integer might cause some signed/unsigned operations buggy)
I came to something like this, clearly this a bit ugly.
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 08c12c41c5a5907dccc7389f396394d8132d962e..cc3cac3ee109f95c8a51eb90ba4a3bf7bebe86eb100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h@@ -323,7 +323,15 @@ enum skb_drop_reason { SKB_DROP_REASON_MAX, }; +#ifdef CONFIG_MAX_SKB_FRAGS_17 +#define MAX_SKB_FRAGS 17UL +#endif +#ifdef CONFIG_MAX_SKB_FRAGS_25 +#define MAX_SKB_FRAGS 25UL +#endif +#ifdef CONFIG_MAX_SKB_FRAGS_45 #define MAX_SKB_FRAGS 45UL +#endif extern int sysctl_max_skb_frags;
diff --git a/net/Kconfig b/net/Kconfig
index 8a1f9d0287de3c32040eee03b60114c6e6d150bc..d91027a654c2aad7bfa55152ef81c882bf394aff100644
--- a/net/Kconfig
+++ b/net/Kconfig@@ -253,6 +253,29 @@ 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).
+choice
+ prompt "Maximum number of fragments per skb_shared_info"
+ default MAX_SKB_FRAGS_17
+
+config MAX_SKB_FRAGS_17
+ bool "17 fragments per skb_shared_info"
+ help
+ Some drivers have assumptions about MAX_SKB_FRAGS being 17.
+ Until they are fixed, it is safe to adopt the old limit.
+
+config MAX_SKB_FRAGS_25
+ bool "25 fragments per skb_shared_info"
+ help
+ Helps BIG TCP workloads, but might expose bugs in some legacy drivers.
+
+config MAX_SKB_FRAGS_45
+ bool "45 fragments per skb_shared_info"
+ help
+ Helps BIG TCP workloads, but might expose bugs in some legacy drivers.
+ This also increase memory overhead of small packets.
+
+endchoice
+
config RPS
bool
depends on SMP && SYSFS