From: Helge Hafting <helgehaf@aitel.hist.no>
To: Keith Owens <kaos@ocs.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: RE2: [OKS] Module removal
Date: Tue, 02 Jul 2002 10:52:27 +0200 [thread overview]
Message-ID: <3D2169CB.73126A47@aitel.hist.no> (raw)
In-Reply-To: 31042.1025576745@kao2.melbourne.sgi.com
Keith Owens wrote:
>
> On Mon, 1 Jul 2002 22:40:34 -0300,
> Werner Almesberger <wa@almesberger.net> wrote:
> >If I remember right, the main arguments why module removal can
> >race with references were:
> >....
> > - removal happening immediately after module usage count is
> > decremented to zero may unload module before module has
> > executed "return" instruction
> >For the removal-before-return problem, I thought a bit about it
> >on my return flight. It would seem to me that an "atomic"
> >"decrement_module_count_and_return" function would do the trick.
>
> This is just one symptom of the overall problem, which is module code
> that adjusts its use count by executing code that belongs to the
> module. The same problem exists on entry to a module function, the
> module can be removed before MOD_INC_USE_COUNT is reached.
>
> Apart from abandoning module removal, there are only two viable fixes:
>
> 1) Do the reference counting outside the module, before it is entered.
>
> This is why Al Viro added the owner: __THIS_MODULE; line to various
> structures. The problem is that it spreads like a cancer.
How about letting the module handle the reference counting but
with one key difference from today's arrangement:
The _code_ for inc/decrementing is kept outside the modules, in
the permanent part of the kernel. So the module simply
does something like decrement_usecount(&my_use_count)
decrement_usecount will return to the module _if_ the count
didn't reach 0. If it does, it goes straight to whatever
usually happens after the module returns. (I.e. pop the
return address that goes to the module, and return to where
the module were supposed to return.)
The module gets an additional restriction: decrement_usecount
may not return so all cleanup etc. must be done first, so
only a return remains when it is called.
The "unsafe return" after decrementing to 0 is eliminated.
Helge Hafting
next prev parent reply other threads:[~2002-07-02 8:50 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-01 20:21 RE2: [OKS] Module removal Michael Nguyen
2002-07-02 1:40 ` Werner Almesberger
2002-07-02 2:25 ` Keith Owens
2002-07-02 3:11 ` Werner Almesberger
2002-07-02 3:42 ` Keith Owens
2002-07-02 4:11 ` Werner Almesberger
2002-07-02 22:23 ` Alexander Viro
2002-07-09 19:23 ` Russ Lewis
2002-07-02 4:08 ` Brian Gerst
2002-07-02 4:53 ` Keith Owens
2002-07-02 5:43 ` Werner Almesberger
2002-07-02 16:36 ` Werner Almesberger
2002-07-02 16:50 ` Benjamin Herrenschmidt
2002-07-02 18:05 ` Werner Almesberger
2002-07-03 3:50 ` Pavel Machek
2002-07-04 4:11 ` Bill Davidsen
2002-07-04 6:29 ` Werner Almesberger
2002-07-04 6:50 ` Werner Almesberger
2002-07-07 21:09 ` Jamie Lokier
2002-07-07 21:41 ` Oliver Neukum
2002-07-08 0:31 ` Jamie Lokier
2002-07-08 6:42 ` Oliver Neukum
2002-07-08 0:18 ` Bill Davidsen
2002-07-08 0:46 ` Jamie Lokier
2002-07-08 6:22 ` Daniel Phillips
2002-07-08 10:16 ` Bill Davidsen
2002-07-09 0:07 ` Werner Almesberger
2002-07-09 0:27 ` Keith Owens
2002-07-09 3:09 ` Werner Almesberger
2002-07-09 6:25 ` Roman Zippel
2002-07-09 8:59 ` Kai Germaschewski
2002-07-09 11:06 ` Roman Zippel
2002-07-04 12:29 ` Bill Davidsen
2002-07-09 1:50 ` Kevin O'Connor
2002-07-09 2:37 ` Werner Almesberger
2002-07-02 23:35 ` Alexander Viro
2002-07-02 22:41 ` RE2: " Alexander Viro
2002-07-02 8:52 ` Helge Hafting [this message]
2002-07-02 16:22 ` Werner Almesberger
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=3D2169CB.73126A47@aitel.hist.no \
--to=helgehaf@aitel.hist.no \
--cc=kaos@ocs.com.au \
--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