netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin Leroy <colin@colino.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: mpm@selenic.com, akpm@osdl.org, netdev@oss.sgi.com
Subject: Re: [PATCH] Prevent netpoll hanging when link is down
Date: Thu, 7 Oct 2004 16:05:32 +0200	[thread overview]
Message-ID: <20041007160532.60c3f26b@pirandello> (raw)
In-Reply-To: <20041006234912.66bfbdcc.davem@davemloft.net>

On 06 Oct 2004 at 23h10, David S. Miller wrote:

Hi again, 

> Folks debugging this should verify that gp->hw_running is non-zero
> when the problematic case runs.

I looked a bit more at the code and found out a possible problem.
However it doesn't fix the hang, so either it's not what I found, or
there's something else.

First, my newbie question: is it possible to deadlock a spinlock on a
Uniprocessor kernel ? For example, there's something I find suspect in
netpoll/sungem interaction:

it starts in netpoll_send_skb(), where xmit_lock is acquired; then,
gem_start_xmit() is called. In gem_start_xmit(), if the TX ring is full,
we return 1, but previously log the error via printk(). 
In this condition, isn't netpoll_send_skb() called again (via the whole
console stuff), where it retries to get the lock on xmit_lock? Could
that cause a deadlock?

Also, at the end of netpoll_send_skb() is a check for the return status
of hard_start_xmit. If I understand correctly, hard_start_xmit functions
return 0 for success, -1 for "busy please retry" and 1 for "hard error".
Shouldn't netpoll free the skb and forget about it in case status is 1
(instead of goto'ing repeat) ?

Based on this, I've a new patch that I'm attaching. As said it doesn't
fix the problem, but if my I understood is valid, it may still be
useful ? 

Any insight will be greatly appreciated :)


Patch following:
--- a/net/core/netpoll.c	2004-10-05 21:09:49.000000000 +0200
+++ b/net/core/netpoll.c	2004-10-07 14:11:00.000000000 +0200
@@ -188,7 +188,10 @@
 		return;
 	}
 
-	spin_lock(&np->dev->xmit_lock);
+	if (!spin_trylock(&np->dev->xmit_lock)) {
+		/* looks like np->dev->hard_start_xmit did a printk */
+		goto bail_free;
+	}
 	np->dev->xmit_lock_owner = smp_processor_id();
 
 	/*
@@ -204,13 +207,18 @@
 	}
 
 	status = np->dev->hard_start_xmit(skb, np->dev);
+
 	np->dev->xmit_lock_owner = -1;
 	spin_unlock(&np->dev->xmit_lock);
 
-	/* transmit busy */
-	if(status) {
+	if(status == -1) {
+		/* transmit busy */
 		netpoll_poll(np);
 		goto repeat;
+	} else if (status == 1) {
+		/* hard error, drop this skb */
+bail_free:
+		__kfree_skb(skb);
 	}
 }
 

  parent reply	other threads:[~2004-10-07 14:05 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20041006232544.53615761@jack.colino.net>
2004-10-06 21:43 ` [PATCH] Prevent netpoll hanging when link is down Matt Mackall
2004-10-07  5:53   ` Colin Leroy
2004-10-07  6:49     ` David S. Miller
2004-10-07  8:33       ` Colin Leroy
2004-10-07  8:45         ` Colin Leroy
2004-10-07 14:05       ` Colin Leroy [this message]
2004-10-07 18:28         ` David S. Miller
2004-10-07 18:41           ` Matt Mackall
2004-10-07 20:00             ` Colin Leroy
2004-10-07 18:43           ` Andi Kleen
2004-10-07 20:44           ` Colin Leroy
2004-10-07 21:45             ` Andi Kleen
2004-10-07 21:50               ` Matt Mackall
2004-10-07 22:07                 ` David S. Miller
2004-10-07 23:43                   ` Matt Mackall
2004-10-07 23:50                     ` Andi Kleen
2004-10-08  6:46                       ` Colin Leroy
2004-10-08 21:53                         ` Matt Mackall
2004-10-08  7:06               ` Colin Leroy
2004-10-08 22:00                 ` Matt Mackall
2004-10-08 22:18                   ` Andrew Morton
2004-10-11  3:59                     ` David S. Miller
2004-10-11 15:40                       ` Andi Kleen
2004-10-11 16:22                         ` Matt Mackall
2004-10-11 16:32                           ` Andi Kleen
2004-10-11 16:36                             ` Matt Mackall
2004-10-11 16:43                               ` Andi Kleen
2004-10-11 16:58                                 ` Matt Mackall
2004-10-11 17:41                                   ` Andi Kleen
2004-10-11 20:45                                   ` Colin Leroy
     [not found]                                     ` <5cac192f0410181443303379e2@mail.gmail.com>
     [not found]                                       ` <5cac192f041018145824acce5a@mail.gmail.com>
     [not found]                                         ` <20041020161119.6e30efe5@pirandello>
     [not found]                                           ` <5cac192f0410200848179ccc81@mail.gmail.com>
2004-10-21 16:36                                             ` Colin Leroy
2004-10-24 15:22                                               ` Eric Lemoine
2004-10-07 22:08             ` David S. Miller
2004-10-08  6:54               ` Colin Leroy

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=20041007160532.60c3f26b@pirandello \
    --to=colin@colino.net \
    --cc=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=mpm@selenic.com \
    --cc=netdev@oss.sgi.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;
as well as URLs for NNTP newsgroup(s).