Skip to content

page_pool: recycle buffers

Matteo Croce bpf linux-mm linux-rdma lkml netdev oe-kbuild-all 8 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (refs/heads/master):

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest5 patches 0 repliesApplied 5/5
  2. v75 patches 12 repliesSuperseded
  3. v65 patches 10 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v55 patches16 repliesSuperseded
v44 patches15 repliesSuperseded
v35 patches35 repliesSuperseded
v25 patches5 repliesSuperseded
v16 patches16 repliesSuperseded

Changes in v8 from the cover letter

- use page->lru.next instead of page->index for pfmemalloc
- remove conditional include
- rework page_pool_return_skb_page() so to have less conversions between page and addresses, and call compound_head() only once
- move some code from skb_free_head() to a new helper skb_pp_recycle()
- misc fixes

Patches in v8 All 5 applied

#Subject and filesSizeRepliesApplied
1/5mm: add a signature in struct pageinclude/linux/mm.h include/linux/mm_types.h include/linux/poison.h +1 more+22 -50 repliesApplied
2/5skbuff: add a parameter to __skb_frag_unrefdrivers/net/ethernet/marvell/sky2.c drivers/net/ethernet/mellanox/mlx4/en_rx.c include/linux/skbuff.h +2 more+10 -80 repliesApplied
3/5page_pool: Allow drivers to hint on SKB recyclinginclude/linux/skbuff.h include/net/page_pool.h net/core/page_pool.c +1 more+77 -70 repliesApplied
4/5mvpp2: recycle buffersdrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+1 -10 repliesApplied
5/5mvneta: recycle buffersdrivers/net/ethernet/marvell/mvneta.c+7 -40 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v8 yet.

Read the v8 thread

Cover letter [PATCH net-next v8 0/5] page_pool: recycle buffers

From: Matteo Croce <[email protected]>

This is a respin of [1]

This patchset shows the plans for allowing page_pool to handle and maintain DMA map/unmap of the pages it serves to the driver. For this to work a return hook in the network core is introduced.

The overall purpose is to simplify drivers, by providing a page allocation API that does recycling, such that each driver doesn't have to reinvent its own recycling scheme. Using page_pool in a driver does not require implementing XDP support, but it makes it trivially easy to do so. Instead of allocating buffers specifically for SKBs we now allocate a generic buffer and either wrap it on an SKB (via build_skb) or create an XDP frame.
The recycling code leverages the XDP recycle APIs.

The Marvell mvpp2 and mvneta drivers are used in this patchset to demonstrate how to use the API, and tested on a MacchiatoBIN and EspressoBIN boards respectively.

Please let this going in on a future -rc1 so to allow enough time to have wider tests.

v7 -> v8:
- use page->lru.next instead of page->index for pfmemalloc
- remove conditional include
- rework page_pool_return_skb_page() so to have less conversions between page and addresses, and call compound_head() only once
- move some code from skb_free_head() to a new helper skb_pp_recycle()
- misc fixes

v6 -> v7:
- refresh patches against net-next
- remove a redundant call to virt_to_head_page()
- update mvneta benchmarks

v5 -> v6:
- preserve pfmemalloc bit when setting signature
- fix typo in mvneta
- rebase on next-next with the new cache
- don't clear the skb->pp_recycle in pskb_expand_head()

v4 -> v5:
- move the signature so it doesn't alias with page->mapping
- use an invalid pointer as magic
- incorporate Matthew Wilcox's changes for pfmemalloc pages
- move the __skb_frag_unref() changes to a preliminary patch
- refactor some cpp directives
- only attempt recycling if skb->head_frag
- clear skb->pp_recycle in pskb_expand_head()

v3 -> v4:
- store a pointer to page_pool instead of xdp_mem_info
- drop a patch which reduces xdp_mem_info size
- do the recycling in the page_pool code instead of xdp_return
- remove some unused headers include
- remove some useless forward declaration

v2 -> v3:
- added missing SOBs
- CCed the MM people

v1 -> v2:
- fix a commit message
- avoid setting pp_recycle multiple times on mvneta
- squash two patches to avoid breaking bisect

[1] https://lore.kernel.org/netdev/154413868810.21735.572808840657728172.stgit@firesoul/

Ilias Apalodimas (1):
page_pool: Allow drivers to hint on SKB recycling

Matteo Croce (4):
mm: add a signature in struct page
skbuff: add a parameter to __skb_frag_unref
mvpp2: recycle buffers
mvneta: recycle buffers

 drivers/net/ethernet/marvell/mvneta.c         | 11 ++++--
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   |  2 +-
 drivers/net/ethernet/marvell/sky2.c           |  2 +-
 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  2 +-
 include/linux/mm.h                            | 11 +++---
 include/linux/mm_types.h                      |  7 ++++
 include/linux/poison.h                        |  3 ++
 include/linux/skbuff.h                        | 39 ++++++++++++++++---
 include/net/page_pool.h                       |  9 +++++
 net/core/page_pool.c                          | 28 +++++++++++++
 net/core/skbuff.c                             | 20 ++++++++--
 net/tls/tls_device.c                          |  2 +-
 12 files changed, 114 insertions(+), 22 deletions(-)
Signature · 1 line
2.31.1