hv_netvsc: fix race in napi poll when rescheduling
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 2 Mar 2018 21:49:05 +0000 (13:49 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Mar 2018 03:18:20 +0000 (22:18 -0500)
There is a race between napi_reschedule and re-enabling interrupts
which could lead to missed host interrrupts.  This occurs when
interrupts are re-enabled (hv_end_read) and vmbus irq callback
(netvsc_channel_cb) has already scheduled NAPI.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/hyperv/netvsc.c

index ff97a85b2e9d73625c0cffbcbdd6f3c813228f1a..4237cedc4f0851d135c68d6251ca7d941b741dc2 100644 (file)
@@ -1207,9 +1207,10 @@ int netvsc_poll(struct napi_struct *napi, int budget)
        if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
            work_done < budget &&
            napi_complete_done(napi, work_done) &&
-           hv_end_read(&channel->inbound)) {
+           hv_end_read(&channel->inbound) &&
+           napi_schedule_prep(napi)) {
                hv_begin_read(&channel->inbound);
-               napi_reschedule(napi);
+               __napi_schedule(napi);
        }
 
        /* Driver may overshoot since multiple packets per descriptor */