mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maksim (Max) Krasnyanskiy" <maxk@qualcomm.com>
To: Jacek Konieczny <jajcus@bnet.pl>
Cc: davem@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: "new style" netdevice allocation patch for TUN driver (2.4.18 kernel)
Date: Tue, 06 Aug 2002 10:07:49 -0700	[thread overview]
Message-ID: <5.1.0.14.2.20020806094253.09734790@mail1.qualcomm.com> (raw)
In-Reply-To: <20020803140858.GA5314@nic.nigdzie>


>On Fri, Aug 02, 2002 at 04:54:02PM -0700, Maksim (Max) Krasnyanskiy wrote:
> > You're fixing the wrong problem.
>Probably I am. Alexey Kuznietzov told be the same :-)
>
> >It seems that some subsystem is not  releasing
> > tun device during shutdown/deregistration. (See comment in
> > net/core/dev.c:unregister_netdev).
> > You're not gonna see "waiting for" warning anymore if you change to new
> > style allocation.
>I will not see "waiting for" warning, but I will also be able to control
>all other network devices. Without this "fix" I am not able to shutdown
>network at all. Every "ip" command just hangs forever.
Yeah, this should be fixed. unregister_netdevice() sleeps under rtnl_lock().
Which means that any other activity that needs this lock will be blocked.

Dave, how about this

--- net/core/dev.c.orig Mon Aug  5 21:48:54 2002
+++ net/core/dev.c      Mon Aug  5 21:54:01 2002
@@ -2577,6 +2577,11 @@

          */

+       /* We don't have to hold rtnl semaphore while we're waiting for
+          device to become free.
+        */
+       rtnl_unlock();
+
         now = warning_time = jiffies;
         while (atomic_read(&dev->refcnt) != 1) {
                 if ((jiffies - now) > 1*HZ) {
@@ -2593,6 +2598,10 @@
                         warning_time = jiffies;
                 }
         }
+
+       /* Our caller expects it to be locked */
+       rtnl_lock();
+
         dev_put(dev);
         return 0;
  }

----
We don't have to hold rtnl look while sleeping. Device is already unlinked
from the list so nobody can grab and bump refcount.

> > But you're gonna leak tun devices because destructor is not called unless
> > refcount is zero.
>But it seems it is eventually called. The refcount eventually goes to 0
>(1 in factm - selfreference). Without this patch it never went to 0, as
>system shutdown was stopped "waitnig for...".
It'd be nice to trace what part of the kernel is actually holding refcount.

>I don't have enough time and probably knowledge to write a proper fix
>for the problem, however my patch fixes it well enough for me.
>All this "new style" device allocation would be useless if the kernel
>was bug-free. With this patch it is more bug-proof.
:) No, the point of device destructors is not to hide kernel bugs.

>On protuction system it is sometimes even more important, because kernel
>(or any other big piece of software) will never be bug-free.
That why it's important to trace and fix the subsystem that is holding devices
for a long time after deregistration. I may very well be doing it for a 
good reason
but warning is helpful anyway.
And we should fix sleep in unregister_netdevice() (ie patch above).

Max


  parent reply	other threads:[~2002-08-06 17:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-01 13:35 Jacek Konieczny
2002-08-02 23:54 ` Maksim (Max) Krasnyanskiy
     [not found] ` <20020803140858.GA5314@nic.nigdzie>
2002-08-06 17:07   ` Maksim (Max) Krasnyanskiy [this message]
2002-08-06 17:07     ` David S. Miller
2002-08-06 20:03       ` Maksim (Max) Krasnyanskiy
2002-08-06 17:29     ` Jacek Konieczny
2002-08-07  3:10 Julian Anastasov

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=5.1.0.14.2.20020806094253.09734790@mail1.qualcomm.com \
    --to=maxk@qualcomm.com \
    --cc=davem@redhat.com \
    --cc=jajcus@bnet.pl \
    --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

all inboxes | Powered by JetHome®