public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] net/virtio-net: reverse unregistering on exit
@ 2017-08-22 14:59 Pierre Morel
  2017-08-22 14:59 ` Pierre Morel
  2017-08-22 18:17 ` Michael S. Tsirkin
  0 siblings, 2 replies; 6+ messages in thread
From: Pierre Morel @ 2017-08-22 14:59 UTC (permalink / raw)
  To: virtualization; +Cc: mst

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(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] net/virtio-net: reverse unregistering on exit
  2017-08-22 14:59 [PATCH] net/virtio-net: reverse unregistering on exit Pierre Morel
@ 2017-08-22 14:59 ` Pierre Morel
  2017-08-22 18:13   ` Michael S. Tsirkin
  2017-08-22 18:17 ` Michael S. Tsirkin
  1 sibling, 1 reply; 6+ messages in thread
From: Pierre Morel @ 2017-08-22 14:59 UTC (permalink / raw)
  To: virtualization; +Cc: mst

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.

Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 143d8a9..c042ffd 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -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);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] net/virtio-net: reverse unregistering on exit
  2017-08-22 14:59 ` Pierre Morel
@ 2017-08-22 18:13   ` Michael S. Tsirkin
  2017-08-23  8:28     ` Pierre Morel
  0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2017-08-22 18:13 UTC (permalink / raw)
  To: Pierre Morel; +Cc: virtualization

On Tue, Aug 22, 2017 at 04:59:52PM +0200, Pierre Morel wrote:
> 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.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>

I'm having a deja vu.

Wasn't this fixed by

commit cfa0ebc9d6d6308564f5174ecb655b9d504b2be5
Author: Andrew Jones <drjones@redhat.com>
Date:   Mon Jul 24 15:38:32 2017 +0200

    virtio-net: fix module unloading

already?

> ---
>  drivers/net/virtio_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 143d8a9..c042ffd 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -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);
>  
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] net/virtio-net: reverse unregistering on exit
  2017-08-22 14:59 [PATCH] net/virtio-net: reverse unregistering on exit Pierre Morel
  2017-08-22 14:59 ` Pierre Morel
@ 2017-08-22 18:17 ` Michael S. Tsirkin
  2017-08-23  8:46   ` Pierre Morel
  1 sibling, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2017-08-22 18:17 UTC (permalink / raw)
  To: Pierre Morel; +Cc: virtualization

On Tue, Aug 22, 2017 at 04:59:51PM +0200, Pierre Morel wrote:
> 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 ]------------

Which kernel do you use?


> 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(-)
> 
> -- 
> 2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] net/virtio-net: reverse unregistering on exit
  2017-08-22 18:13   ` Michael S. Tsirkin
@ 2017-08-23  8:28     ` Pierre Morel
  0 siblings, 0 replies; 6+ messages in thread
From: Pierre Morel @ 2017-08-23  8:28 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization

On 22/08/2017 20:13, Michael S. Tsirkin wrote:
> On Tue, Aug 22, 2017 at 04:59:52PM +0200, Pierre Morel wrote:
>> 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.
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
> 
> I'm having a deja vu.
> 
> Wasn't this fixed by
> 
> commit cfa0ebc9d6d6308564f5174ecb655b9d504b2be5
> Author: Andrew Jones <drjones@redhat.com>
> Date:   Mon Jul 24 15:38:32 2017 +0200
> 
>      virtio-net: fix module unloading
> 
> already?

hum... yes, sorry


> 
>> ---
>>   drivers/net/virtio_net.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> index 143d8a9..c042ffd 100644
>> --- a/drivers/net/virtio_net.c
>> +++ b/drivers/net/virtio_net.c
>> @@ -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);
>>   
>> -- 
>> 2.7.4
> 


-- 
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] net/virtio-net: reverse unregistering on exit
  2017-08-22 18:17 ` Michael S. Tsirkin
@ 2017-08-23  8:46   ` Pierre Morel
  0 siblings, 0 replies; 6+ messages in thread
From: Pierre Morel @ 2017-08-23  8:46 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization

On 22/08/2017 20:17, Michael S. Tsirkin wrote:
> On Tue, Aug 22, 2017 at 04:59:51PM +0200, Pierre Morel wrote:
>> 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 ]------------
> 
> 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.

> 
> 
>> 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(-)
>>
>> -- 
>> 2.7.4
> 


-- 
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-23  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-22 14:59 [PATCH] net/virtio-net: reverse unregistering on exit Pierre Morel
2017-08-22 14:59 ` Pierre Morel
2017-08-22 18:13   ` Michael S. Tsirkin
2017-08-23  8:28     ` Pierre Morel
2017-08-22 18:17 ` Michael S. Tsirkin
2017-08-23  8:46   ` Pierre Morel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox