Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: page_pool: scale alloc cache with PAGE_SIZE

The current page_pool alloc-cache size and refill values were chosen to
match the NAPI budget and to leave headroom for XDP_DROP recycling.
These fixed values do not scale well with large pages,
as they significantly increase a given page_pool's memory footprint.

Scale these values to better balance memory footprint across page sizes,
while keeping behavior on 4KB-page systems unchanged.

Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Nimrod Oren <noren@nvidia.com>
Link: https://patch.msgid.link/20260309081301.103152-1-noren@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Nimrod Oren and committed by
Jakub Kicinski
15abbe7c 06fc88a6

+10 -1
+10 -1
include/net/page_pool/types.h
··· 44 44 * use-case. The NAPI budget is 64 packets. After a NAPI poll the RX 45 45 * ring is usually refilled and the max consumed elements will be 64, 46 46 * thus a natural max size of objects needed in the cache. 47 + * The refill watermark is set to 64 for 4KB pages, 48 + * and scales to balance its size in bytes across page sizes. 47 49 * 48 50 * Keeping room for more objects, is due to XDP_DROP use-case. As 49 51 * XDP_DROP allows the opportunity to recycle objects directly into ··· 53 51 * cache is already full (or partly full) then the XDP_DROP recycles 54 52 * would have to take a slower code path. 55 53 */ 56 - #define PP_ALLOC_CACHE_SIZE 128 54 + #if PAGE_SIZE >= SZ_64K 55 + #define PP_ALLOC_CACHE_REFILL 4 56 + #elif PAGE_SIZE >= SZ_16K 57 + #define PP_ALLOC_CACHE_REFILL 16 58 + #else 57 59 #define PP_ALLOC_CACHE_REFILL 64 60 + #endif 61 + 62 + #define PP_ALLOC_CACHE_SIZE (PP_ALLOC_CACHE_REFILL * 2) 58 63 struct pp_alloc_cache { 59 64 u32 count; 60 65 netmem_ref cache[PP_ALLOC_CACHE_SIZE];