Commit 1cdf3f2d authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'split-netmem-from-struct-page'

Byungchul Park says:

====================
Split netmem from struct page

The MM subsystem is trying to reduce struct page to a single pointer.
See the following link for your information:

   https://kernelnewbies.org/MatthewWilcox/Memdescs/Path

The first step towards that is splitting struct page by its individual
users, as has already been done with folio and slab.  This patchset does
that for page pool.

Matthew Wilcox tried and stopped the same work, you can see in:

   https://lore.kernel.org/20230111042214.907030-1-willy@infradead.org

I focused on removing the page pool members in struct page this time,
not moving the allocation code of page pool from net to mm.  It can be
done later if needed.
====================

Link: https://patch.msgid.link/20250721021835.63939-1-byungchul@sk.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 918c675b 9dfd871a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1045,7 +1045,9 @@ static void fec_enet_bd_init(struct net_device *dev)
				struct page *page = txq->tx_buf[i].buf_p;

				if (page)
					page_pool_put_page(page->pp, page, 0, false);
					page_pool_put_page(pp_page_to_nmdesc(page)->pp,
							   page, 0,
							   false);
			}

			txq->tx_buf[i].buf_p = NULL;
@@ -1586,7 +1588,8 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id, int budget)
			xdp_return_frame_rx_napi(xdpf);
		} else { /* recycle pages of XDP_TX frames */
			/* The dma_sync_size = 0 as XDP_TX has already synced DMA for_device */
			page_pool_put_page(page->pp, page, 0, true);
			page_pool_put_page(pp_page_to_nmdesc(page)->pp, page,
					   0, true);
		}

		txq->tx_buf[index].buf_p = NULL;
@@ -3348,7 +3351,8 @@ static void fec_enet_free_buffers(struct net_device *ndev)
			} else {
				struct page *page = txq->tx_buf[i].buf_p;

				page_pool_put_page(page->pp, page, 0, false);
				page_pool_put_page(pp_page_to_nmdesc(page)->pp,
						   page, 0, false);
			}

			txq->tx_buf[i].buf_p = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -1216,7 +1216,7 @@ static struct sk_buff *iavf_build_skb(const struct libeth_fqe *rx_buffer,
				      unsigned int size)
{
	struct page *buf_page = __netmem_to_page(rx_buffer->netmem);
	u32 hr = buf_page->pp->p.offset;
	u32 hr = pp_page_to_nmdesc(buf_page)->pp->p.offset;
	struct sk_buff *skb;
	void *va;

+5 −3
Original line number Diff line number Diff line
@@ -3276,8 +3276,10 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,

	hdr_page = __netmem_to_page(hdr->netmem);
	buf_page = __netmem_to_page(buf->netmem);
	dst = page_address(hdr_page) + hdr->offset + hdr_page->pp->p.offset;
	src = page_address(buf_page) + buf->offset + buf_page->pp->p.offset;
	dst = page_address(hdr_page) + hdr->offset +
		pp_page_to_nmdesc(hdr_page)->pp->p.offset;
	src = page_address(buf_page) + buf->offset +
		pp_page_to_nmdesc(buf_page)->pp->p.offset;

	memcpy(dst, src, LARGEST_ALIGN(copy));
	buf->offset += copy;
@@ -3296,7 +3298,7 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
struct sk_buff *idpf_rx_build_skb(const struct libeth_fqe *buf, u32 size)
{
	struct page *buf_page = __netmem_to_page(buf->netmem);
	u32 hr = buf_page->pp->p.offset;
	u32 hr = pp_page_to_nmdesc(buf_page)->pp->p.offset;
	struct sk_buff *skb;
	void *va;

+1 −1
Original line number Diff line number Diff line
@@ -1571,7 +1571,7 @@ static bool otx2_xdp_rcv_pkt_handler(struct otx2_nic *pfvf,
		cq->pool_ptrs++;
		if (xsk_buff) {
			xsk_buff_free(xsk_buff);
		} else if (page->pp) {
		} else if (pp_page_to_nmdesc(page)->pp) {
			page_pool_recycle_direct(pool->page_pool, page);
		} else {
			otx2_dma_unmap_page(pfvf, iova, pfvf->rbsize,
+3 −1
Original line number Diff line number Diff line
@@ -460,9 +460,11 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,

		truesize += frag_info->frag_stride;
		if (frag_info->frag_stride == PAGE_SIZE / 2) {
			struct netmem_desc *desc = pp_page_to_nmdesc(page);

			frags->page_offset ^= PAGE_SIZE / 2;
			release = page_count(page) != 1 ||
				  atomic_long_read(&page->pp_ref_count) != 1 ||
				  atomic_long_read(&desc->pp_ref_count) != 1 ||
				  page_is_pfmemalloc(page) ||
				  page_to_nid(page) != numa_mem_id();
		} else if (!priv->rx_headroom) {
Loading