Skip to content

Commit f1776da

Browse files
rustyrusselldavem330
authored andcommitted
virtio_net: use non-reentrant workqueue.
Michael S. Tsirkin also noticed that we could run the refill work multiple CPUs: if we kick off a refill on one CPU and then on another, they would both manipulate the queue at the same time (they use napi_disable to avoid racing against the receive handler itself). Tejun points out that this is what the WQ_NON_REENTRANT flag is for, and that there is a convenient system kthread we can use. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b2baed6 commit f1776da

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/virtio_net.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ static void refill_work(struct work_struct *work)
508508
/* In theory, this can happen: if we don't get any buffers in
509509
* we will *never* try to fill again. */
510510
if (still_empty)
511-
schedule_delayed_work(&vi->refill, HZ/2);
511+
queue_delayed_work(system_nrt_wq, &vi->refill, HZ/2);
512512
}
513513

514514
static int virtnet_poll(struct napi_struct *napi, int budget)
@@ -527,7 +527,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
527527

528528
if (vi->num < vi->max / 2) {
529529
if (!try_fill_recv(vi, GFP_ATOMIC))
530-
schedule_delayed_work(&vi->refill, 0);
530+
queue_delayed_work(system_nrt_wq, &vi->refill, 0);
531531
}
532532

533533
/* Out of packets? */
@@ -729,7 +729,7 @@ static int virtnet_open(struct net_device *dev)
729729

730730
/* Make sure we have some buffers: if oom use wq. */
731731
if (!try_fill_recv(vi, GFP_KERNEL))
732-
schedule_delayed_work(&vi->refill, 0);
732+
queue_delayed_work(system_nrt_wq, &vi->refill, 0);
733733

734734
virtnet_napi_enable(vi);
735735
return 0;

0 commit comments

Comments
 (0)