From: Rusty Russell <rusty@rustcorp.com.au>
To: Daniel Phillips <phillips@arcor.de>,
Roman Zippel <zippel@linux-m68k.org>
Cc: Jamie Lokier <lk@tantalophile.demon.co.uk>,
Alexander Viro <viro@math.psu.edu>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] Raceless module interface
Date: Fri, 13 Sep 2002 16:51:58 +1000 [thread overview]
Message-ID: <20020913080709.9026B2C054@lists.samba.org> (raw)
In-Reply-To: Your message of "Fri, 13 Sep 2002 04:19:18 +0200." <E17pg3H-0007pb-00@starship>
In message <E17pg3H-0007pb-00@starship> you write:
> On Friday 13 September 2002 03:30, Rusty Russell wrote:
> > In message <Pine.LNX.4.44.0209121520300.28515-100000@serv> you write:
> > > The usecount is optional, the only important question a module must be
> > > able to answer is: Are there any objects/references belonging to the
> > > module? It's a simple yes/no question. If a module can't answer that, it
> > > likely has more problem than just module unloading.
> >
> > Ah, we're assuming you insert synchronize_kernel() between the call
> > to stop and the call to exit?
> >
> > In which case *why* do you check the use count *inside* exit_affs_fs?
> > Why not get exit_module() to do "if (mod->usecount() != 0) return
> > -EBUSY; else mod->exit();"?
>
> Because mod->usecount may be a totally inadequate way of determining
> if a module is busy. How does it work for LSM, for example?
As established previously: unless the hooks do it for you, you keep
track of it yourself before you sleep.
> > There's the other issue of symmetry. If you allocate memory, in
> > start, do you clean it up in stop or exit?
>
> Actually, I'm going to press you on why you think you even need a
> two stage stop. I know you have your reasons, but I doubt any of
> the effects you aim at cannot be achieved with a single stage
> stop/exit. Could you please summarize the argument in favor of the
> two stage stop?
Of course you can simulate a two-stage within a single-stage, of course,
by doing int single_stage(void) { stage_one(); stage_two(); }, so
"need" is a bit strong.
Basically, you can't do stage two until you know noone is using the
module, but you can do stage one at any time. Basically stage 1
ensures that the refcount never *increases* by removing all external
references to the module (ie. deregister, etc). Stage 2 then knows
that if the refcnt is zero, there's no race and it can destroy they
module data structures.
The synchronize_kernel() covers those "I was about to bump the module
count!" races, as long as noone explicitly sleeps before mod_inc, or
after mod_dec.
> > Similarly for other
> > resources: you call mod->exit() every time start fails, so that is
> > supposed to check that mod->start() succeeded?
>
> He does? That's not right. ->start should clean up after itself if
> it fails, like any other good Linux citizen.
>From my reading, yes.
> > Of course, separating start into "init" and "start" allows you to
> > solve the half-initialized problem as well as clarify the rules.
>
> I doubt it gives any new capability at all.
Since I explained what it does for you at the kernel summit, you
obviously aren't listening. If you split registration interfaces into
reserve (can fail) and use (can't fail), then you do:
int my_module_init(void)
{
int ret;
ret = reserve_foo();
if (ret != 0)
return ret;
ret = reserve_bar();
if (ret != 0)
unreserve_foo();
return ret;
}
void my_module_start(void)
{
use_foo();
use_bar();
}
Note the symmetry here with the exit case: noone can actually use the
module until my_module_start is called, so even if the reserve_bar()
fails, we're safe.
> The same with the entrenched separation at the user level between
> create and init module: what does it give you that an error exit
> from a single create/init would not?
That's done for entirely different reasons, as the userspace linker
needs to know the address of the module.
> Sure, I know it's not going to change, but I'd like to know what the
> thinking was, and especially, if there's a non-bogus reason, I'd
> like to know it.
You should probably start playing with my code if you're really
interested.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-09-13 8:02 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-04 18:02 Question about pseudo filesystems Jamie Lokier
2002-09-07 12:00 ` Daniel Phillips
2002-09-07 13:36 ` Alexander Viro
2002-09-07 18:27 ` Jamie Lokier
2002-09-07 19:47 ` Alexander Viro
2002-09-08 2:21 ` Jamie Lokier
2002-09-08 2:43 ` Alexander Viro
2002-09-15 1:41 ` Moving a mount point (was Re: Question about pseudo filesystems) Rob Landley
2002-09-08 16:00 ` Question about pseudo filesystems Daniel Phillips
2002-09-09 19:48 ` Jamie Lokier
2002-09-09 20:06 ` Daniel Phillips
2002-09-10 0:44 ` Jamie Lokier
2002-09-10 1:40 ` Daniel Phillips
2002-09-10 1:56 ` Jamie Lokier
2002-09-10 2:53 ` Daniel Phillips
2002-09-10 3:26 ` Jamie Lokier
2002-09-10 3:47 ` Daniel Phillips
2002-09-10 9:15 ` Daniel Phillips
2002-09-10 10:17 ` Roman Zippel
2002-09-11 18:35 ` [RFC] Raceless module interface Daniel Phillips
2002-09-11 18:53 ` Oliver Neukum
2002-09-11 19:20 ` Daniel Phillips
2002-09-11 20:29 ` Oliver Neukum
2002-09-11 21:15 ` Daniel Phillips
2002-09-11 21:26 ` Jamie Lokier
2002-09-11 21:47 ` Daniel Phillips
2002-09-12 1:42 ` Rusty Russell
2002-09-12 2:09 ` Jamie Lokier
2002-09-12 3:13 ` Rusty Russell
2002-09-12 3:47 ` Daniel Phillips
2002-09-12 3:53 ` Alexander Viro
2002-09-12 4:11 ` Daniel Phillips
2002-09-12 4:40 ` Rusty Russell
2002-09-12 5:27 ` Daniel Phillips
2002-09-12 14:46 ` Gerhard Mack
2002-09-13 0:39 ` Rusty Russell
2002-09-13 2:23 ` Daniel Phillips
2002-09-12 5:35 ` Rusty Russell
2002-09-12 4:52 ` Rusty Russell
2002-09-12 5:58 ` Daniel Phillips
2002-09-12 7:00 ` Rusty Russell
2002-09-13 8:18 ` Helge Hafting
2002-09-12 3:32 ` Daniel Phillips
2002-09-12 1:31 ` Rusty Russell
2002-09-12 9:10 ` Oliver Neukum
2002-09-12 11:27 ` Roman Zippel
2002-09-12 13:03 ` Rusty Russell
2002-09-12 13:44 ` Roman Zippel
2002-09-13 1:30 ` Rusty Russell
2002-09-13 2:19 ` Daniel Phillips
2002-09-13 6:51 ` Rusty Russell [this message]
2002-09-13 13:34 ` Daniel Phillips
2002-09-13 13:52 ` Thunder from the hill
2002-09-13 14:09 ` Daniel Phillips
2002-09-13 14:33 ` Thunder from the hill
2002-09-13 14:44 ` Daniel Phillips
2002-09-13 14:59 ` Thunder from the hill
2002-09-13 15:17 ` Daniel Phillips
2002-09-13 15:27 ` Thunder from the hill
2002-09-13 15:37 ` Daniel Phillips
2002-09-16 2:17 ` Rusty Russell
2002-09-16 16:13 ` Daniel Phillips
2002-09-16 16:36 ` Understanding the Principles of Argumentation #3 Daniel Phillips
2002-09-16 16:42 ` Robinson Maureira Castillo
2002-09-16 17:29 ` Cort Dougan
2002-09-16 22:31 ` David Woodhouse
2002-10-01 14:13 ` Daniel Phillips
2002-10-01 14:27 ` David Woodhouse
2002-09-13 15:59 ` [RFC] Raceless module interface Daniel Phillips
2002-09-13 3:14 ` David Gibson
2002-09-13 10:35 ` Roman Zippel
2002-09-13 13:53 ` Daniel Phillips
2002-09-13 15:13 ` Roman Zippel
2002-09-13 15:30 ` Daniel Phillips
2002-09-13 15:55 ` Roman Zippel
2002-09-13 16:09 ` Daniel Phillips
2002-09-13 16:39 ` Thunder from the hill
2002-09-13 17:12 ` Daniel Phillips
2002-09-16 0:24 ` Bill Davidsen
2002-09-16 1:49 ` Rusty Russell
2002-09-16 21:36 ` Roman Zippel
2002-09-16 21:48 ` Daniel Phillips
2002-09-16 22:44 ` Roman Zippel
2002-09-11 15:28 ` Question about pseudo filesystems Bill Davidsen
2002-09-11 19:36 ` Daniel Phillips
2002-09-09 20:12 ` Daniel Phillips
2002-09-09 22:56 ` Jamie Lokier
2002-09-10 1:39 ` Alexander Viro
2002-09-09 20:18 ` Daniel Phillips
2002-09-10 6:48 ` Kai Henningsen
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=20020913080709.9026B2C054@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=lk@tantalophile.demon.co.uk \
--cc=phillips@arcor.de \
--cc=viro@math.psu.edu \
--cc=zippel@linux-m68k.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