[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250819074214.23d4332a@kernel.org>
Date: Tue, 19 Aug 2025 07:42:14 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Łukasz Majewski <lukasz.majewski@...lbox.org>
Cc: Andrew Lunn <andrew+netdev@...n.ch>, davem@...emloft.net, Eric Dumazet
<edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Rob Herring
<robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Shawn Guo <shawnguo@...nel.org>, Sascha Hauer
<s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Richard Cochran
<richardcochran@...il.com>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org, Stefan Wahren
<wahrenst@....net>, Simon Horman <horms@...nel.org>
Subject: Re: [net-next v18 5/7] net: mtip: Add mtip_switch_{rx|tx} functions
to the L2 switch driver
On Tue, 19 Aug 2025 10:31:19 +0200 Łukasz Majewski wrote:
> > The rx buffer circulation is very odd.
>
> The fec_main.c uses page_pool_alloc_pages() to allocate RX page from
> the pool.
>
> At the RX function the __build_skb(data, ...) is called to create skb.
>
> Last step with the RX function is to call skb_mark_for_recycle(skb),
> which sets skb->pp_recycle = 1.
>
> And yes, in the MTIP I do copy the data to the newly created skb in RX
> function (anyway, I need to swap bytes in the buffer).
>
> It seems like extra copy is performed in the RX function.
Right, so the use of page pool is entirely pointless.
The strength of the page pool is recycling the pages.
If you don't free / allocate pages on the fast path you're
just paying the extra overhead (of having a populated cache)
> > Also you are releasing the page to be recycled without clearing it
> > from the ring. I think you'd free it again on shutdown, so it's a
> > double-free.
>
> No, the page is persistent. It will be removed when the driver is
> closed and memory for pages and descriptors is released.
So remove the page_pool_recycle_direct() call, please:
static int mtip_switch_rx(struct net_device *dev, int budget, int *port)
...
skb = netdev_alloc_skb(pndev, pkt_len + NET_IP_ALIGN);
if (unlikely(!skb)) {
...
page_pool_recycle_direct(fep->page_pool, page);
Powered by blists - more mailing lists