Skip to contentSkip to conversation

Proposed module init race fix.

PATCH Petr Vandrovec 3 participants 3 messages Jan 15, 2003 – Jan 16, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 9 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 8 lines · Rusty Russell
Quoted 6 lines

It's possible to start using a module, and then have it fail initialization. In 2.4, this resulted in random behaviour. One solution to this is to make all interfaces two-stage: reserve everything you need (which might fail), the activate them. This means changing about 1600 modules, and deprecating every interface they use.

Quoted 5 lines
Quoted 3 lines

Could you explain this "random behavior" of 2.4 a bit more?
As far as I know, if a module's init function fails, it must unregister everything that it has registered up to that point.

And if someone's using it, the module gets unloaded underneath them.

No. Unregister will go to sleep until it is safe to unregister driver. See unregister_netdevice for perfect example, but I'm sure that there are other unregister functions which make sure that after unregister it is OK to destroy everything.
Best regards,
Petr Vandrovec [email protected]

#1 lore raw

In message <[email protected]> you write:

Quoted 6 lines · Rusty Russell
Quoted 5 lines

In message <[email protected]> you write:

Quoted 3 lines

Could you explain this "random behavior" of 2.4 a bit more?
As far as I know, if a module's init function fails, it must unregister everything that it has registered up to that point.

Quoted 6 lines
Quoted 1 line

And if someone's using it, the module gets unloaded underneath them.

No. Unregister will go to sleep until it is safe to unregister driver. See unregister_netdevice for perfect example, but I'm sure that there are other unregister functions which make sure that after unregister it is OK to destroy everything.

And see remove_proc_entry, or notifier_chain_unregister for counterexamples. No doubt there are others.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#2 lore raw
Quoted 2 lines · Rusty Russell

And see remove_proc_entry, or notifier_chain_unregister for counterexamples. No doubt there are others.

Perhaps some convenient include file should contain something like this:

#ifdef CONFIG_DEBUG_KERNEL
#define whistleblower() \
printk(KERN_ERR "this interface may call back after deregistration\n");
#else
#define whistleblower() /* no failure is silent in Oopsland */ #endif

? ;-)

- Werner

Signature · 3 lines
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         [email protected] /
/_http://www.almesberger.net/____________________________________________/