Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Jan 2009 18:35:48 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r187554 - in stable/7/sys: . contrib/pf dev/cxgb kern
Message-ID:  <200901211835.n0LIZmCf086637@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901211835.n0LIZmCf086637>