netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv1 net] xen-netfront: use napi_complete() correctly to prevent Rx stalling
@ 2014-12-16 18:59 David Vrabel
  2014-12-16 20:22 ` David Miller
  2014-12-20  0:23 ` virtio_net: Fix napi poll list corruption Herbert Xu
  0 siblings, 2 replies; 23+ messages in thread
From: David Vrabel @ 2014-12-16 18:59 UTC (permalink / raw)
  To: netdev
  Cc: David Vrabel, xen-devel, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	Eric Dumazet

After d75b1ade567ffab085e8adbbdacf0092d10cd09c (net: less interrupt
masking in NAPI) the napi instance is removed from the per-cpu list
prior to calling the n->poll(), and is only requeued if all of the
budget was used.  This inadvertently broke netfront because netfront
does not use NAPI correctly.

If netfront had not used all of its budget it would do a final check
for any Rx responses and avoid calling napi_complete() if there were
more responses.  It would still return under budget so it would never
be rescheduled.  The final check would also not re-enable the Rx
interrupt.

Additionally, xenvif_poll() would also 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 both of these by always calling napi_compete() if the budget was
not all used, and then calling napi_schedule() if the final checks
says there's more work.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Cc: Eric Dumazet <edumazet@google.com>
---
 drivers/net/xen-netfront.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 2f0a9ce..22bcb4e 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -977,7 +977,6 @@ static int xennet_poll(struct napi_struct *napi, int budget)
 	struct sk_buff_head rxq;
 	struct sk_buff_head errq;
 	struct sk_buff_head tmpq;
-	unsigned long flags;
 	int err;
 
 	spin_lock(&queue->rx_lock);
@@ -1050,15 +1049,11 @@ err:
 	if (work_done < budget) {
 		int more_to_do = 0;
 
-		napi_gro_flush(napi, false);
-
-		local_irq_save(flags);
+		napi_complete(napi);
 
 		RING_FINAL_CHECK_FOR_RESPONSES(&queue->rx, more_to_do);
-		if (!more_to_do)
-			__napi_complete(napi);
-
-		local_irq_restore(flags);
+		if (more_to_do)
+			napi_schedule(napi);
 	}
 
 	spin_unlock(&queue->rx_lock);
-- 
1.7.10.4

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

end of thread, other threads:[~2014-12-24  4:20 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16 18:59 [PATCHv1 net] xen-netfront: use napi_complete() correctly to prevent Rx stalling David Vrabel
2014-12-16 20:22 ` David Miller
2014-12-20  0:23 ` virtio_net: Fix napi poll list corruption Herbert Xu
2014-12-20  0:36   ` net: Detect drivers that reschedule NAPI and exhaust budget Herbert Xu
2014-12-20  1:34     ` Eric Dumazet
2014-12-20  2:40       ` David Miller
2014-12-20  6:55         ` Herbert Xu
2014-12-20 18:00           ` Eric Dumazet
2014-12-20 20:14             ` [0/4] net: net_rx_action fixes and clean-ups Herbert Xu
2014-12-20 20:16               ` [PATCH 1/4] net: Move napi polling code out of net_rx_action Herbert Xu
2014-12-24  4:20                 ` David Miller
2014-12-20 20:16               ` [PATCH 2/4] net: Detect drivers that reschedule NAPI and exhaust budget Herbert Xu
2014-12-24  4:20                 ` David Miller
2014-12-20 20:16               ` [PATCH 3/4] net: Always poll at least one device in net_rx_action Herbert Xu
2014-12-24  4:20                 ` David Miller
2014-12-20 20:16               ` [PATCH 4/4] net: Rearrange loop " Herbert Xu
2014-12-24  4:20                 ` David Miller
2014-12-22  8:18   ` virtio_net: Fix napi poll list corruption Jason Wang
2014-12-22  9:35     ` caif: " Herbert Xu
2014-12-22 10:02       ` Jason Wang
2014-12-22 21:35       ` David Miller
2014-12-22 16:19   ` virtio_net: " Marcelo Ricardo Leitner
2014-12-22 21:10   ` 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).