linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] netpoll: fix netpoll lockups
@ 2006-12-12 10:16 Ingo Molnar
  2006-12-12 12:49 ` [patch] net, 8139too.c: fix netpoll deadlock Ingo Molnar
  2006-12-12 16:13 ` [patch] netpoll: fix netpoll lockups Linus Torvalds
  0 siblings, 2 replies; 10+ messages in thread
From: Ingo Molnar @ 2006-12-12 10:16 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, David S. Miller, Thomas Gleixner, linux-kernel

Subject: [patch] netpoll: fix netpoll lockups
From: Ingo Molnar <mingo@elte.hu>

current -git doesnt boot on my laptop due to the following netpoll 
breakages:

 - unlock the tx lock in the else branch too ...
 - use irq-safe locking instead of bh-safe locking, netpoll is
   often called from irq context.

with this patch -git boots fine with lockdep enabled and there are no 
locking complaints and everything works fine. (The netpoll_send_skb() 
portion of this patch was based on Andrew's bh-locking based netpoll 
patch in -mm.)

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 net/core/netpoll.c |   39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

Index: linux-hres-timers.q/net/core/netpoll.c
===================================================================
--- linux-hres-timers.q.orig/net/core/netpoll.c
+++ linux-hres-timers.q/net/core/netpoll.c
@@ -55,6 +55,7 @@ static void queue_process(struct work_st
 	struct netpoll_info *npinfo =
 		container_of(work, struct netpoll_info, tx_work.work);
 	struct sk_buff *skb;
+	unsigned long flags;
 
 	while ((skb = skb_dequeue(&npinfo->txq))) {
 		struct net_device *dev = skb->dev;
@@ -64,15 +65,19 @@ static void queue_process(struct work_st
 			continue;
 		}
 
-		netif_tx_lock_bh(dev);
+		local_irq_save(flags);
+		netif_tx_lock(dev);
 		if (netif_queue_stopped(dev) ||
 		    dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) {
 			skb_queue_head(&npinfo->txq, skb);
-			netif_tx_unlock_bh(dev);
+			netif_tx_unlock(dev);
+			local_irq_restore(flags);
 
 			schedule_delayed_work(&npinfo->tx_work, HZ/10);
 			return;
 		}
+		netif_tx_unlock(dev);
+		local_irq_restore(flags);
 	}
 }
 
@@ -231,7 +236,7 @@ repeat:
 static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
 {
 	int status = NETDEV_TX_BUSY;
-	unsigned long tries;
+	unsigned long tries, flags;
  	struct net_device *dev = np->dev;
  	struct netpoll_info *npinfo = np->dev->npinfo;
 
@@ -242,22 +247,26 @@ static void netpoll_send_skb(struct netp
 
 	/* don't get messages out of order, and no recursion */
 	if (skb_queue_len(&npinfo->txq) == 0 &&
-	    npinfo->poll_owner != smp_processor_id() &&
-	    netif_tx_trylock(dev)) {
-		/* try until next clock tick */
-		for (tries = jiffies_to_usecs(1)/USEC_PER_POLL; tries > 0; --tries) {
-			if (!netif_queue_stopped(dev))
-				status = dev->hard_start_xmit(skb, dev);
+		    npinfo->poll_owner != smp_processor_id()) {
+		local_irq_save(flags);	/* Where's netif_tx_trylock_irqsave()? */
+		if (netif_tx_trylock(dev)) {
+			/* try until next clock tick */
+			for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
+					tries > 0; --tries) {
+				if (!netif_queue_stopped(dev))
+					status = dev->hard_start_xmit(skb, dev);
 
-			if (status == NETDEV_TX_OK)
-				break;
+				if (status == NETDEV_TX_OK)
+					break;
 
-			/* tickle device maybe there is some cleanup */
-			netpoll_poll(np);
+				/* tickle device maybe there is some cleanup */
+				netpoll_poll(np);
 
-			udelay(USEC_PER_POLL);
+				udelay(USEC_PER_POLL);
+			}
+			netif_tx_unlock(dev);
 		}
-		netif_tx_unlock(dev);
+		local_irq_restore(flags);
 	}
 
 	if (status != NETDEV_TX_OK) {

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

end of thread, other threads:[~2007-02-16  4:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-12 10:16 [patch] netpoll: fix netpoll lockups Ingo Molnar
2006-12-12 12:49 ` [patch] net, 8139too.c: fix netpoll deadlock Ingo Molnar
2006-12-12 13:28   ` Jeff Garzik
2006-12-12 21:49     ` Francois Romieu
2006-12-13  1:12       ` Ingo Molnar
2007-02-14  2:30         ` Atsushi Nemoto
2007-02-16  4:33           ` Atsushi Nemoto
2006-12-12 16:13 ` [patch] netpoll: fix netpoll lockups Linus Torvalds
2006-12-12 16:20   ` [patch] netpoll: fix netpoll lockup Ingo Molnar
2006-12-12 21:00     ` Herbert Xu

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).