From: Rusty Russell <rusty@rustcorp.com.au>
To: Roman Zippel <zippel@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH][RFC] new module interface
Date: Sat, 27 Jul 2002 16:49:59 +1000 [thread overview]
Message-ID: <20020727070413.EF52943E4@lists.samba.org> (raw)
In-Reply-To: Your message of "Fri, 26 Jul 2002 12:12:06 +0200." <Pine.LNX.4.44.0207261109470.28515-100000@serv>
In message <Pine.LNX.4.44.0207261109470.28515-100000@serv> you write:
> Hi,
>
> On Fri, 26 Jul 2002, Rusty Russell wrote:
> > Well, you substituted the module pointer for an atomic counter. Bit
> > of a wash, really.
>
> Converting the module pointer into a counter is the easiest way to convert
> to the new interface. Behind that is a very important concept - complete
> seperation of module state management (done in kernel/module.c) and module
> usage management (done by the module). Both are independent in my patch,
> so the module has complete freedom how to do the later. This means it
> doesn't has to use a counter, the usecount function could be as well
> something like "return busy ? 1 : 0;" and the module won't be bothered
> with unloading.
But your added flexibility doesn't actually buy you any more power.
It does mean (as implemented) that even without module support in your
kernel, filesystems have to be reference counted.
> On the other hand if a module needs something more
> complex, it can do so without bothering the remaining the module code
> (e.g. if I look at the LSM hooks, I'm really not sure how to sanely unload
> a module from that).
Exactly. I don't see how it is a definitive win 8(
> > No, if you drop them newer binutils notices the link problem, hence
> > the __devexit_p(x) macro.
>
> AFAIK we have that problem if we discard the sections immediately at link
> time, but we could also discard them at kernel init. On the other hand I'm
> not completely against wrapping the field initialization in a macro.
Yes. I hate the macro wrapping myself though 8(
> > > Not yet. The problem is the module name, e.g. ext2 is called
> > > fs_ext2_super, it will need some kbuild changes to get the right module
> > > name.
> >
> > I need that too: the mythical "KBUILD_MODNAME". Both Keith and Kai
> > promised it to me...
>
> I found a solution for that yesterday. :)
> I looked at your patch and some interesting parts are missing, so it's
> difficult to comment. It's really small, but it also has lots of FIXMEs. :)
> My module pointer comment above applies to your patch as well. Since
> module unloading isn't implemented yet, it's difficult to say how you want
> to avoid the races.
I removed module unloading from the current patch, because of ongoing
debate (and as you know, this is a whole issue by itself 8).
The implementation in the older patches did:
module->waiting = current;
err = module->stop();
if (err)
return err;
synchronize_kernel();
module_put(module);
while (atomic_read(&module->count)) {
set_current_state(TASK_INTERRUPTIBLE);
schedule();
}
synchronize_kernel() waits for every CPU to schedule (with preemption,
it means wait for every preempted thread to voluntarily schedule).
This prevents the "MOD_DEC_USE_COUNT; return" race.
module_put() was a simple:
if (atomic_dec_and_test(&module->count))
wake_up_process(module->waiting);
> One thing I mentioned earlier is that I still think that module linkage
> is better done in user space, if we also keep all the symbol and
> dependency information in user space. Insmod just had to relocate the
> module and the kernel only needs the pointer to the module structure and
> finds the rest through it, so no adding of new sections/symbols or
> initialization of the module structure would be required, so insmod hadn'
I think the in-kernel linker is much neater, and much smaller than the
combined one. One big advantage is that I don't have to do 64-bit
links on a 32-bit userspace.
> BTW I also looked at the automatic initcall generation script, I think I
> have a solution for a big part of the problem, that would at least allow
> to order the init calls of all normal modules. (Patches are coming
> hopefully soon. :) )
Yes. I thought of treating each module as one "unit" for the purposes
of initialization order, and resolving the ordering within each module
as a separate problem, but I ran out of energy, and I'm not convinced
that some core code loops are not fundamental. The problem is that if
there are still loops, they may well depend on .config so some poor
user with a different config can't compile the kernel 8(
And the explicit initcalls are pretty nice, too!
Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-07-27 7:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-24 20:02 [PATCH][RFC] new module interface Roman Zippel
2002-07-25 8:08 ` Rusty Russell
2002-07-25 9:56 ` Roman Zippel
2002-07-26 3:43 ` Rusty Russell
2002-07-26 4:22 ` Keith Owens
2002-07-26 10:12 ` Roman Zippel
2002-07-27 6:49 ` Rusty Russell [this message]
2002-07-28 11:57 ` Roman Zippel
2002-07-26 18:15 ` Kai Germaschewski
2002-07-27 7:00 ` Rusty Russell
2002-07-27 17:11 ` Kai Germaschewski
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=20020727070413.EF52943E4@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--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