netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/3] skbuff: introduce skbuff_heads reusing and bulking
@ 2021-01-13 13:35 Alexander Lobakin
  2021-01-13 13:36 ` [PATCH v2 net-next 1/3] skbuff: open-code __build_skb() inside __napi_alloc_skb() Alexander Lobakin
  0 siblings, 1 reply; 13+ messages in thread
From: Alexander Lobakin @ 2021-01-13 13:35 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski
  Cc: Eric Dumazet, Edward Cree, Jonathan Lemon, Willem de Bruijn,
	Miaohe Lin, Alexander Lobakin, Steffen Klassert, Guillaume Nault,
	Yadu Kishore, Al Viro, netdev, linux-kernel

Currently, all sorts of skb allocation always do allocate
skbuff_heads one by one via kmem_cache_alloc().
On the other hand, we have percpu napi_alloc_cache to store
skbuff_heads queued up for freeing and flush them by bulks.

We can use this cache not only for bulk-wiping, but also to obtain
heads for new skbs and avoid unconditional allocations, as well as
for bulk-allocating.
As accessing napi_alloc_cache implies NAPI softirq context, do this
only for __napi_alloc_skb() and its derivatives (napi_alloc_skb()
and napi_get_frags()). The rough amount of their call sites are 69,
which is quite a number.

iperf3 showed 35-50 Mbps bumps for both TCP and UDP while performing
VLAN NAT on 1.2 GHz MIPS board. The boost is likely to be way bigger
on more powerful hosts and NICs with tens of Mpps.

Since v1 [0]:
 - use one unified cache instead of two separate to greatly simplify
   the logics and reduce hotpath overhead (Edward Cree);
 - new: recycle also GRO_MERGED_FREE skbs instead of immediate
   freeing;
 - correct performance numbers after optimizations and performing
   lots of tests for different use cases.

[0] https://lore.kernel.org/netdev/20210111182655.12159-1-alobakin@pm.me

Alexander Lobakin (3):
  skbuff: open-code __build_skb() inside __napi_alloc_skb()
  skbuff: (re)use NAPI skb cache on allocation path
  skbuff: recycle GRO_MERGED_FREE skbs into NAPI skb cache

 include/linux/skbuff.h |  1 +
 net/core/dev.c         |  9 +----
 net/core/skbuff.c      | 74 +++++++++++++++++++++++++++++-------------
 3 files changed, 54 insertions(+), 30 deletions(-)

-- 
2.30.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-01-14 13:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13 13:35 [PATCH v2 net-next 0/3] skbuff: introduce skbuff_heads reusing and bulking Alexander Lobakin
2021-01-13 13:36 ` [PATCH v2 net-next 1/3] skbuff: open-code __build_skb() inside __napi_alloc_skb() Alexander Lobakin
2021-01-13 13:37   ` [PATCH v2 net-next 2/3] skbuff: (re)use NAPI skb cache on allocation path Alexander Lobakin
2021-01-13 14:36     ` Eric Dumazet
2021-01-14 11:41       ` Alexander Lobakin
2021-01-14 11:47         ` Dmitry Vyukov
2021-01-14 12:44           ` Alexander Lobakin
2021-01-14 12:50             ` Dmitry Vyukov
2021-01-14 12:51               ` Dmitry Vyukov
2021-01-14 13:06                 ` Alexander Lobakin
2021-01-14 13:00               ` Alexander Lobakin
2021-01-14 13:01                 ` Dmitry Vyukov
2021-01-13 13:37   ` [PATCH v2 net-next 3/3] skbuff: recycle GRO_MERGED_FREE skbs into NAPI skb cache Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).