To eliminate the use of struct page in page pool, the page pool users
should use netmem descriptor and APIs instead.
Make xdp access ->pp through netmem_desc instead of page.
Signed-off-by: Byungchul Park <byungchul@sk.com>
---
include/net/libeth/xdp.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/net/libeth/xdp.h b/include/net/libeth/xdp.h
index 6ce6aec6884c..f4880b50e804 100644
--- a/include/net/libeth/xdp.h
+++ b/include/net/libeth/xdp.h
@@ -1292,7 +1292,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
#endif
xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
- page->pp->p.offset, len, true);
+ pp_page_to_nmdesc(page)->pp->p.offset, len, true);
}
/**
--
2.17.1
Hi Byungchul,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]
url: https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
base: c65d34296b2252897e37835d6007bbd01b255742
patch link: https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/linux/timer.h:5,
from include/linux/netdevice.h:24,
from include/trace/events/xdp.h:8,
from include/linux/bpf_trace.h:5,
from include/net/libeth/xdp.h:7,
from drivers/net/ethernet/intel/libeth/tx.c:6:
include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
>> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
pp_page_to_nmdesc(page)->pp->p.offset, len, true);
^~~~
include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
^
include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)); \
^~~~~~~~~~~~~~~~~~~~~~
include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
pp_page_to_nmdesc(page)->pp->p.offset, len, true);
^~~~~~~~~~~~~~~~~
In file included from arch/arm/include/asm/cacheflush.h:10,
from include/linux/cacheflush.h:5,
from include/linux/highmem.h:8,
from include/linux/bvec.h:10,
from include/linux/skbuff.h:17,
from include/net/net_namespace.h:43,
from include/linux/netdevice.h:38,
from include/trace/events/xdp.h:8,
from include/linux/bpf_trace.h:5,
from include/net/libeth/xdp.h:7,
from drivers/net/ethernet/intel/libeth/tx.c:6:
include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
static inline bool page_pool_page_is_pp(struct page *page)
~~~~~~~~~~~~~^~~~
vim +1295 include/net/libeth/xdp.h
1263
1264 bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
1265 const struct libeth_fqe *fqe,
1266 u32 len);
1267
1268 /**
1269 * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
1270 * @xdp: XDP buffer to attach the head to
1271 * @fqe: FQE containing the head buffer
1272 * @len: buffer len passed from HW
1273 *
1274 * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
1275 * head with the Rx buffer data: data pointer, length, headroom, and
1276 * truesize/tailroom. Zeroes the flags.
1277 * Uses faster single u64 write instead of per-field access.
1278 */
1279 static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
1280 const struct libeth_fqe *fqe,
1281 u32 len)
1282 {
1283 const struct page *page = __netmem_to_page(fqe->netmem);
1284
1285 #ifdef __LIBETH_WORD_ACCESS
1286 static_assert(offsetofend(typeof(xdp->base), flags) -
1287 offsetof(typeof(xdp->base), frame_sz) ==
1288 sizeof(u64));
1289
1290 *(u64 *)&xdp->base.frame_sz = fqe->truesize;
1291 #else
1292 xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
1293 #endif
1294 xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> 1295 pp_page_to_nmdesc(page)->pp->p.offset, len, true);
1296 }
1297
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Fri, Jul 18, 2025 at 01:42:38AM +0800, kernel test robot wrote:
> Hi Byungchul,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
> base: c65d34296b2252897e37835d6007bbd01b255742
> patch link: https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
> patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
> config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/container_of.h:5,
> from include/linux/list.h:5,
> from include/linux/timer.h:5,
> from include/linux/netdevice.h:24,
> from include/trace/events/xdp.h:8,
> from include/linux/bpf_trace.h:5,
> from include/net/libeth/xdp.h:7,
> from drivers/net/ethernet/intel/libeth/tx.c:6:
> include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
> >> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> ^~~~
> include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
> #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
> ^
> include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
> DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)); \
> ^~~~~~~~~~~~~~~~~~~~~~
> include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
> pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> ^~~~~~~~~~~~~~~~~
> In file included from arch/arm/include/asm/cacheflush.h:10,
> from include/linux/cacheflush.h:5,
> from include/linux/highmem.h:8,
> from include/linux/bvec.h:10,
> from include/linux/skbuff.h:17,
> from include/net/net_namespace.h:43,
> from include/linux/netdevice.h:38,
> from include/trace/events/xdp.h:8,
> from include/linux/bpf_trace.h:5,
> from include/net/libeth/xdp.h:7,
> from drivers/net/ethernet/intel/libeth/tx.c:6:
> include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
> static inline bool page_pool_page_is_pp(struct page *page)
> ~~~~~~~~~~~~~^~~~
Oh. page_pool_page_is_pp() in the mainline code already has this issue
that the helper cannot take const struct page * as argument.
How should we resolve the issue? Changing page_pool_page_is_pp() to
macro and using _Generic again looks too much. Or should we? Any idea?
Byungchul
> vim +1295 include/net/libeth/xdp.h
>
> 1263
> 1264 bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
> 1265 const struct libeth_fqe *fqe,
> 1266 u32 len);
> 1267
> 1268 /**
> 1269 * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
> 1270 * @xdp: XDP buffer to attach the head to
> 1271 * @fqe: FQE containing the head buffer
> 1272 * @len: buffer len passed from HW
> 1273 *
> 1274 * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
> 1275 * head with the Rx buffer data: data pointer, length, headroom, and
> 1276 * truesize/tailroom. Zeroes the flags.
> 1277 * Uses faster single u64 write instead of per-field access.
> 1278 */
> 1279 static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
> 1280 const struct libeth_fqe *fqe,
> 1281 u32 len)
> 1282 {
> 1283 const struct page *page = __netmem_to_page(fqe->netmem);
> 1284
> 1285 #ifdef __LIBETH_WORD_ACCESS
> 1286 static_assert(offsetofend(typeof(xdp->base), flags) -
> 1287 offsetof(typeof(xdp->base), frame_sz) ==
> 1288 sizeof(u64));
> 1289
> 1290 *(u64 *)&xdp->base.frame_sz = fqe->truesize;
> 1291 #else
> 1292 xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
> 1293 #endif
> 1294 xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> > 1295 pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> 1296 }
> 1297
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
On Fri, Jul 18, 2025 at 09:43:46AM +0900, Byungchul Park wrote:
> On Fri, Jul 18, 2025 at 01:42:38AM +0800, kernel test robot wrote:
> > Hi Byungchul,
> >
> > kernel test robot noticed the following build warnings:
> >
> > [auto build test WARNING on c65d34296b2252897e37835d6007bbd01b255742]
> >
> > url: https://github.com/intel-lab-lkp/linux/commits/Byungchul-Park/netmem-introduce-struct-netmem_desc-mirroring-struct-page/20250717-150253
> > base: c65d34296b2252897e37835d6007bbd01b255742
> > patch link: https://lore.kernel.org/r/20250717070052.6358-13-byungchul%40sk.com
> > patch subject: [Intel-wired-lan] [PATCH net-next v11 12/12] libeth: xdp: access ->pp through netmem_desc instead of page
> > config: arm-randconfig-r072-20250717 (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/config)
> > compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250718/202507180111.jygqJHzk-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202507180111.jygqJHzk-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> > In file included from include/linux/container_of.h:5,
> > from include/linux/list.h:5,
> > from include/linux/timer.h:5,
> > from include/linux/netdevice.h:24,
> > from include/trace/events/xdp.h:8,
> > from include/linux/bpf_trace.h:5,
> > from include/net/libeth/xdp.h:7,
> > from drivers/net/ethernet/intel/libeth/tx.c:6:
> > include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff':
> > >> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
> > pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> > ^~~~
> > include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID'
> > #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e))))
> > ^
> > include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE'
> > DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)); \
> > ^~~~~~~~~~~~~~~~~~~~~~
> > include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc'
> > pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> > ^~~~~~~~~~~~~~~~~
> > In file included from arch/arm/include/asm/cacheflush.h:10,
> > from include/linux/cacheflush.h:5,
> > from include/linux/highmem.h:8,
> > from include/linux/bvec.h:10,
> > from include/linux/skbuff.h:17,
> > from include/net/net_namespace.h:43,
> > from include/linux/netdevice.h:38,
> > from include/trace/events/xdp.h:8,
> > from include/linux/bpf_trace.h:5,
> > from include/net/libeth/xdp.h:7,
> > from drivers/net/ethernet/intel/libeth/tx.c:6:
> > include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *'
> > static inline bool page_pool_page_is_pp(struct page *page)
> > ~~~~~~~~~~~~~^~~~
>
> Oh. page_pool_page_is_pp() in the mainline code already has this issue
> that the helper cannot take const struct page * as argument.
>
> How should we resolve the issue? Changing page_pool_page_is_pp() to
> macro and using _Generic again looks too much. Or should we? Any idea?
option 1. Remove 'const' on declaration of struct page in
libeth_xdp_prepare_buff() but maybe bad.
option 2. Use __pp_page_to_nmdesc() instead of pp_page_to_nmdesc() in
libeth_xdp_prepare_buff() to skip checking if it's a pp page.
option 3. Change page_pool_page_is_pp() to macro and use _Generic to
cover const casting.
More?
Byungchul
> Byungchul
>
> > vim +1295 include/net/libeth/xdp.h
> >
> > 1263
> > 1264 bool libeth_xdp_buff_add_frag(struct libeth_xdp_buff *xdp,
> > 1265 const struct libeth_fqe *fqe,
> > 1266 u32 len);
> > 1267
> > 1268 /**
> > 1269 * libeth_xdp_prepare_buff - fill &libeth_xdp_buff with head FQE data
> > 1270 * @xdp: XDP buffer to attach the head to
> > 1271 * @fqe: FQE containing the head buffer
> > 1272 * @len: buffer len passed from HW
> > 1273 *
> > 1274 * Internal, use libeth_xdp_process_buff() instead. Initializes XDP buffer
> > 1275 * head with the Rx buffer data: data pointer, length, headroom, and
> > 1276 * truesize/tailroom. Zeroes the flags.
> > 1277 * Uses faster single u64 write instead of per-field access.
> > 1278 */
> > 1279 static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,
> > 1280 const struct libeth_fqe *fqe,
> > 1281 u32 len)
> > 1282 {
> > 1283 const struct page *page = __netmem_to_page(fqe->netmem);
> > 1284
> > 1285 #ifdef __LIBETH_WORD_ACCESS
> > 1286 static_assert(offsetofend(typeof(xdp->base), flags) -
> > 1287 offsetof(typeof(xdp->base), frame_sz) ==
> > 1288 sizeof(u64));
> > 1289
> > 1290 *(u64 *)&xdp->base.frame_sz = fqe->truesize;
> > 1291 #else
> > 1292 xdp_init_buff(&xdp->base, fqe->truesize, xdp->base.rxq);
> > 1293 #endif
> > 1294 xdp_prepare_buff(&xdp->base, page_address(page) + fqe->offset,
> > > 1295 pp_page_to_nmdesc(page)->pp->p.offset, len, true);
> > 1296 }
> > 1297
> >
> > --
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
On 7/18/25 02:14, Byungchul Park wrote: ...>>> >>> In file included from include/linux/container_of.h:5, >>> from include/linux/list.h:5, >>> from include/linux/timer.h:5, >>> from include/linux/netdevice.h:24, >>> from include/trace/events/xdp.h:8, >>> from include/linux/bpf_trace.h:5, >>> from include/net/libeth/xdp.h:7, >>> from drivers/net/ethernet/intel/libeth/tx.c:6: >>> include/net/libeth/xdp.h: In function 'libeth_xdp_prepare_buff': >>>>> include/net/libeth/xdp.h:1295:23: warning: passing argument 1 of 'page_pool_page_is_pp' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] >>> pp_page_to_nmdesc(page)->pp->p.offset, len, true); >>> ^~~~ >>> include/linux/build_bug.h:30:63: note: in definition of macro 'BUILD_BUG_ON_INVALID' >>> #define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e)))) >>> ^ >>> include/net/netmem.h:301:2: note: in expansion of macro 'DEBUG_NET_WARN_ON_ONCE' >>> DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)); \ >>> ^~~~~~~~~~~~~~~~~~~~~~ >>> include/net/libeth/xdp.h:1295:5: note: in expansion of macro 'pp_page_to_nmdesc' >>> pp_page_to_nmdesc(page)->pp->p.offset, len, true); >>> ^~~~~~~~~~~~~~~~~ >>> In file included from arch/arm/include/asm/cacheflush.h:10, >>> from include/linux/cacheflush.h:5, >>> from include/linux/highmem.h:8, >>> from include/linux/bvec.h:10, >>> from include/linux/skbuff.h:17, >>> from include/net/net_namespace.h:43, >>> from include/linux/netdevice.h:38, >>> from include/trace/events/xdp.h:8, >>> from include/linux/bpf_trace.h:5, >>> from include/net/libeth/xdp.h:7, >>> from drivers/net/ethernet/intel/libeth/tx.c:6: >>> include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *' >>> static inline bool page_pool_page_is_pp(struct page *page) >>> ~~~~~~~~~~~~~^~~~ >> >> Oh. page_pool_page_is_pp() in the mainline code already has this issue >> that the helper cannot take const struct page * as argument. Probably not, and probably for wrong reasons. netmem_ref is define as an integer, compilers cast away such const unlike const pointers. >> How should we resolve the issue? Changing page_pool_page_is_pp() to >> macro and using _Generic again looks too much. Or should we? Any idea? page_pool_page_is_pp() doesn't change the page, just make the argument const. bool page_pool_page_is_pp(const struct page *page) -- Pavel Begunkov
On 7/18/25 10:18, Pavel Begunkov wrote: > On 7/18/25 02:14, Byungchul Park wrote: ...>>>> include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *' >>>> static inline bool page_pool_page_is_pp(struct page *page) >>>> ~~~~~~~~~~~~~^~~~ >>> >>> Oh. page_pool_page_is_pp() in the mainline code already has this issue >>> that the helper cannot take const struct page * as argument. > > Probably not, and probably for wrong reasons. netmem_ref is define > as an integer, compilers cast away such const unlike const pointers. Taking a look libeth, at least at the reported spot it does page->pp->p.offset, that should be fine. And your problem is caused by the is_pp check in pp_page_to_nmdesc(). -- Pavel Begunkov
On Fri, Jul 18, 2025 at 10:32:38AM +0100, Pavel Begunkov wrote: > On 7/18/25 10:18, Pavel Begunkov wrote: > > On 7/18/25 02:14, Byungchul Park wrote: > ...>>>> include/linux/mm.h:4176:54: note: expected 'struct page *' but argument is of type 'const struct page *' > > > > > static inline bool page_pool_page_is_pp(struct page *page) > > > > > ~~~~~~~~~~~~~^~~~ > > > > > > > > Oh. page_pool_page_is_pp() in the mainline code already has this issue > > > > that the helper cannot take const struct page * as argument. > > > > Probably not, and probably for wrong reasons. netmem_ref is define > > as an integer, compilers cast away such const unlike const pointers. > > Taking a look libeth, at least at the reported spot it does > page->pp->p.offset, that should be fine. And your problem > is caused by the is_pp check in pp_page_to_nmdesc(). Exactly, but you asked me to add the check, DEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p)) in pp_page_to_nmdesc(). What I meant was, in order to apply that, page_pool_page_is_pp() should take 'const struct page *' as argument. I think it's good idea to change the proto type like, as you said: static inline bool page_pool_page_is_pp(const struct page *page); Thanks. Byungchul > > -- > Pavel Begunkov >
© 2016 - 2026 Red Hat, Inc.