From: Rusty Russell <rusty@rustcorp.com.au>
To: Werner Almesberger <wa@almesberger.net>
Cc: kuznet@ms2.inr.ac.ru, Roman Zippel <zippel@linux-m68k.org>,
kronos@kronoz.cjb.net, linux-kernel@vger.kernel.org
Subject: Re: [RFC] Migrating net/sched to new module interface
Date: Thu, 16 Jan 2003 12:12:25 +1100 [thread overview]
Message-ID: <20030116013125.ACE0F2C0A3@lists.samba.org> (raw)
In-Reply-To: Your message of "Wed, 15 Jan 2003 06:33:49 -0300." <20030115063349.A1521@almesberger.net>
In message <20030115063349.A1521@almesberger.net> you write:
> Rusty Russell wrote:
> > 1) It's simply not a good idea to force 1600 modules to change, no
> > matter what timescale.
>
> That's the part that I don't believe. The kernel interfaces
> aren't static. Locking rules have changed several times, the
> wait/sleep interface has changed, the concept of a module
> owner has been added, various other interfaces have changed.
Deprecating every module, and rewriting their initialization routines
is ambitious beyond the scale of anything you have mentioned. Not
that 90% of the kernel code couldn't use a damn good spring cleaning,
but I'm not prepared to make such a change personally.
And remember why we're doing it: for a fairly obscure race condition.
> > And changing it in a way that is *more*,
> > not *less* complex is even worse.
>
> The implementation may be more complex, but the change I'm
> suggesting would greatly simplify the rules: no endless set
> of voodoo rites, but one simple rule: "the shutdowncall
> function either does nothing, and returns failure, or it
> returns success, and completely de-registers everything it
> has previously registered".
So we go from:
int init(void)
{
if (!register_foo(&foo))
return -err;
if (!register_bar(&bar)) {
unregister_foo(&foo);
return -err;
}
return 0;
}
void fini(void)
{
unregister_foo(&foo);
unregister_bar(&bar);
}
to:
int fini(void)
{
if (!unregister_foo(&foo))
return -err;
if (!unregister_bar(&bar)) {
if (!register_foo(&foo))
????
return -err;
}
return 0;
}
> > PS. The *implementation* flaw in your scheme: someone starts using a
> > module as you try to deregister it.
>
> If a callback comes in at the wrong moment, the module can
> choose to de-register and wait until the subsystem has
> finished any callbacks, or detect that it's about to
> shut itself down, and fail the callback. The point is that
> all the locking is now under control of the module, and
> not scattered all over kernel+module(s).
Something like this?
static int i_am_live;
static spinlock_t my_lock = SPIN_LOCK_UNLOCKED;
/* This is our registered function. */
static int foo_function(void *somedata)
{
int live;
spin_lock(&my_lock);
live = i_am_live;
spin_unlock(&my_lock);
if (!live)
return -EIGNOREME???;
...
}
int fini(void)
{
spin_lock(&my_lock);
i_am_live = 0;
spin_unlock(&my_lock);
if (!unregister_foo(&foo)) {
spin_lock(&my_lock);
i_am_live = 1;
spin_unlock(&my_lock);
return -err;
}
if (!unregister_bar(&bar)) {
if (!register_foo(&foo))
????
spin_lock(&my_lock);
i_am_live = 1;
spin_unlock(&my_lock);
return -err;
}
return 0;
}
Now, if someone tries to remove a module, but it's busy, you get a
window of spurious failure, even though the module isn't actually
removed. Secondly, there is often no way of returning a value which
says "I'm going away, act as if I'm not here": only the level above
can sanely know what it would do if this were not found.
> > (ie. you can never unload security modules),
>
> Hmm, what makes security modules (what exactly do you mean
> by that ?) special ? In any case, a module that's truly
> unloadable would simply return failure from its
> shutdowncall.
On a busy system, they're never not being used. Your unload routine
would always fail. Same with netfilter modules.
> > or you leave it half unloaded (even worse).
>
> There's always the choice of just sleeping through any
> inconvenient callbacks. In some cases, this is perfectly
> acceptable, because the callback won't keep the module
> busy for a long time anyway (interrupts, timers, tasklets,
> etc.). In other cases (e.g. "open" functions), a callback
> could keep it busy forever.
Exactly. It's kept there forever, while the module is useless.
> The problem I see with the current module interface is that it
> just tries to hack the current mess into a less buggy state,
> but doesn't provide much of an incentive for actually cleaning
> up the interfaces.
>
> Avoiding the bugs is good, but we should also work towards a
> clean long-term solution.
The current scheme is clean: it's two-stage delete with a nice helper
function "try_module_get()" which tells you when it's going away, and
no requirement that modules actually implement two-stage delete
themselves. The patch to mirror this in two-stage init was posted
yesterday, as well.
It also puts the (minimal) burden in the right place: in the interface
coder's lap, not the interface user's lap.
Unfortunately, I don't have the patience to explain this once for
every kernel developer.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2003-01-16 1:22 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-02 22:50 [RFC] Migrating net/sched to new module interface Kronos
2003-01-03 5:10 ` Rusty Russell
2003-01-03 8:37 ` David S. Miller
2003-01-04 6:09 ` Rusty Russell
2003-01-04 16:21 ` Kronos
2003-01-13 22:32 ` kuznet
2003-01-13 23:23 ` Max Krasnyansky
2003-01-14 17:49 ` Kronos
2003-01-15 0:21 ` Roman Zippel
2003-01-15 1:19 ` kuznet
2003-01-15 7:31 ` Werner Almesberger
2003-01-15 8:16 ` Rusty Russell
2003-01-15 9:33 ` Werner Almesberger
2003-01-16 1:12 ` Rusty Russell [this message]
2003-01-16 2:42 ` Werner Almesberger
2003-01-16 3:31 ` Rusty Russell
2003-01-16 4:20 ` Werner Almesberger
2003-01-16 4:25 ` David S. Miller
2003-01-16 4:49 ` Werner Almesberger
2003-01-16 16:05 ` Roman Zippel
2003-01-16 18:15 ` Roman Zippel
2003-01-16 18:58 ` Werner Almesberger
2003-01-16 23:53 ` Roman Zippel
2003-01-17 1:04 ` Greg KH
2003-01-17 2:27 ` Rusty Russell
2003-01-17 21:40 ` Roman Zippel
2003-02-13 23:16 ` Werner Almesberger
2003-02-14 1:57 ` Rusty Russell
2003-02-14 3:44 ` Werner Almesberger
2003-02-14 11:16 ` Roman Zippel
2003-02-14 12:04 ` Rusty Russell
2003-02-14 12:49 ` Roman Zippel
2003-02-17 1:59 ` Rusty Russell
2003-02-17 10:53 ` Roman Zippel
2003-02-17 23:31 ` Rusty Russell
2003-02-18 12:26 ` Roman Zippel
2003-02-14 13:21 ` Roman Zippel
2003-02-14 13:53 ` Werner Almesberger
2003-02-14 14:24 ` Roman Zippel
2003-02-14 18:30 ` Werner Almesberger
2003-02-14 20:09 ` Roman Zippel
2003-02-15 0:12 ` Werner Almesberger
2003-02-15 0:51 ` Roman Zippel
2003-02-15 2:28 ` Werner Almesberger
2003-02-15 23:20 ` Roman Zippel
2003-02-17 17:04 ` Werner Almesberger
2003-02-17 23:09 ` [RFC] Is an alternative module interface needed/possible? Roman Zippel
2003-02-18 1:18 ` Werner Almesberger
2003-02-18 4:54 ` Rusty Russell
2003-02-18 7:20 ` Werner Almesberger
2003-02-18 12:06 ` Roman Zippel
2003-02-18 14:12 ` Werner Almesberger
2003-02-18 12:45 ` Thomas Molina
2003-02-18 17:22 ` Werner Almesberger
2003-02-19 3:30 ` Rusty Russell
2003-02-19 4:11 ` Werner Almesberger
2003-02-19 23:38 ` Rusty Russell
2003-02-20 9:46 ` Roman Zippel
2003-02-20 0:40 ` Roman Zippel
2003-02-20 2:17 ` Werner Almesberger
2003-02-23 16:02 ` Roman Zippel
2003-02-26 23:26 ` Werner Almesberger
2003-02-27 12:34 ` Roman Zippel
2003-02-27 13:20 ` Werner Almesberger
2003-02-27 14:33 ` Roman Zippel
2003-02-23 23:34 ` Kevin O'Connor
2003-02-24 12:14 ` Roman Zippel
2003-02-18 12:35 ` Roman Zippel
2003-02-18 14:14 ` Werner Almesberger
2003-02-19 1:48 ` Roman Zippel
2003-02-19 2:27 ` Werner Almesberger
2003-01-16 13:44 ` [RFC] Migrating net/sched to new module interface Roman Zippel
2003-01-15 17:04 ` Roman Zippel
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=20030116013125.ACE0F2C0A3@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=kronos@kronoz.cjb.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=wa@almesberger.net \
--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