mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: mpm@selenic.com
Cc: linux-kernel@vger.kernel.org
Subject: [patch] allow netpoll_poll to be called recursively
Date: Mon, 16 Aug 2004 18:27:44 -0400	[thread overview]
Message-ID: <16673.13536.765055.152488@segfault.boston.redhat.com> (raw)

Hi, Matt,

This should fix the recursive netpoll_poll deadlock that can happen with
the newly introduced netpoll_poll_lock.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

--- linux-2.6.7/net/core/netpoll.c.getcpu	2004-08-16 15:50:47.275980584 -0400
+++ linux-2.6.7/net/core/netpoll.c	2004-08-16 15:46:53.328546000 -0400
@@ -72,7 +72,9 @@ void netpoll_poll(struct netpoll *np)
 	 * timeouts.  Thus, we set our budget to a more reasonable value.
 	 */
 	int budget = 16;
+	static int poll_owner = -1;
 	unsigned long flags;
+	int netpoll_rx_flag = NETPOLL_RX_DROP;
 
 	if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
 		return;
@@ -81,17 +83,27 @@ void netpoll_poll(struct netpoll *np)
 	np->dev->poll_controller(np->dev);
 
 	/* If scheduling is stopped, tickle NAPI bits */
-	spin_lock_irqsave(&netpoll_poll_lock, flags);
+	local_irq_save(flags);
+	if (!spin_trylock(&netpoll_poll_lock)) {
+		/* allow recursive calls on this cpu */
+		if (smp_processor_id() != poll_owner)
+			spin_lock(&netpoll_poll_lock);
+		else
+			netpoll_rx_flag = 0;
+	}
+	poll_owner = smp_processor_id();
+
 	if (np->dev->poll &&
 	    test_bit(__LINK_STATE_RX_SCHED, &np->dev->state)) {
-		np->dev->netpoll_rx |= NETPOLL_RX_DROP;
+		np->dev->netpoll_rx |= netpoll_rx_flag;
 		atomic_inc(&trapped);
 
 		np->dev->poll(np->dev, &budget);
 
 		atomic_dec(&trapped);
-		np->dev->netpoll_rx &= ~NETPOLL_RX_DROP;
+		np->dev->netpoll_rx &= ~netpoll_rx_flag;
 	}
+	poll_owner = -1;
 	spin_unlock_irqrestore(&netpoll_poll_lock, flags);
 
 	zap_completion_queue();

             reply	other threads:[~2004-08-16 22:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-16 22:27 Jeff Moyer [this message]
2004-08-26  2:02 ` Matt Mackall

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=16673.13536.765055.152488@segfault.boston.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    /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

all inboxes | Powered by JetHome®