Thread (22 messages) flat view 22 messages, 3 authors, 2021-03-17
STALE1972d

[PATCH net-next v3 16/16] virtio_net: take the rtnl lock when calling virtnet_set_affinity

From: Antoine Tenart <atenart@kernel.org>
Date: 2021-03-12 15:06:13
Subsystem: networking drivers, the rest, virtio net driver · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds, "Michael S. Tsirkin", Jason Wang

netif_set_xps_queue must be called with the rtnl lock taken, and this is
now enforced using ASSERT_RTNL(). In virtio_net, netif_set_xps_queue is
called by virtnet_set_affinity. As this function can be called from an
ethtool helper, we can't take the rtnl lock directly in it. Instead we
take the rtnl lock when calling virtnet_set_affinity when the rtnl lock
isn't taken already.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
---
 drivers/net/virtio_net.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index dde9bbcc5ff0..54d2277f6c98 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -2027,7 +2027,9 @@ static int virtnet_cpu_online(unsigned int cpu, struct hlist_node *node)
 {
 	struct virtnet_info *vi = hlist_entry_safe(node, struct virtnet_info,
 						   node);
+	rtnl_lock();
 	virtnet_set_affinity(vi);
+	rtnl_unlock();
 	return 0;
 }
 
@@ -2035,7 +2037,9 @@ static int virtnet_cpu_dead(unsigned int cpu, struct hlist_node *node)
 {
 	struct virtnet_info *vi = hlist_entry_safe(node, struct virtnet_info,
 						   node_dead);
+	rtnl_lock();
 	virtnet_set_affinity(vi);
+	rtnl_unlock();
 	return 0;
 }
 
@@ -2883,7 +2887,9 @@ static int init_vqs(struct virtnet_info *vi)
 		goto err_free;
 
 	get_online_cpus();
+	rtnl_lock();
 	virtnet_set_affinity(vi);
+	rtnl_unlock();
 	put_online_cpus();
 
 	return 0;
-- 
2.29.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help