Re: [PATCH 18/18] mm, netmem: remove the page pool members in struct page

From
Mina Almasry <hidden>
Date
2025-05-26 17:34:07
Also in
bpf, linux-mm, linux-rdma, lkml
Reply to
Pavel Begunkov, 2025-05-26
On Mon, May 26, 2025 at 9:57 AM Pavel Begunkov [off-list ref] wrote:
quoted
quoted
Removing these asserts is actually a bit dangerous. Functions like
netmem_or_pp_magic() rely on the fact that the offsets are the same
between struct page and struct net_iov to access these fields without
Worth noting this patch removes the page pool fields from struct page.
static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem)
{
        return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);
}

static inline atomic_long_t *netmem_get_pp_ref_count_ref(netmem_ref netmem)
{
        return &__netmem_clear_lsb(netmem)->pp_ref_count;
}

That's a snippet of code after applying the series. So, let's say we
take a page, it's casted to netmem, then the netmem (as it was before)
is casted to net_iov. Before it relied on net_iov and the pp's part of
the page having the same layout, which was checked by static asserts,
but now, unless I'm mistaken, it's aligned in the exactly same way but
points to a seemingly random offset of the page. We should not be doing
that.
Agreed.
Just to be clear, I think casting pages to struct net_iov *, as it
currently is, is quite ugly, but that's something netmem_desc and this
effort can help with.
Agreed it's quite ugly. It was done in the name of optimizing the page
pool benchmark to the extreme as far as I can remember. We could use
page pool benchmark numbers on this series to make sure these new
changes aren't regressing the fast path.

-- 
Thanks,
Mina
Thread (72 messages) 72 messages, 7 authors, last reply 2025-05-28
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help