Re: __init & __exit

Horst von Brand (vonbrand@inf.utfsm.cl)
Tue, 10 Aug 1999 11:36:37 -0400


"Petr Vandrovec Ing. VTEI" <VANDROVE@vc.cvut.cz> said:
> On 10 Aug 99 at 9:50, Horst von Brand wrote:
> > > for hotpluggable devices we then cannot
> > > release __init section in most cases (as
> > > device initialization lives in this section
> > > in most cases).

> > It's probably easier to get the module in two pieces: foo-init and
> > foo-proper. foo-init loads foo-proper (or is loaded by a dependency,
> > whatever), initializes it and goes away. Or use the kernel __init idea:
> > Use it, loose it.

> It requires some cooperation from modutils - it knows which module depends
> on which, so you cannot release foo-init. And it has no idea about __init -
> it could eventually lead to call into released memory on another module
> insmod. And, unfortunately, you cannot use this aproach for objects build
> into kernel - these __init sections are stored only in kernel image, nowhere
> else.

Seems you misunderstood me: What the kernel does is stuff all the init code
and data into separate segments (which are not intermingled with the
rest). After using them, the memory is just reused. In the module case, you
could do the same: Separate initialization stuff, and return its memory to
the system after use. I doubt it is useful in general, as this will usually
amount to a few bytes, and modules are allocated in 4K pages.

The foo-{init,proper} would work without any changes AFAIKS if foo-init
depended on foo-proper (sure will, as it meddles with its symbols :); then
when you load foo-init, foo-proper gets loaded automatically, foo-init does
its work and unloads (or marks itself unused, and gets reaped by the
standard procedure).

-- 
Dr. Horst H. von Brand                       mailto:vonbrand@inf.utfsm.cl
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/