* [PATCH net] virtio-net: fix refill races during restore
@ 2013-12-30 3:34 Jason Wang
2014-01-03 0:23 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jason Wang @ 2013-12-30 3:34 UTC (permalink / raw)
To: rusty, mst, virtualization, netdev, linux-kernel; +Cc: Amit Shah, Eric Dumazet
During restoring, try_fill_recv() was called with neither napi lock nor napi
disabled. This can lead two try_fill_recv() was called in the same time. Fix
this by refilling before trying to enable napi.
Fixes 0741bcb5584f9e2390ae6261573c4de8314999f2
(virtio: net: Add freeze, restore handlers to support S4).
Cc: Amit Shah <amit.shah@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/virtio_net.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d208f86..5d77644 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1797,16 +1797,17 @@ static int virtnet_restore(struct virtio_device *vdev)
if (err)
return err;
- if (netif_running(vi->dev))
+ if (netif_running(vi->dev)) {
+ for (i = 0; i < vi->curr_queue_pairs; i++)
+ if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
+ schedule_delayed_work(&vi->refill, 0);
+
for (i = 0; i < vi->max_queue_pairs; i++)
virtnet_napi_enable(&vi->rq[i]);
+ }
netif_device_attach(vi->dev);
- for (i = 0; i < vi->curr_queue_pairs; i++)
- if (!try_fill_recv(&vi->rq[i], GFP_KERNEL))
- schedule_delayed_work(&vi->refill, 0);
-
mutex_lock(&vi->config_lock);
vi->config_enable = true;
mutex_unlock(&vi->config_lock);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] virtio-net: fix refill races during restore
2013-12-30 3:34 [PATCH net] virtio-net: fix refill races during restore Jason Wang
@ 2014-01-03 0:23 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-01-03 0:23 UTC (permalink / raw)
To: jasowang
Cc: eric.dumazet, mst, netdev, linux-kernel, virtualization, amit.shah
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 30 Dec 2013 11:34:40 +0800
> During restoring, try_fill_recv() was called with neither napi lock nor napi
> disabled. This can lead two try_fill_recv() was called in the same time. Fix
> this by refilling before trying to enable napi.
>
> Fixes 0741bcb5584f9e2390ae6261573c4de8314999f2
> (virtio: net: Add freeze, restore handlers to support S4).
>
> Cc: Amit Shah <amit.shah@redhat.com>
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-03 0:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-30 3:34 [PATCH net] virtio-net: fix refill races during restore Jason Wang
2014-01-03 0:23 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).