From 7f0e1ddf29c5e8d9e7811518a23420cb6a10417b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 5 Mar 2025 16:59:06 +0000 Subject: [PATCH] Revert "net: allow small head cache usage with large MAX_SKB_FRAGS values" This reverts commit ed0ca7d2127c63991cfaf1932b827e3f4f8ee480 which is commit 14ad6ed30a10afbe91b0749d6378285f4225d482 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I32153ebc29e736f73f8c4e4b6d6fa6b8fd35ed70 Signed-off-by: Greg Kroah-Hartman --- include/net/gro.h | 3 --- net/core/gro.c | 3 +++ net/core/skbuff.c | 10 +++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/net/gro.h b/include/net/gro.h index 7b548f91754b..b9b58c1f8d19 100644 --- a/include/net/gro.h +++ b/include/net/gro.h @@ -11,9 +11,6 @@ #include #include -/* This should be increased if a protocol with a bigger head is added. */ -#define GRO_MAX_HEAD (MAX_HEADER + 128) - struct napi_gro_cb { union { struct { diff --git a/net/core/gro.c b/net/core/gro.c index 78b320b63174..d1f44084e978 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -7,6 +7,9 @@ #define MAX_GRO_SKBS 8 +/* This should be increased if a protocol with a bigger head is added. */ +#define GRO_MAX_HEAD (MAX_HEADER + 128) + static DEFINE_SPINLOCK(offload_lock); /** diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 61a950f13a91..74149dc4ee31 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -69,7 +69,6 @@ #include #include #include -#include #include #include #include @@ -96,9 +95,7 @@ static struct kmem_cache *skbuff_ext_cache __ro_after_init; #endif -#define GRO_MAX_HEAD_PAD (GRO_MAX_HEAD + NET_SKB_PAD + NET_IP_ALIGN) -#define SKB_SMALL_HEAD_SIZE SKB_HEAD_ALIGN(max(MAX_TCP_HEADER, \ - GRO_MAX_HEAD_PAD)) +#define SKB_SMALL_HEAD_SIZE SKB_HEAD_ALIGN(MAX_TCP_HEADER) /* We want SKB_SMALL_HEAD_CACHE_SIZE to not be a power of two. * This should ensure that SKB_SMALL_HEAD_HEADROOM is a unique @@ -739,7 +736,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, /* If requested length is either too small or too big, * we use kmalloc() for skb->head allocation. */ - if (len <= SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE) || + if (len <= SKB_WITH_OVERHEAD(1024) || len > SKB_WITH_OVERHEAD(PAGE_SIZE) || (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE); @@ -819,8 +816,7 @@ struct sk_buff *napi_alloc_skb(struct napi_struct *napi, unsigned int len) * When the small frag allocator is available, prefer it over kmalloc * for small fragments */ - if ((!NAPI_HAS_SMALL_PAGE_FRAG && - len <= SKB_WITH_OVERHEAD(SKB_SMALL_HEAD_CACHE_SIZE)) || + if ((!NAPI_HAS_SMALL_PAGE_FRAG && len <= SKB_WITH_OVERHEAD(1024)) || len > SKB_WITH_OVERHEAD(PAGE_SIZE) || (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) { skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX | SKB_ALLOC_NAPI,