Commit 57f05bc2 authored by Yunsheng Lin's avatar Yunsheng Lin Committed by Jakub Kicinski
Browse files

page_pool: keep pp info as long as page pool owns the page



Currently, page->pp is cleared and set everytime the page
is recycled, which is unnecessary.

So only set the page->pp when the page is added to the page
pool and only clear it when the page is released from the
page pool.

This is also a preparation to support allocating frag page
in page pool.

Reviewed-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2a2b6e36
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -2327,7 +2327,7 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool,
	if (!skb)
		return ERR_PTR(-ENOMEM);

	skb_mark_for_recycle(skb, virt_to_page(xdp->data), pool);
	skb_mark_for_recycle(skb);

	skb_reserve(skb, xdp->data - xdp->data_hard_start);
	skb_put(skb, xdp->data_end - xdp->data);
@@ -2339,10 +2339,6 @@ mvneta_swbm_build_skb(struct mvneta_port *pp, struct page_pool *pool,
		skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags,
				skb_frag_page(frag), skb_frag_off(frag),
				skb_frag_size(frag), PAGE_SIZE);
		/* We don't need to reset pp_recycle here. It's already set, so
		 * just mark fragments for recycling.
		 */
		page_pool_store_mem_info(skb_frag_page(frag), pool);
	}

	return skb;
+1 −1
Original line number Diff line number Diff line
@@ -3995,7 +3995,7 @@ static int mvpp2_rx(struct mvpp2_port *port, struct napi_struct *napi,
		}

		if (pp)
			skb_mark_for_recycle(skb, page, pp);
			skb_mark_for_recycle(skb);
		else
			dma_unmap_single_attrs(dev->dev.parent, dma_addr,
					       bm_pool->buf_size, DMA_FROM_DEVICE,
+1 −1
Original line number Diff line number Diff line
@@ -431,7 +431,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
	skb->protocol = eth_type_trans(skb, ndev);

	/* mark skb for recycling */
	skb_mark_for_recycle(skb, page, pool);
	skb_mark_for_recycle(skb);
	netif_receive_skb(skb);

	ndev->stats.rx_bytes += len;
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
	skb->protocol = eth_type_trans(skb, ndev);

	/* mark skb for recycling */
	skb_mark_for_recycle(skb, page, pool);
	skb_mark_for_recycle(skb);
	netif_receive_skb(skb);

	ndev->stats.rx_bytes += len;
+1 −3
Original line number Diff line number Diff line
@@ -4712,11 +4712,9 @@ static inline u64 skb_get_kcov_handle(struct sk_buff *skb)
}

#ifdef CONFIG_PAGE_POOL
static inline void skb_mark_for_recycle(struct sk_buff *skb, struct page *page,
					struct page_pool *pp)
static inline void skb_mark_for_recycle(struct sk_buff *skb)
{
	skb->pp_recycle = 1;
	page_pool_store_mem_info(page, pp);
}
#endif

Loading