From owner-svn-src-stable@FreeBSD.ORG Wed Jan 21 18:35:49 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB615106570F; Wed, 21 Jan 2009 18:35:48 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A2CB88FC0C; Wed, 21 Jan 2009 18:35:48 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0LIZmLJ086638; Wed, 21 Jan 2009 18:35:48 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0LIZmCf086637; Wed, 21 Jan 2009 18:35:48 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <200901211835.n0LIZmCf086637@svn.freebsd.org> From: John Baldwin Date: Wed, 21 Jan 2009 18:35:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187554 - in stable/7/sys: . contrib/pf dev/cxgb kern X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2009 18:35:55 -0000 Author: jhb Date: Wed Jan 21 18:35:48 2009 New Revision: 187554 URL: http://svn.freebsd.org/changeset/base/187554 Log: MFC: Reorder modules during initialization to ensure that MOD_QUIESCE and MOD_UNLOAD events are posted to kernel modules in the reverse order of MOD_LOAD events. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/kern/kern_module.c Modified: stable/7/sys/kern/kern_module.c ============================================================================== --- stable/7/sys/kern/kern_module.c Wed Jan 21 18:32:43 2009 (r187553) +++ stable/7/sys/kern/kern_module.c Wed Jan 21 18:35:48 2009 (r187554) @@ -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); }