[RFC 00/19] Split netmem from struct page

Byungchul Park posted 19 patches 7 months, 1 week ago
There is a newer version of this series
drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  46 ++++----
drivers/net/ethernet/mellanox/mlx4/en_tx.c    |   8 +-
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h  |   4 +-
drivers/net/ethernet/mellanox/mlx5/core/en.h  |   4 +-
.../net/ethernet/mellanox/mlx5/core/en/xdp.c  |  18 +--
.../net/ethernet/mellanox/mlx5/core/en/xdp.h  |   2 +-
.../net/ethernet/mellanox/mlx5/core/en_main.c |  15 ++-
.../net/ethernet/mellanox/mlx5/core/en_rx.c   |  66 +++++------
include/linux/mm_types.h                      |  13 +--
include/linux/skbuff.h                        |  18 ++-
include/net/netmem.h                          |  88 +++++----------
include/net/netmem_type.h                     |  22 ++++
include/net/page_pool/helpers.h               |  17 ++-
include/net/page_pool/memory_provider.h       |   6 +-
include/net/page_pool/types.h                 |   2 +
io_uring/zcrx.c                               |  42 +++----
mm/page_alloc.c                               |   5 +-
net/core/devmem.c                             |  14 +--
net/core/devmem.h                             |  24 ++--
net/core/page_pool.c                          | 106 ++++++++++--------
net/core/skbuff.c                             |   5 -
net/ipv4/tcp.c                                |   2 +-
22 files changed, 272 insertions(+), 255 deletions(-)
create mode 100644 include/net/netmem_type.h
[RFC 00/19] Split netmem from struct page
Posted by Byungchul Park 7 months, 1 week ago
The MM subsystem is trying to reduce struct page to a single pointer.
The first step towards that is splitting struct page by its individual
users, as has already been done with folio and slab.  This patchset does
that for netmem which is used for page pools.

Matthew Wilcox tried and stopped the same work, you can see in:

   https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/

Mina Almasry already has done a lot fo prerequisite works by luck, he
said :).  I stacked my patches on the top of his work e.i. netmem.

I focused on removing the page pool members in struct page this time,
not moving the allocation code of page pool from net to mm.  It can be
done later if needed.

There are still a lot of works to do, to remove the dependency on struct
page in the network subsystem.  I will continue to work on this after
this base patchset is merged.

This patchset is based on mm tree's mm-unstable branch.

Byungchul Park (19):
  netmem: rename struct net_iov to struct netmem_desc
  netmem: introduce netmem alloc/put API to wrap page alloc/put API
  page_pool: use netmem alloc/put API in __page_pool_alloc_page_order()
  page_pool: rename __page_pool_alloc_page_order() to
    __page_pool_alloc_large_netmem()
  page_pool: use netmem alloc/put API in __page_pool_alloc_pages_slow()
  page_pool: rename page_pool_return_page() to page_pool_return_netmem()
  page_pool: use netmem alloc/put API in page_pool_return_netmem()
  page_pool: rename __page_pool_release_page_dma() to
    __page_pool_release_netmem_dma()
  page_pool: rename __page_pool_put_page() to __page_pool_put_netmem()
  page_pool: rename __page_pool_alloc_pages_slow() to
    __page_pool_alloc_netmems_slow()
  mlx4: use netmem descriptor and API for page pool
  netmem: introduce page_pool_recycle_direct_netmem()
  page_pool: expand scope of is_pp_{netmem,page}() to global
  mm: page_alloc: do not directly access page->pp_magic but use
    is_pp_page()
  mlx5: use netmem descriptor and API for page pool
  netmem: use _Generic to cover const casting for page_to_netmem()
  netmem: remove __netmem_get_pp()
  page_pool: make page_pool_get_dma_addr() just wrap
    page_pool_get_dma_addr_netmem()
  mm, netmem: remove the page pool members in struct page

 drivers/net/ethernet/mellanox/mlx4/en_rx.c    |  46 ++++----
 drivers/net/ethernet/mellanox/mlx4/en_tx.c    |   8 +-
 drivers/net/ethernet/mellanox/mlx4/mlx4_en.h  |   4 +-
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |   4 +-
 .../net/ethernet/mellanox/mlx5/core/en/xdp.c  |  18 +--
 .../net/ethernet/mellanox/mlx5/core/en/xdp.h  |   2 +-
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  15 ++-
 .../net/ethernet/mellanox/mlx5/core/en_rx.c   |  66 +++++------
 include/linux/mm_types.h                      |  13 +--
 include/linux/skbuff.h                        |  18 ++-
 include/net/netmem.h                          |  88 +++++----------
 include/net/netmem_type.h                     |  22 ++++
 include/net/page_pool/helpers.h               |  17 ++-
 include/net/page_pool/memory_provider.h       |   6 +-
 include/net/page_pool/types.h                 |   2 +
 io_uring/zcrx.c                               |  42 +++----
 mm/page_alloc.c                               |   5 +-
 net/core/devmem.c                             |  14 +--
 net/core/devmem.h                             |  24 ++--
 net/core/page_pool.c                          | 106 ++++++++++--------
 net/core/skbuff.c                             |   5 -
 net/ipv4/tcp.c                                |   2 +-
 22 files changed, 272 insertions(+), 255 deletions(-)
 create mode 100644 include/net/netmem_type.h


base-commit: fd93b3350b4314eebd8fbf0fea3ca7fe48d777e3
-- 
2.17.1
Re: [RFC 00/19] Split netmem from struct page
Posted by Mina Almasry 7 months, 1 week ago
On Fri, May 9, 2025 at 4:51 AM Byungchul Park <byungchul@sk.com> wrote:
>
> The MM subsystem is trying to reduce struct page to a single pointer.
> The first step towards that is splitting struct page by its individual
> users, as has already been done with folio and slab.  This patchset does
> that for netmem which is used for page pools.
>
> Matthew Wilcox tried and stopped the same work, you can see in:
>
>    https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/
>
> Mina Almasry already has done a lot fo prerequisite works by luck, he
> said :).  I stacked my patches on the top of his work e.i. netmem.
>
> I focused on removing the page pool members in struct page this time,
> not moving the allocation code of page pool from net to mm.  It can be
> done later if needed.
>
> There are still a lot of works to do, to remove the dependency on struct
> page in the network subsystem.  I will continue to work on this after
> this base patchset is merged.
>
> This patchset is based on mm tree's mm-unstable branch.
>

This series largely looks good to me, but a couple of things:

- For deep changes like this to the page_pool, I think we need a
before/after run to Jesper's currently out-of-tree benchmark to see
any regressions:
https://lore.kernel.org/netdev/20250309084118.3080950-1-almasrymina@google.com/

- Also please CC Pavel on iterations related to netmem/net_iov, they
are reusing that in io_uring code for iouring rx rc as well.

--
Thanks,
Mina
Re: [RFC 00/19] Split netmem from struct page
Posted by Byungchul Park 7 months, 1 week ago
On Fri, May 09, 2025 at 07:09:16AM -0700, Mina Almasry wrote:
> On Fri, May 9, 2025 at 4:51 AM Byungchul Park <byungchul@sk.com> wrote:
> >
> > The MM subsystem is trying to reduce struct page to a single pointer.
> > The first step towards that is splitting struct page by its individual
> > users, as has already been done with folio and slab.  This patchset does
> > that for netmem which is used for page pools.
> >
> > Matthew Wilcox tried and stopped the same work, you can see in:
> >
> >    https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/
> >
> > Mina Almasry already has done a lot fo prerequisite works by luck, he
> > said :).  I stacked my patches on the top of his work e.i. netmem.
> >
> > I focused on removing the page pool members in struct page this time,
> > not moving the allocation code of page pool from net to mm.  It can be
> > done later if needed.
> >
> > There are still a lot of works to do, to remove the dependency on struct
> > page in the network subsystem.  I will continue to work on this after
> > this base patchset is merged.
> >
> > This patchset is based on mm tree's mm-unstable branch.
> >
> 
> This series largely looks good to me, but a couple of things:
> 
> - For deep changes like this to the page_pool, I think we need a
> before/after run to Jesper's currently out-of-tree benchmark to see
> any regressions:
> https://lore.kernel.org/netdev/20250309084118.3080950-1-almasrymina@google.com/

Sure.  I will check it.

> - Also please CC Pavel on iterations related to netmem/net_iov, they
> are reusing that in io_uring code for iouring rx rc as well.

I will.  Thank you.

	Byungchul

> --
> Thanks,
> Mina
Re: [RFC 00/19] Split netmem from struct page
Posted by Pavel Begunkov 7 months, 1 week ago
On 5/12/25 13:36, Byungchul Park wrote:
> On Fri, May 09, 2025 at 07:09:16AM -0700, Mina Almasry wrote:
>> On Fri, May 9, 2025 at 4:51 AM Byungchul Park <byungchul@sk.com> wrote:
>>>
>>> The MM subsystem is trying to reduce struct page to a single pointer.
>>> The first step towards that is splitting struct page by its individual
>>> users, as has already been done with folio and slab.  This patchset does
>>> that for netmem which is used for page pools.
>>>
>>> Matthew Wilcox tried and stopped the same work, you can see in:
>>>
>>>     https://lore.kernel.org/linux-mm/20230111042214.907030-1-willy@infradead.org/
>>>
>>> Mina Almasry already has done a lot fo prerequisite works by luck, he
>>> said :).  I stacked my patches on the top of his work e.i. netmem.
>>>
>>> I focused on removing the page pool members in struct page this time,
>>> not moving the allocation code of page pool from net to mm.  It can be
>>> done later if needed.
>>>
>>> There are still a lot of works to do, to remove the dependency on struct
>>> page in the network subsystem.  I will continue to work on this after
>>> this base patchset is merged.
>>>
>>> This patchset is based on mm tree's mm-unstable branch.
>>>
>>
>> This series largely looks good to me, but a couple of things:
>>
>> - For deep changes like this to the page_pool, I think we need a
>> before/after run to Jesper's currently out-of-tree benchmark to see
>> any regressions:
>> https://lore.kernel.org/netdev/20250309084118.3080950-1-almasrymina@google.com/
> 
> Sure.  I will check it.
> 
>> - Also please CC Pavel on iterations related to netmem/net_iov, they
>> are reusing that in io_uring code for iouring rx rc as well.
> 
> I will.  Thank you.

Mina, thanks for CC'ing. And since it's touching io_uring, future
versions need to CC it as well.

-- 
Pavel Begunkov