Skip to content

Commit ef04d29

Browse files
committed
net: page_pool: do not count normal frag allocation in stats
Commit 0f6deac ("net: page_pool: add page allocation stats for two fast page allocate path") added increments for "fast path" allocation to page frag alloc. It mentions performance degradation analysis but the details are unclear. Could be that the author was simply surprised by the alloc stats not matching packet count. In my experience the key metric for page pool is the recycling rate. Page return stats, however, count returned _pages_ not frags. This makes it impossible to calculate recycling rate for drivers using the frag API. Here is example output of the page-pool YNL sample for a driver allocating 1200B frags (4k pages) with nearly perfect recycling: $ ./page-pool eth0[2] page pools: 32 (zombies: 0) refs: 291648 bytes: 1194590208 (refs: 0 bytes: 0) recycling: 33.3% (alloc: 4557:2256365862 recycle: 200476245:551541893) The recycling rate is reported as 33.3% because we give out 4096 // 1200 = 3 frags for every recycled page. Effectively revert the aforementioned commit. This also aligns with the stats we would see for drivers which do the fragmentation themselves, although that's not a strong reason in itself. On the (very unlikely) path where we can reuse the current page let's bump the "cached" stat. The fact that we don't put the page in the cache is just an optimization. Acked-by: Jesper Dangaard Brouer <hawk@kernel.org> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Link: https://patch.msgid.link/20241109023303.3366500-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 7ed816b commit ef04d29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/page_pool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,7 @@ netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool,
950950
if (netmem && *offset + size > max_size) {
951951
netmem = page_pool_drain_frag(pool, netmem);
952952
if (netmem) {
953+
recycle_stat_inc(pool, cached);
953954
alloc_stat_inc(pool, fast);
954955
goto frag_reset;
955956
}
@@ -974,7 +975,6 @@ netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool,
974975

975976
pool->frag_users++;
976977
pool->frag_offset = *offset + size;
977-
alloc_stat_inc(pool, fast);
978978
return netmem;
979979
}
980980
EXPORT_SYMBOL(page_pool_alloc_frag_netmem);

0 commit comments

Comments
 (0)