Re: [PATCH net-next v2 3/3] net: devmem: batch net_iov allocations into the page_pool cache

From: Mina Almasry

Date: Mon Sep 14 2026 - 17:58:18 EST


On Fri, Sep 11, 2026 at 8:46 AM Stanislav Fomichev <sdf.kernel@xxxxxxxxx> wrote:
>
> Rename net_devmem_alloc_dmabuf() into net_devmem_alloc_dmabuf_bulk() and
> make it refill page pool with up to PP_ALLOC_CACHE_REFILL NIOVs,
> similar to io_pp_zc_alloc_netmems(). That should amortize recently
> introduced freelist_lock.
>
> Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxxx>
> ---
> net/core/devmem.c | 59 +++++++++++++++++++++++++++++------------------
> net/core/devmem.h | 8 -------
> 2 files changed, 37 insertions(+), 30 deletions(-)
>
> diff --git a/net/core/devmem.c b/net/core/devmem.c
> index 7949f8425bcd..a0dcc896dd12 100644
> --- a/net/core/devmem.c
> +++ b/net/core/devmem.c
> @@ -58,25 +58,25 @@ void __net_devmem_dmabuf_binding_free(struct work_struct *wq)
> kfree(binding);
> }
>
> -struct net_iov *
> -net_devmem_alloc_dmabuf(struct net_devmem_dmabuf_binding *binding)
> +static unsigned int
> +net_devmem_alloc_dmabuf_bulk(struct net_devmem_dmabuf_binding *binding,
> + netmem_ref *netmems, unsigned int count)
> {
> - struct net_iov *niov;
> + unsigned int i;
> +
> spin_lock_bh(&binding->freelist_lock);
> - if (unlikely(!binding->free_count)) {
> - spin_unlock_bh(&binding->freelist_lock);
> - return NULL;
> +
> + count = min_t(size_t, count, binding->free_count);
> + for (i = 0; i < count; i++) {
> + struct net_iov *niov = binding->freelist[--binding->free_count];
> +
> + binding->freelist[binding->free_count] = NULL;

Nulling is probably unnecessary?

Reviewed-by: Mina Almasry <almasrymina@xxxxxxxxxx>


--
Thanks,
Mina