1. 08 Jun, 2021 38 commits
  2. 07 Jun, 2021 2 commits
    • David S. Miller's avatar
      Merge branch 'page_pool-recycling' · dc8cf755
      David S. Miller authored
      Matteo Croce says:
      
      ====================
      page_pool: recycle buffers
      
      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
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dc8cf755
    • Matteo Croce's avatar
      mvneta: recycle buffers · e4017570
      Matteo Croce authored
      Use the new recycling API for page_pool.
      In a drop rate test, the packet rate increased by 10%,
      from 296 Kpps to 326 Kpps.
      
      perf top on a stock system shows:
      
      Overhead  Shared Object     Symbol
        23.66%  [kernel]          [k] __pi___inval_dcache_area
        22.85%  [mvneta]          [k] mvneta_rx_swbm
         7.54%  [kernel]          [k] kmem_cache_alloc
         6.49%  [kernel]          [k] eth_type_trans
         3.94%  [kernel]          [k] dev_gro_receive
         3.91%  [kernel]          [k] __netif_receive_skb_core
         3.91%  [kernel]          [k] kmem_cache_free
         3.76%  [kernel]          [k] page_pool_release_page
         3.56%  [kernel]          [k] free_unref_page
         2.40%  [kernel]          [k] build_skb
         1.49%  [kernel]          [k] skb_release_data
         1.45%  [kernel]          [k] __alloc_pages_bulk
         1.30%  [kernel]          [k] page_frag_free
      
      And this is the same output with recycling enabled:
      
      Overhead  Shared Object     Symbol
        26.41%  [kernel]          [k] __pi___inval_dcache_area
        25.00%  [mvneta]          [k] mvneta_rx_swbm
         8.14%  [kernel]          [k] kmem_cache_alloc
         6.84%  [kernel]          [k] eth_type_trans
         4.44%  [kernel]          [k] __netif_receive_skb_core
         4.38%  [kernel]          [k] kmem_cache_free
         4.16%  [kernel]          [k] dev_gro_receive
         3.21%  [kernel]          [k] page_pool_put_page
         2.41%  [kernel]          [k] build_skb
         1.82%  [kernel]          [k] skb_release_data
         1.61%  [kernel]          [k] napi_gro_receive
         1.25%  [kernel]          [k] page_pool_refill_alloc_cache
         1.16%  [kernel]          [k] __netif_receive_skb_list_core
      
      We can see that page_pool_release_page(), free_unref_page() and
      __alloc_pages_bulk() are no longer on top of the list when receiving
      traffic.
      
      The test was done with mausezahn on the TX side with 64 byte raw
      ethernet frames.
      Signed-off-by: default avatarMatteo Croce <mcroce@microsoft.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4017570