Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Haishuang Yan
Sun, 29 Nov 2026 02:47
[PATCH net] net: update RX queue kobjects during device unregistration
Author: Haishuang Yan
Date: Sun, 29 Nov 2026 02:47
Date: Sun, 29 Nov 2026 02:47
50 lines
10769 bytes
10769 bytes
When unregister_netdevice_many_notify() sets NETREG_UNREGISTERING and
calls dev_xdp_uninstall(), a driver that shrinks real_num_rx_queues
(such as virtio_net) hits netif_set_real_num_rx_queues(). Because it
only checks NETREG_REGISTERED, it skips net_rx_queue_update_kobjects()
while still lowering dev->real_num_rx_queues. remove_queue_kobjects()
then leaks the extra RX queue kobjects and their netdev references,
hanging unregister with "waiting for eth0 to become free. Usage count
= 2".
Update RX queue kobjects under NETREG_UNREGISTERING too, matching
netif_set_real_num_tx_queues() from
commit 5c56580b74e5 ("net: Adjust TX queue kobjects if number of queues
changes during unregister").
Found and verified by unbinding virtio_net with XDP attached in an
x86_64 KVM guest (KASAN + NET_DEV_REFCNT_TRACKER).
Fixes: bd0b2e7fe611 ("net: xdp: make the stack take care of the tear down")
Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
---
The root cause was analyzed with the help of an AI coding assistant.
Tested on x86_64 KVM (net e1055cbfd6eb, KASAN + NET_DEV_REFCNT_TRACKER):
- before: unbinding virtio_net with XDP hangs ("Usage count = 2");
- after: unbind with/without XDP and with AF_XDP socket on XDP queue
all succeed cleanly; W=1 net/core/dev.o clean;
- not tested: other drivers, CONFIG_SYSFS=n, non-x86_64.
net/core/dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index cd0796a1dbf..09047ae78da 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3341,7 +3341,8 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq)
if (rxq < 1 || rxq > dev->num_rx_queues)
return -EINVAL;
- if (dev->reg_state == NETREG_REGISTERED) {
+ if (dev->reg_state == NETREG_REGISTERED ||
+ dev->reg_state == NETREG_UNREGISTERING) {
netdev_assert_locked_ops_compat(dev);
rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues,
base-commit: e1055cbfd6eb578417f3ce983cf44462e8465267
--
2.43.0
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads