Skip to content

Commit fdaa767

Browse files
Toshiaki Makitadavem330
authored andcommitted
virtio_net: Disable interrupts if napi_complete_done rescheduled napi
Since commit 39e6c82 ("net: solve a NAPI race") napi has been able to be rescheduled within napi_complete_done() even in non-busypoll case, but virtnet_poll() always enabled interrupts before complete, and when napi was rescheduled within napi_complete_done() it did not disable interrupts. This caused more interrupts when event idx is disabled. According to commit cbdadbb ("virtio_net: fix race in RX VQ processing") we cannot place virtqueue_enable_cb_prepare() after NAPI_STATE_SCHED is cleared, so disable interrupts again if napi_complete_done() returned false. Tested with vhost-user of OVS 2.7 on host, which does not have the event idx feature. * Before patch: $ netperf -t UDP_STREAM -H 192.168.150.253 -l 60 -- -m 1472 MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.150.253 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 1472 60.00 32763206 0 6430.32 212992 60.00 23384299 4589.56 Interrupts on guest: 9872369 Packets/interrupt: 2.37 * After patch $ netperf -t UDP_STREAM -H 192.168.150.253 -l 60 -- -m 1472 MIGRATED UDP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.150.253 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 1472 60.00 32794646 0 6436.49 212992 60.00 32793501 6436.27 Interrupts on guest: 4941299 Packets/interrupt: 6.64 Signed-off-by: Toshiaki Makita <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 62cd277 commit fdaa767

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/virtio_net.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@ static void virtqueue_napi_complete(struct napi_struct *napi,
261261
int opaque;
262262

263263
opaque = virtqueue_enable_cb_prepare(vq);
264-
if (napi_complete_done(napi, processed) &&
265-
unlikely(virtqueue_poll(vq, opaque)))
266-
virtqueue_napi_schedule(napi, vq);
264+
if (napi_complete_done(napi, processed)) {
265+
if (unlikely(virtqueue_poll(vq, opaque)))
266+
virtqueue_napi_schedule(napi, vq);
267+
} else {
268+
virtqueue_disable_cb(vq);
269+
}
267270
}
268271

269272
static void skb_xmit_done(struct virtqueue *vq)

0 commit comments

Comments
 (0)