public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Non-__init functions calling __init functions
@ 2003-03-20 16:03 Stuart MacDonald
  0 siblings, 0 replies; 6+ messages in thread
From: Stuart MacDonald @ 2003-03-20 16:03 UTC (permalink / raw)
  To: linux-kernel

This is always a bug isn't it?

A quick check shows that the following files have non-__init functions
calling __init init_idle() in 2.5.65:

arch/ppc/kernel/smp.c
arch/um/kernel/smp.c
arch/mips/kernel/process.c
arch/mips64/kernel/process.c
arch/parisc/kernel/smp.c
arch/s390x/kernel/smp.c
arch/s390/kernel/smp.c

..Stu



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-__init functions calling __init functions
@ 2003-03-20 16:15 Andrzej Krzysztofowicz
  2003-03-20 16:23 ` Stuart MacDonald
  0 siblings, 1 reply; 6+ messages in thread
From: Andrzej Krzysztofowicz @ 2003-03-20 16:15 UTC (permalink / raw)
  To: kernel list; +Cc: stuartm

> This is always a bug isn't it?

... unless they are guaranteed to be called in the init context only.

Andrzej

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-__init functions calling __init functions
  2003-03-20 16:15 Non-__init functions calling __init functions Andrzej Krzysztofowicz
@ 2003-03-20 16:23 ` Stuart MacDonald
  2003-03-20 16:32   ` Andrzej Krzysztofowicz
  0 siblings, 1 reply; 6+ messages in thread
From: Stuart MacDonald @ 2003-03-20 16:23 UTC (permalink / raw)
  To: Andrzej Krzysztofowicz, kernel list

From: "Andrzej Krzysztofowicz" <ankry@green.mif.pg.gda.pl>
> From: "Stuart MacDonald" <stuartm@connecttech.com>
> > This is always a bug isn't it?
>
> ... unless they are guaranteed to be called in the init context only.

In which case those functions should also be marked __init so they can
be reclaimed, correct? So it's the reciprocal bug.

..Stu



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-__init functions calling __init functions
  2003-03-20 16:23 ` Stuart MacDonald
@ 2003-03-20 16:32   ` Andrzej Krzysztofowicz
  2003-03-20 17:01     ` Chris Friesen
  0 siblings, 1 reply; 6+ messages in thread
From: Andrzej Krzysztofowicz @ 2003-03-20 16:32 UTC (permalink / raw)
  To: Stuart MacDonald; +Cc: Andrzej Krzysztofowicz, kernel list

> From: "Andrzej Krzysztofowicz" <ankry@green.mif.pg.gda.pl>
> > From: "Stuart MacDonald" <stuartm@connecttech.com>
> > > This is always a bug isn't it?
> >
> > ... unless they are guaranteed to be called in the init context only.
> 
> In which case those functions should also be marked __init so they can
> be reclaimed, correct? So it's the reciprocal bug.

Not always possible.

__init A() {
...
}

__exit B() {
...
}

C() {
...
A();
...
#ifdef MODULE
B();
#endif
...
}

C cannot be marked __init for #define MODULE case. Even if it is called only
by some __init code. I can imagine other similar situations.

However it is not your case probably.

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-__init functions calling __init functions
  2003-03-20 16:32   ` Andrzej Krzysztofowicz
@ 2003-03-20 17:01     ` Chris Friesen
  2003-03-21  9:10       ` Andrzej Krzysztofowicz
  0 siblings, 1 reply; 6+ messages in thread
From: Chris Friesen @ 2003-03-20 17:01 UTC (permalink / raw)
  To: Andrzej Krzysztofowicz; +Cc: Stuart MacDonald, kernel list

Andrzej Krzysztofowicz wrote:

> Not always possible.
> 
> __init A() {
> ...
> }
> 
> __exit B() {
> ...
> }
> 
> C() {
> ...
> A();
> ...
> #ifdef MODULE
> B();
> #endif
> ...
> }
> 
> C cannot be marked __init for #define MODULE case. Even if it is called only
> by some __init code. I can imagine other similar situations.

I thought that in the case of modules, __init is a noop?  At least, that's what 
this page says

http://www.netfilter.org/unreliable-guides/kernel-hacking/routines-init.html

So if MODULE is defined, it doesn't matter if C is labelled as __init or not, 
and if it is not defined, it *should* be labelled as __init since it is itself 
calling __init code.

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Non-__init functions calling __init functions
  2003-03-20 17:01     ` Chris Friesen
@ 2003-03-21  9:10       ` Andrzej Krzysztofowicz
  0 siblings, 0 replies; 6+ messages in thread
From: Andrzej Krzysztofowicz @ 2003-03-21  9:10 UTC (permalink / raw)
  To: Chris Friesen; +Cc: Andrzej Krzysztofowicz, Stuart MacDonald, kernel list

> Andrzej Krzysztofowicz wrote:
> 
> > Not always possible.
> > 
> > __init A() {
> > ...
> > }
> > 
> > __exit B() {
> > ...
> > }
> > 
> > C() {
> > ...
> > A();
> > ...
> > #ifdef MODULE
> > B();
> > #endif
> > ...
> > }
> > 
> > C cannot be marked __init for #define MODULE case. Even if it is called only
> > by some __init code. I can imagine other similar situations.
> 
> I thought that in the case of modules, __init is a noop?  At least, that's what 
> this page says

Currently - yes.
But I heard about patches that make __init usefull in modular case.
Why break them ?

> http://www.netfilter.org/unreliable-guides/kernel-hacking/routines-init.html
> 
> So if MODULE is defined, it doesn't matter if C is labelled as __init or not, 
> and if it is not defined, it *should* be labelled as __init since it is itself 
> calling __init code.

Safely the following can be added:

+ #ifndef MODULE
+ __init
+ #endif
  C() {

But I heard that our policy is avoiding extra #ifdefs if possible... 

AFAIR, some __init functions were called (in 2.4 scsi code; I didn't check
newer code) indirectly, by pointers to them, from non __init code. It is
more dificult to detect such cases.

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Gdansk University of Technology

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-03-21  8:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-20 16:15 Non-__init functions calling __init functions Andrzej Krzysztofowicz
2003-03-20 16:23 ` Stuart MacDonald
2003-03-20 16:32   ` Andrzej Krzysztofowicz
2003-03-20 17:01     ` Chris Friesen
2003-03-21  9:10       ` Andrzej Krzysztofowicz
  -- strict thread matches above, loose matches on Subject: below --
2003-03-20 16:03 Stuart MacDonald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox