From: Ingo Molnar <mingo@elte.hu>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
"David S. Miller" <davem@davemloft.net>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: [patch] netpoll: fix netpoll lockups
Date: Tue, 12 Dec 2006 11:16:56 +0100 [thread overview]
Message-ID: <20061212101656.GA5064@elte.hu> (raw)
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) {
next reply other threads:[~2006-12-12 10:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-12 10:16 Ingo Molnar [this message]
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
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=20061212101656.GA5064@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.