Subject: Re: [RFC net] net: make page pool stall netdev unregistration to avoid IOMMU crashes

From: Jakub Kicinski <[email-masked]>
Date: Thu, 8 Aug 2024 07:05:11 -0700

On Thu, 8 Aug 2024 20:52:52 +0800 Yonglong Liu wrote:
> I hooks the netdev to the page pool, and run with this patch for a 
> while, then get
> 
> the following messages, and the vf can not disable:

> [ 1950.137586] hns3 0000:7d:01.0 eno1v0: link up
> [ 1950.137671] hns3 0000:7d:01.0 eno1v0: net open
> [ 1950.147098] 8021q: adding VLAN 0 to HW filter on device eno1v0
> [ 1974.287476] hns3 0000:7d:01.0 eno1v0: net stop
> [ 1974.294359] hns3 0000:7d:01.0 eno1v0: link down
> [ 1975.596916] hns3 0000:7d:01.0 eno1v0 (unregistered): page pool 
> release stalling device unregister
> [ 1976.744947] hns3 0000:7d:01.0 eno1v0 (unregistered): page pool 
> release stalling device unregister

So.. the patch works? :) We may want to add this to get the info prints
back:

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 2abe6e919224..26bc1618de7c 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1021,11 +1021,12 @@ static void page_pool_release_retry(struct work_struct *wq)
 	/* Periodic warning for page pools the user can't see */
 	netdev = READ_ONCE(pool->slow.netdev);
 	if (time_after_eq(jiffies, pool->defer_warn) &&
-	    (!netdev || netdev == NET_PTR_POISON)) {
+	    (!netdev || netdev == NET_PTR_POISON || netdev->pp_unreg_pending)) {
 		int sec = (s32)((u32)jiffies - (u32)pool->defer_start) / HZ;
 
-		pr_warn("%s() stalled pool shutdown: id %u, %d inflight %d sec\n",
-			__func__, pool->user.id, inflight, sec);
+		pr_warn("%s(): %s stalled pool shutdown: id %u, %d inflight %d sec (hold netdev: %d)\n",
+			__func__, netdev ? netdev_name(netdev) : "",
+			pool->user.id, inflight, sec, pool->defer_warn);
 		pool->defer_warn = jiffies + DEFER_WARN_INTERVAL;
 	}

> I install drgn, but don't know how to find out the using pages, would 
> you guide me on how to use it?

You can use this sample as a starting point:

https://github.com/osandov/drgn/blob/main/contrib/tcp_sock.py

but if the pages are actually leaked (rather than sitting in a socket),
you'll have to scan pages, not sockets. And figure out how they got leaked.
Somehow...