netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen-netback: fix race between napi_complete() and interrupt handler
@ 2014-03-25 14:08 David Vrabel
  2014-03-25 14:41 ` Zoltan Kiss
  2014-03-25 14:50 ` [PATCH] xen-netback: fix race between napi_complete() and interrupt handler Wei Liu
  0 siblings, 2 replies; 7+ messages in thread
From: David Vrabel @ 2014-03-25 14:08 UTC (permalink / raw)
  To: netdev; +Cc: xen-devel, Ian Campbell, Wei Liu, David Vrabel

When the NAPI budget was not all used, xenvif_poll() would call
napi_complete() /after/ enabling the interrupt.  This resulted in a
race between the napi_complete() and the napi_schedule() in the
interrupt handler.  The use of local_irq_save/restore() avoided by
race iff the handler is running on the same CPU but not if it was
running on a different CPU.

Fix this properly by calling napi_complete() before reenabling
interrupts (in the xenvif_check_rx_xenvif() call).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
 drivers/net/xen-netback/interface.c |   28 ++--------------------------
 1 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 7669d49..ee322d9 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -65,32 +65,8 @@ static int xenvif_poll(struct napi_struct *napi, int budget)
 	work_done = xenvif_tx_action(vif, budget);
 
 	if (work_done < budget) {
-		int more_to_do = 0;
-		unsigned long flags;
-
-		/* It is necessary to disable IRQ before calling
-		 * RING_HAS_UNCONSUMED_REQUESTS. Otherwise we might
-		 * lose event from the frontend.
-		 *
-		 * Consider:
-		 *   RING_HAS_UNCONSUMED_REQUESTS
-		 *   <frontend generates event to trigger napi_schedule>
-		 *   __napi_complete
-		 *
-		 * This handler is still in scheduled state so the
-		 * event has no effect at all. After __napi_complete
-		 * this handler is descheduled and cannot get
-		 * scheduled again. We lose event in this case and the ring
-		 * will be completely stalled.
-		 */
-
-		local_irq_save(flags);
-
-		RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, more_to_do);
-		if (!more_to_do)
-			__napi_complete(napi);
-
-		local_irq_restore(flags);
+		napi_complete(napi);
+		xenvif_check_rx_xenvif(vif);
 	}
 
 	return work_done;
-- 
1.7.2.5

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

end of thread, other threads:[~2014-05-15 17:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 14:08 [PATCH] xen-netback: fix race between napi_complete() and interrupt handler David Vrabel
2014-03-25 14:41 ` Zoltan Kiss
2014-05-15 16:26   ` interrupt moving and NAPI scheduling Zoltan Kiss
2014-05-15 17:33     ` Eric Dumazet
2014-03-25 14:50 ` [PATCH] xen-netback: fix race between napi_complete() and interrupt handler Wei Liu
2014-03-25 15:08   ` David Vrabel
2014-03-26 20:33   ` 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).