Thread (29 messages) flat view 29 messages, 5 authors, 2023-08-18

Re: [RFC net-next 05/13] net: page_pool: record pools per netdev

From: Simon Horman <horms@kernel.org>
Date: 2023-08-17 07:26:13

On Wed, Aug 16, 2023 at 04:42:54PM -0700, Jakub Kicinski wrote:
Link the page pools with netdevs. This needs to be netns compatible
so we have two options. Either we record the pools per netns and
have to worry about moving them as the netdev gets moved.
Or we record them directly on the netdev so they move with the netdev
without any extra work.

Implement the latter option. Since pools may outlast netdev we need
a place to store orphans. In time honored tradition use loopback
for this purpose.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
...
quoted hunk ↗ jump to hunk
diff --git a/net/core/page_pool_user.c b/net/core/page_pool_user.c
...
+static void page_pool_unreg_netdev(struct net_device *netdev)
+{
+	struct page_pool *pool, *last;
+	struct net_device *lo;
+
+	lo = __dev_get_by_index(dev_net(netdev), 1);
+	if (!lo) {
+		netdev_err_once(netdev,
+				"can't get lo to store orphan page pools\n");
+		page_pool_unreg_netdev_wipe(netdev);
+		return;
+	}
+
+	mutex_lock(&page_pools_lock);
+	hlist_for_each_entry(pool, &netdev->page_pools, user.list) {
+		pool->slow.netdev = lo;
+		last = pool;
+	}
+
+	hlist_splice_init(&netdev->page_pools, &last->user.list,
Hi Jakub.

I'm not sure if it is possible, but if the hlist loop above iterates zero
times then last will be uninitialised here.

Flagged by Smatch.
+			  &lo->page_pools);
+	mutex_unlock(&page_pools_lock);
+}
...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help