On Wed, Sep 18, 2002 at 02:53:44PM +0530, Nagaraj wrote: > > MOD_INC_USE_COUNT and MOD_DEC_USE_COUNT are incorrect on SMP. That is, > > if they are called from the module, there is a race condition. > > > Hmmm...but this code from linux/include/linux/module.h says atomic_inc. > > #define __MOD_INC_USE_COUNT(mod) \ > (atomic_inc(&(mod)->uc.usecount), (mod)->flags |= > MOD_VISITED|MOD_USED_ONCE) Well, I did not state it exactly. It's not in these call themselves. The race is in using them from the module itself. Because the caller must keep the reference, not the called. > > Anyway, such module may be unloaded using kgdb, or maybe even gdb on > > /proc/kcore - you zero out the counter manually. Or you can write > > a simple module, that will zero the count (it will only have the init > > function, which will return error at the end, so nothing will be actualy > > loaded). > > Well ive an idea, plz tellme if this is feasible. > > We traverse the list of modules by doing: > > struct module *mod_list = THIS_MODULE; > > and identify the module which has faulted. > Then manually doin some cleanups. > > in linux/kernel/module.c i saw this code: > sys_delete_module(const char *name_user); > { > : > : > if (!__MOD_IN_USE(mod)) { > mod->flags |= MOD_DELETED; > spin_unlock(&unload_lock); > free_module(mod, 0); > error = 0; > } else { > /* We can do cleanup here */ > spin_unlock(&unload_lock); > } > goto out; > : > : > } > > Well, but i think this would also introduce bugs. > Anybody who knows what r those ?? ... no, this is autoclean. To get rid of crashed modules, you have to explicitely tamper their use count. Else __MOD_IN_USE still declares them in use. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/