Date: Fri, 5 Dec 2008 16:47:31 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185642 - head/sys/kern Message-ID: <200812051647.mB5GlVst067730@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Fri Dec 5 16:47:30 2008 New Revision: 185642 URL: http://svn.freebsd.org/changeset/base/185642 Log: When the SYSINIT() to load a module invokes the MOD_LOAD event successfully, move that module to the head of the associated linker file's list of modules. The end result is that once all the modules are loaded, they are sorted in the reverse of their load order. This causes the kernel linker to invoke the MOD_QUIESCE and MOD_UNLOAD events in the reverse of the order that MOD_LOAD was invoked. This means that the ordering of MOD_LOAD events that is set by the SI_* paramters to DECLARE_MODULE() are now honored in the same order they would be for SYSUNINIT() for the MOD_QUIESCE and MOD_UNLOAD events. MFC after: 1 month Modified: head/sys/kern/kern_module.c Modified: head/sys/kern/kern_module.c ============================================================================== --- head/sys/kern/kern_module.c Fri Dec 5 15:50:59 2008 (r185641) +++ head/sys/kern/kern_module.c Fri Dec 5 16:47:30 2008 (r185642) @@ -130,6 +130,21 @@ module_register_init(const void *arg) printf("module_register_init: MOD_LOAD (%s, %p, %p) error" " %d\n", data->name, (void *)data->evhand, data->priv, error); + } else { + MOD_XLOCK; + if (mod->file) { + /* + * Once a module is succesfully loaded, move + * it to the head of the module list for this + * linker file. This resorts the list so that + * when the kernel linker iterates over the + * modules to unload them, it will unload them + * in the reverse order they were loaded. + */ + TAILQ_REMOVE(&mod->file->modules, mod, flink); + TAILQ_INSERT_HEAD(&mod->file->modules, mod, flink); + } + MOD_XUNLOCK; } mtx_unlock(&Giant); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812051647.mB5GlVst067730>