public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Andrew Morton <akpm@osdl.org>
Cc: stern@rowland.harvard.edu, david-b@pacbell.net,
	viro@math.psu.edu, maneesh@in.ibm.com,
	linux-usb-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: Unregistering interfaces
Date: Mon, 29 Mar 2004 15:16:04 -0800	[thread overview]
Message-ID: <20040329231604.GA29494@kroah.com> (raw)
In-Reply-To: <20040329132551.23e12144.akpm@osdl.org>

On Mon, Mar 29, 2004 at 01:25:51PM -0800, Andrew Morton wrote:
> Greg KH <greg@kroah.com> wrote:
> >
> > On Sun, Mar 28, 2004 at 12:38:57PM -0800, Andrew Morton wrote:
> > > Alan Stern <stern@rowland.harvard.edu> wrote:
> > > >
> > > >  However, a very noticeable and IMO unacceptable delay occurs when there's
> > > >  a reference to a kobject caused by a negative dentry that won't get
> > > >  recycled until the system decides it's good and ready.  That's the real
> > > >  problem I wanted to call to people's attention.
> > > 
> > > Have you verified that this actually happens?
> > 
> > Yes, I've verified this, and it looks like Maneesh also agrees with
> > this.
> > 
> > > If so, what are its effects?  rmmod hangs for half an hour?  Cannot reload
> > > the module?
> > 
> > Well, before the patch that I submitted for the USB core, we would hang
> > waiting for the release function to return as there was still a
> > reference to the kobject pending.
> > 
> > For other subsystems (and USB), this might cause nasty oopses when the
> > kobject is finally released and yet the module has been unloaded already
> > (as the owner of the reference did not cause the module reference count
> > to increment.)  This is bad.
> > 
> 
> The module should remain in memory, "unhashed", until the final kobject
> reference falls to zero.  Destruction of that kobject causes the refcount
> on the module to fall to zero which causes the entire module to be
> released.
> 
> (hmm, the existence of a kobject doesn't appear to contribute to its
> module's refcount.  Why not?)

It does, if a file for that kobject is opened.  In this case, there was
no file opened, so the module refcount isn't incremented.

> But the module system is that smart, so what we do instead is to block
> rmmod until the module refcount falls to zero, and rmmod then does the
> final destruction.  We could have punted the module destruction up to some
> reaper thread but for some reason did not do so.

Well, as the module refcount was never incremented, it does not do this.
I just verified this (accidentally) by removing my lp modules and then
doing a bk pull.  kswapd forced the stale dentry out, which decremented
the kobject reference count, which then tried to call the release
function in the (now gone) lp module.  My machine then spit up a lovely
oops, and was reduced to a unusable sludge as there was no more kswapd
running :(

> So as far as I can tell, the only problem we have is that rmmod will hang
> around until memory pressure, yes?

Nope, oopses will happen.  You can verify this yourself by doing much of
what I just did.

This needs to get fixed, as it's not just a USB issue (so I've added
lkml on the cc list.)

> Maybe a shrink_dcache_parent(dentry) on entry to simple_rmdir() would
> suffice?

Will that get rid of the references properly nwhen we remove the
kobject?

thanks,

greg k-h

       reply	other threads:[~2004-03-29 23:17 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040328063711.GA6387@kroah.com>
     [not found] ` <Pine.LNX.4.44L0.0403281057100.17150-100000@netrider.rowland.org>
     [not found]   ` <20040328123857.55f04527.akpm@osdl.org>
     [not found]     ` <20040329210219.GA16735@kroah.com>
     [not found]       ` <20040329132551.23e12144.akpm@osdl.org>
2004-03-29 23:16         ` Greg KH [this message]
2004-03-29 23:31           ` Unregistering interfaces Andrew Morton
2004-03-30  0:01             ` Greg KH
2004-03-30  7:38               ` Maneesh Soni
2004-03-30 15:38               ` Alan Stern
2004-03-30  5:51             ` Maneesh Soni
2004-03-30 23:01               ` Greg KH
2004-03-30 23:16                 ` Andrew Morton
2004-03-30 23:30                   ` Greg KH
2004-03-30 23:57                     ` Greg KH
2004-03-30 23:56                   ` Alan Stern
2004-03-31  0:08                     ` David Brownell
2004-03-31  0:34                       ` Greg KH
2004-03-31 15:32                       ` Alan Stern
2004-03-31  0:33                     ` Greg KH
2004-03-31 15:54                       ` Alan Stern
2004-04-01  7:24                         ` Greg KH
2004-03-30 23:55                 ` [PATCH] back out sysfs reference count change Greg KH
2004-03-31  2:11                   ` [linux-usb-devel] " Benjamin Herrenschmidt
2004-03-31  2:19                     ` Andrew Morton
2004-03-31  9:26                       ` Maneesh Soni
2004-03-31 15:11                         ` Alan Stern
2004-04-01  5:17                           ` Maneesh Soni
2004-04-01  7:15                             ` Greg KH
2004-04-01 14:56                             ` Alan Stern
2004-04-02  4:38                               ` Maneesh Soni
2004-04-02 21:41                                 ` Alan Stern
2004-04-06 10:13                                   ` Maneesh Soni
2004-04-06 17:03                                     ` Alan Stern
2004-04-14 13:20                                     ` Maneesh Soni
2004-04-15 21:36                                       ` Greg KH
2004-04-15 22:10                                         ` Andrew Morton
2004-04-16  8:42                                           ` Maneesh Soni
2004-03-31 22:18                     ` Greg KH
2004-04-01  1:56                       ` Benjamin Herrenschmidt
2004-04-01  3:48                         ` Alan Stern
2004-04-01  6:55                         ` Greg KH
2004-04-01  7:13                           ` Benjamin Herrenschmidt

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=20040329231604.GA29494@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@osdl.org \
    --cc=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=maneesh@in.ibm.com \
    --cc=stern@rowland.harvard.edu \
    --cc=viro@math.psu.edu \
    /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