Suggestion for module .init.{text,data} sections
A while ago, on linux-kernel, we had a discussion about
adding support for __initdata and __init in modules. Somebody (whose name escapes me) had implemented it by essentially adding a vmrealloc() facility in the kernel. I think I've thought of a simpler way, that would require almost no kernel changes.
Have insmod split the module into two parts and load them
as two modules. First, create the regular part of the module as usual (without .data.init and .text.init), except with no initialization routine set. Second, create a module from the .data.init and the .text.init sections (if any), with it's initialization routine set to the module's init_module routine, even if that routine resides in the first module. Third, there will be cross references between these two modules, so will generally be necessary to resolve the relocations before loading either module. Fourth, load the first module. This will always succeed, since there is no initialization routine to fail. Fifth, load the second module, the one made of .data.init and .text.init. It will run the actual module_init function. If the module initialization routine fails, both modules are unloaded and the usual failure behavior happens. If the module initialization succeeds, the ".init" module (the second module) is unloaded.
Potentially, this could save some memory footprint in
highly modularized systems and cleanup linux/include/init.h. I guess I would imagine this as a potential 2.5 feature, or perhaps as a default-off option intended soley for stress testing in 2.4.
I started looking through the modutils sources, but I was
a little disappointed to discover that it is ELF-specific rather than written in bfd, as I am pretty unfamiliar with ELF innards but a little more conversant in bfd. Maybe I'll take a whack at it yet, but I figure I should at least pass the idea along and see if I'm overlooking anything obvious.
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104 [email protected] \ / San Jose, California 95129-1034 +1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
Quoted 6 lines · Adam J. Richter
A while ago, on linux-kernel, we had a discussion about
adding support for__initdataand__initin modules. Somebody (whose name escapes me) had implemented it by essentially adding avmrealloc()facility in the kernel. I think I've thought of a simpler way, that would require almost no kernel changes.
[implementation details snipped]
While you are at this, you could make the .exit.{text,data} sections swappable for modules (by allocating swappable pages fro them?) and only mark them unswappable, while the module is exiting.
Rationale: A device needed for swaping will never call exit stuff, because it is still in use. So I see no obvious race here.
Regards
Ingo Oeser
Signature · 2 lines
10.+11.03.2001 - 3. Chemnitzer LinuxTag <http://www.tu-chemnitz.de/linux/tag>
<<<<<<<<<<<< been there and had much fun >>>>>>>>>>>>Quoted 15 lines · Ingo Oeser
Quoted 6 lines · Adam J. Richter
A while ago, on linux-kernel, we had a discussion about
adding support for__initdataand__initin modules. Somebody (whose name escapes me) had implemented it by essentially adding avmrealloc()facility in the kernel. I think I've thought of a simpler way, that would require almost no kernel changes.[implementation details snipped]
While you are at this, you could make the .exit.{text,data} sections swappable for modules (by allocating swappable pages fro them?) and only mark them unswappable, while the module is exiting.
Quoted 4 lines
Rationale: A device needed for swaping will never call exit stuff, because it is still in use. So I see no obvious race here.
Regards
__exit functions and data are usually too small to make the effort worth it. __init functions and data on the other hand could be quite large, if they contain firmware data for example.
--
Brian Gerst
Hi!
Quoted 8 lines
Quoted 6 lines
A while ago, on linux-kernel, we had a discussion about
adding support for__initdataand__initin modules. Somebody (whose name escapes me) had implemented it by essentially adding avmrealloc()facility in the kernel. I think I've thought of a simpler way, that would require almost no kernel changes.[implementation details snipped]
Quoted 7 lines
While you are at this, you could make the .exit.{text,data} sections swappable for modules (by allocating swappable pages fro them?) and only mark them unswappable, while the module is exiting.
Rationale: A device needed for swaping will never call exit stuff, because it is still in use. So I see no obvious race here.
You can't do that. Think about interrupt routine being swapped out.
Kernel is *not* preemptible.
Signature · 2 lines
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt, details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.
Quoted 4 lines · Pavel Machek
You can't do that. Think about interrupt routine being swapped out.
Kernel is *not* preemptible.
Quite a statement. Would you care to elaborate? I thought there are Unix (or Unix-like) kernels out there that allow pageing and premption of kernel parts. Or am i mistaken?
Dominik
Signature · 3 lines
A lovely thing to see: Kobayashi Issa
through the paper window's holes (1763-1828)
the galaxy. [taken from: David Brin - Sundiver]