public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Ingo Molnar <mingo@elte.hu>, Alan <alan@lxorguk.ukuu.org.uk>,
	Len Brown <lenb@kernel.org>,
	linux-kernel@vger.kernel.org, ak@suse.de,
	Linus Torvalds <torvalds@osdl.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [patch] net: dev_watchdog() locking fix
Date: Fri, 8 Dec 2006 15:19:02 -0800	[thread overview]
Message-ID: <20061208151902.4c8bb012.akpm@osdl.org> (raw)
In-Reply-To: <20061207210657.GA23229@gondor.apana.org.au>

On Fri, 8 Dec 2006 08:06:57 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> On Thu, Dec 07, 2006 at 09:55:22PM +0100, Ingo Molnar wrote:
> > 
> > fallout of the recent big networking merge i guess. Tested fix below. 
> > David, Herbert, do you agree with it, or is it a false positive?
> 
> I agree that this is a bug, but the fix is in the wrong spot.  The
> dev_watchdog function already runs in softirq context so it doesn't
> need to disable BH.
> 
> You can almost be guaranteed that if netpoll is involved in a bug
> then it should be fixed :)
> 
> In this case, it's taking the tx lock in process context which is
> not allowed.  So it should disable BH before taking the tx lock.
> 

Like this?

	/* don't get messages out of order, and no recursion */
	if (skb_queue_len(&npinfo->txq) == 0 &&
		    npinfo->poll_owner != smp_processor_id()) {
		local_bh_disable();	/* Where's netif_tx_trylock_bh()? */
		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;

				/* tickle device maybe there is some cleanup */
				netpoll_poll(np);

				udelay(USEC_PER_POLL);
			}
			netif_tx_unlock(dev);
		}
		local_bh_enable();
	}


--- a/net/core/netpoll.c~netpoll-locking-fix
+++ a/net/core/netpoll.c
@@ -242,22 +242,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_bh_disable();	/* Where's netif_tx_trylock_bh()? */
+		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_bh_enable();
 	}
 
 	if (status != NETDEV_TX_OK) {
_


  reply	other threads:[~2006-12-08 23:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-06 22:30 [patch] ACPI, i686, x86_64: fix laptop bootup hang in init_acpi() Ingo Molnar
2006-12-06 23:57 ` Len Brown
2006-12-07 11:08   ` Ingo Molnar
2006-12-07 12:11   ` [patch] x86_64: do not enable the NMI watchdog by default Ingo Molnar
2006-12-07 12:30     ` Alan
2006-12-07 20:38       ` Andrew Morton
2006-12-07 20:47         ` Ingo Molnar
2006-12-07 20:49           ` Ingo Molnar
2006-12-07 20:55             ` [patch] net: dev_watchdog() locking fix Ingo Molnar
2006-12-07 21:06               ` Herbert Xu
2006-12-08 23:19                 ` Andrew Morton [this message]
2006-12-08 23:59                   ` Herbert Xu
2006-12-09 22:02                     ` David Miller
2006-12-11  7:45                       ` Andrew Morton
2006-12-11  7:51                         ` Herbert Xu
2006-12-11  7:56                           ` Ingo Molnar
2006-12-11 20:09                           ` Andrew Morton
2006-12-07 17:24     ` [patch] x86_64: do not enable the NMI watchdog by default Andi Kleen
2006-12-07  2:28 ` [patch] ACPI, i686, x86_64: fix laptop bootup hang in init_acpi() Sergio Monteiro Basto
2006-12-07  4:47   ` Karsten Wiese
2006-12-07 11:09     ` Ingo Molnar
2006-12-07 11:24       ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061208151902.4c8bb012.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=ak@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox