Re: [PATCH net-next v6 07/10] netmem: add a couple of page helper wrappers

From: Toke Høiland-Jørgensen
Date: Wed Dec 04 2024 - 05:49:24 EST


Alexander Lobakin <aleksander.lobakin@xxxxxxxxx> writes:

> Add the following netmem counterparts:
>
> * virt_to_netmem() -- simple page_to_netmem(virt_to_page()) wrapper;
> * netmem_is_pfmemalloc() -- page_is_pfmemalloc() for page-backed
> netmems, false otherwise;
>
> and the following "unsafe" versions:
>
> * __netmem_to_page()
> * __netmem_get_pp()
> * __netmem_address()
>
> They do the same as their non-underscored buddies, but assume the netmem
> is always page-backed. When working with header &page_pools, you don't
> need to check whether netmem belongs to the host memory and you can
> never get NULL instead of &page. Checks for the LSB, clearing the LSB,
> branches take cycles and increase object code size, sometimes
> significantly. When you're sure your PP is always host, you can avoid
> this by using the underscored counterparts.
>
> Signed-off-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>

Makes sense to have these as helpers, spelling out the constraints

Reviewed-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx>