Building net-next with powerpc with GCC 14 compiler results in this build error:
/home/sfr/next/tmp/ccuSzwiR.s: Assembler messages: /home/sfr/next/tmp/ccuSzwiR.s:2579: Error: operand out of domain (39 is not a multiple of 4) make[5]: *** [/home/sfr/next/next/scripts/Makefile.build:229: net/core/page_pool.o] Error 1 Root caused in this thread: https://lore.kernel.org/netdev/[email protected]/ We try to access offset 40 in the pointer returned by this function: static inline unsigned long _compound_head(const struct page *page) { unsigned long head = READ_ONCE(page->compound_head); if (unlikely(head & 1)) return head - 1; return (unsigned long)page_fixed_fake_head(page); } The GCC 14 (but not 11) compiler optimizes this by doing: ld page + 39 Rather than: ld (page - 1) + 40 And causing an unaligned load. Get around this by issuing a READ_ONCE as we convert the page to netmem. That disables the compiler optimizing the load in this way. Cc: Simon Horman <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: David Miller <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: Networking <[email protected]> Cc: Linux Kernel Mailing List <[email protected]> Cc: Linux Next Mailing List <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: "[email protected]" <[email protected]> Cc: Matthew Wilcox <[email protected]> Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Mina Almasry <[email protected]> --- v2: https://lore.kernel.org/netdev/[email protected]/ - Work around this issue as we convert the page to netmem, instead of a generic change that affects compound_head(). --- net/core/page_pool.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index a813d30d2135..74ea491d0ab2 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -859,12 +859,25 @@ void page_pool_put_page_bulk(struct page_pool *pool, void **data, { int i, bulk_len = 0; bool allow_direct; + netmem_ref netmem; + struct page *page; bool in_softirq; allow_direct = page_pool_napi_local(pool); for (i = 0; i < count; i++) { - netmem_ref netmem = page_to_netmem(virt_to_head_page(data[i])); + page = virt_to_head_page(data[i]); + + /* GCC 14 powerpc compiler will optimize reads into the + * resulting netmem_ref into unaligned reads as it sees address + * arithmetic in _compound_head() call that the page has come + * from. + * + * The READ_ONCE here gets around that by breaking the + * optimization chain between the address arithmetic and later + * indexing. + */ + netmem = page_to_netmem(READ_ONCE(page)); /* It is not the last user for the page frag case */ if (!page_pool_is_last_ref(netmem)) -- 2.46.0.662.g92d0881bb0-goog
