Skip to contentSkip to conversation

net/virtio-net: reverse unregistering on exit

PATCH In review Pierre Morel 2 participants 6 messages Aug 22, 2017 – Aug 23, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio-net: reverse unregistering on exit

Hi,

I got a problem with virtio-net in a QEMU guest.

When virtio-net is used as a module in a guest and the network is activated, removing the virtio-net modules produces a kernel error:

[ 2375.624949] Last Breaking-Event-Address:
[ 2375.624954]  [<00000000001453d4>] __cpuhp_remove_state+0x84/0x1a8
[ 2375.624959] ---[ end trace cc9fd68b89f5235a ]---
[ 2375.624966] Error: Removing state 163 which has instances left.
[ 2375.624985] ------------[ cut here ]------------

The problem is produced by an inversion in the order of unregistering the driver and the hotplug state machine callbacks in virtio_net_driver_exit.

This patch solves the problem by first unregistering the virtio_net_driver before unregistering the hotplug state machine callbacks.

Best regards,

Pierre Morel

Pierre Morel (1):
net/virtio-net: reverse unregistering on exit

 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 net/virtio-net: reverse unregistering on exit

unregister_virtio_driver should be done before the unregistering of the hotplug state machine callbacks, otherwise the state machine still holds some instance states at that time.

Let's first unregister the virtio_net_driver first and then the hotplug state machine callbacks.

---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
index 143d8a9..c042ffd 100644
@@ -2734,9 +2734,9 @@ module_init(virtio_net_driver_init);
 
 static __exit void virtio_net_driver_exit(void)
 {
+	unregister_virtio_driver(&virtio_net_driver);
 	cpuhp_remove_multi_state(CPUHP_VIRT_NET_DEAD);
 	cpuhp_remove_multi_state(virtionet_online);
-	unregister_virtio_driver(&virtio_net_driver);
 }
 module_exit(virtio_net_driver_exit);
 
Signature · 1 line
2.7.4
#2 lore raw
Quoted 8 lines · Pierre Morel

unregister_virtio_driver should be done before the unregistering of the hotplug state machine callbacks, otherwise the state machine still holds some instance states at that time.

Let's first unregister the virtio_net_driver first and then the hotplug state machine callbacks.

I'm having a deja vu.

Wasn't this fixed by

commit cfa0ebc9d6d6308564f5174ecb655b9d504b2be5

Author: Andrew Jones <[email protected]>
Date:   Mon Jul 24 15:38:32 2017 +0200

virtio-net: fix module unloading

already?

Quoted 21 lines
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
index 143d8a9..c042ffd 100644
@@ -2734,9 +2734,9 @@ module_init(virtio_net_driver_init);
 
 static __exit void virtio_net_driver_exit(void)
 {
+	unregister_virtio_driver(&virtio_net_driver);
 	cpuhp_remove_multi_state(CPUHP_VIRT_NET_DEAD);
 	cpuhp_remove_multi_state(virtionet_online);
-	unregister_virtio_driver(&virtio_net_driver);
 }
 module_exit(virtio_net_driver_exit);
 
Signature · 1 line
2.7.4
#3 lore raw
Quoted 14 lines · Michael S. Tsirkin
Quoted 8 lines · Pierre Morel

unregister_virtio_driver should be done before the unregistering of the hotplug state machine callbacks, otherwise the state machine still holds some instance states at that time.

Let's first unregister the virtio_net_driver first and then the hotplug state machine callbacks.

I'm having a deja vu.

Wasn't this fixed by

Quoted 7 lines

commit cfa0ebc9d6d6308564f5174ecb655b9d504b2be5

Author: Andrew Jones <[email protected]>
Date:   Mon Jul 24 15:38:32 2017 +0200

virtio-net: fix module unloading

already?

hum... yes, sorry

Quoted 23 lines
Quoted 22 lines
---
  drivers/net/virtio_net.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio_net.c +1 -1
index 143d8a9..c042ffd 100644
@@ -2734,9 +2734,9 @@ module_init(virtio_net_driver_init);
 
  static __exit void virtio_net_driver_exit(void)
  {
+	unregister_virtio_driver(&virtio_net_driver);
  	cpuhp_remove_multi_state(CPUHP_VIRT_NET_DEAD);
  	cpuhp_remove_multi_state(virtionet_online);
-	unregister_virtio_driver(&virtio_net_driver);
  }
  module_exit(virtio_net_driver_exit);
 
Signature · 1 line
2.7.4
Signature · 7 lines
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#4 lore raw
In reply to Pierre Morel
Quoted 4 lines · Pierre Morel

Hi,

I got a problem with virtio-net in a QEMU guest.

Quoted 8 lines

When virtio-net is used as a module in a guest and the network is activated, removing the virtio-net modules produces a kernel error:

[ 2375.624949] Last Breaking-Event-Address:
[ 2375.624954]  [<00000000001453d4>] __cpuhp_remove_state+0x84/0x1a8
[ 2375.624959] ---[ end trace cc9fd68b89f5235a ]---
[ 2375.624966] Error: Removing state 163 which has instances left.
[ 2375.624985] ------------[ cut here ]------------

Which kernel do you use?

Quoted 18 lines

The problem is produced by an inversion in the order of unregistering the driver and the hotplug state machine callbacks in virtio_net_driver_exit.

This patch solves the problem by first unregistering the virtio_net_driver before unregistering the hotplug state machine callbacks.

Best regards,

Pierre Morel

Pierre Morel (1):
net/virtio-net: reverse unregistering on exit

 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.7.4
#5 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Pierre Morel

Hi,

I got a problem with virtio-net in a QEMU guest.

When virtio-net is used as a module in a guest and the network is activated, removing the virtio-net modules produces a kernel error:

Quoted 7 lines
Quoted 5 lines
[ 2375.624949] Last Breaking-Event-Address:
[ 2375.624954]  [<00000000001453d4>] __cpuhp_remove_state+0x84/0x1a8
[ 2375.624959] ---[ end trace cc9fd68b89f5235a ]---
[ 2375.624966] Error: Removing state 163 which has instances left.
[ 2375.624985] ------------[ cut here ]------------

Which kernel do you use?

A too old one , 4.12.0 , I forgot to check on linux-next. The problem has indeed been solved in between. Sorry for the noise.

Quoted 21 lines
Quoted 20 lines

The problem is produced by an inversion in the order of unregistering the driver and the hotplug state machine callbacks in virtio_net_driver_exit.

This patch solves the problem by first unregistering the virtio_net_driver before unregistering the hotplug state machine callbacks.

Best regards,

Pierre Morel

Pierre Morel (1):
net/virtio-net: reverse unregistering on exit

  drivers/net/virtio_net.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.7.4
Signature · 7 lines
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization