From: Matt Mackall <mpm@selenic.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, Jeff Moyer <jmoyer@redhat.com>
Subject: [PATCH 5/5] netpoll: fix up trapped logic
Date: Thu, 26 Aug 2004 15:02:52 -0500 [thread overview]
Message-ID: <20040826200252.GC31237@waste.org> (raw)
From: Jeff Moyer <jmoyer@redhat.com>
This patch contains the updates necessary to fix the hangs in netconsole.
This includes the changing of trapped to an atomic_t, and the addition of a
netpoll_poll_lock. It also turns dev->netpoll_rx into a bitfield which is
used to keep from running the networking code from the netpoll_poll call
path.
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Matt Mackall <mpm@selenic.com>
--- linux-2.6.7/net/core/netpoll.c.locking 2004-08-16 14:43:52.565309376 -0400
+++ linux-2.6.7/net/core/netpoll.c 2004-08-16 15:06:29.270058904 -0400
@@ -36,7 +36,11 @@ static struct sk_buff *skbs;
static spinlock_t rx_list_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(rx_list);
-static int trapped;
+static atomic_t trapped;
+spinlock_t netpoll_poll_lock = SPIN_LOCK_UNLOCKED;
+
+#define NETPOLL_RX_ENABLED 1
+#define NETPOLL_RX_DROP 2
#define MAX_SKB_SIZE \
(MAX_UDP_CHUNK + sizeof(struct udphdr) + \
@@ -68,6 +72,7 @@ void netpoll_poll(struct netpoll *np)
* timeouts. Thus, we set our budget to a more reasonable value.
*/
int budget = 16;
+ unsigned long flags;
if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
return;
@@ -76,9 +81,19 @@ void netpoll_poll(struct netpoll *np)
np->dev->poll_controller(np->dev);
/* If scheduling is stopped, tickle NAPI bits */
- if(trapped && np->dev->poll &&
- test_bit(__LINK_STATE_RX_SCHED, &np->dev->state))
+ spin_lock_irqsave(&netpoll_poll_lock, flags);
+ if (np->dev->poll &&
+ test_bit(__LINK_STATE_RX_SCHED, &np->dev->state)) {
+ np->dev->netpoll_rx |= NETPOLL_RX_DROP;
+ atomic_inc(&trapped);
+
np->dev->poll(np->dev, &budget);
+
+ atomic_dec(&trapped);
+ np->dev->netpoll_rx &= ~NETPOLL_RX_DROP;
+ }
+ spin_unlock_irqrestore(&netpoll_poll_lock, flags);
+
zap_completion_queue();
}
@@ -355,7 +370,8 @@ int netpoll_rx(struct sk_buff *skb)
goto out;
/* check if netpoll clients need ARP */
- if (skb->protocol == __constant_htons(ETH_P_ARP) && trapped) {
+ if (skb->protocol == __constant_htons(ETH_P_ARP) &&
+ atomic_read(&trapped)) {
arp_reply(skb);
return 1;
}
@@ -418,7 +434,7 @@ int netpoll_rx(struct sk_buff *skb)
spin_unlock_irqrestore(&rx_list_lock, flags);
out:
- return trapped;
+ return atomic_read(&trapped);
}
int netpoll_parse_options(struct netpoll *np, char *opt)
@@ -609,7 +625,7 @@ int netpoll_setup(struct netpoll *np)
if(np->rx_hook) {
unsigned long flags;
- np->dev->netpoll_rx = 1;
+ np->dev->netpoll_rx = NETPOLL_RX_ENABLED;
spin_lock_irqsave(&rx_list_lock, flags);
list_add(&np->rx_list, &rx_list);
@@ -639,12 +655,15 @@ void netpoll_cleanup(struct netpoll *np)
int netpoll_trap(void)
{
- return trapped;
+ return atomic_read(&trapped);
}
void netpoll_set_trap(int trap)
{
- trapped = trap;
+ if (trap)
+ atomic_inc(&trapped);
+ else
+ atomic_dec(&trapped);
}
EXPORT_SYMBOL(netpoll_set_trap);
--
Mathematics is the supreme nostalgia of our time.
reply other threads:[~2004-08-26 20:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040826200252.GC31237@waste.org \
--to=mpm@selenic.com \
--cc=akpm@osdl.org \
--cc=jmoyer@redhat.com \
--cc=linux-kernel@vger.kernel.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