]> git.ipfire.org Git - thirdparty/linux.git/commit
netmem: add a couple of page helper wrappers
authorAlexander Lobakin <aleksander.lobakin@intel.com>
Tue, 3 Dec 2024 17:37:30 +0000 (18:37 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Dec 2024 02:41:07 +0000 (18:41 -0800)
commit9bd9f72a74344b54cfb6fcabf1173e6c6e5c6952
treeee14b293c360a8ff8079975820905e63ac83ddec
parente77d9aee951341119be16a991fcfc76d1154d22a
netmem: add a couple of page helper wrappers

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@intel.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://patch.msgid.link/20241203173733.3181246-8-aleksander.lobakin@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/netmem.h