Date: Sun, 13 Aug 2006 01:03:24 GMT From: Chris Jones <cdjones@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 103741 for review Message-ID: <200608130103.k7D13O2X014685@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=103741 Change 103741 by cdjones@cdjones-impulse on 2006/08/13 01:02:50 Integrate to keep things building properly. Whee. Affected files ... .. //depot/projects/soc2006/cdjones_jail/src/sys/conf/NOTES#3 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/conf/files#3 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/conf/options#3 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_mutex.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_sx.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_syscalls.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_sysctl.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/sched_hier.c#7 edit .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_autoconf.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_lock.c#3 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_turnstile.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_witness.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/kernel.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/lock.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/mutex.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/param.h#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/serial.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/sysent.h#5 integrate Differences ... ==== //depot/projects/soc2006/cdjones_jail/src/sys/conf/NOTES#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1325.2.14 2006/04/05 15:44:08 hrs Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1325.2.16 2006/08/10 10:40:45 glebius Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -557,6 +557,7 @@ options NETGRAPH_SOCKET options NETGRAPH_SPLIT options NETGRAPH_SPPP +options NETGRAPH_TAG options NETGRAPH_TCPMSS options NETGRAPH_TEE options NETGRAPH_TTY @@ -1771,6 +1772,9 @@ # SMC91C90/92/94/95 chips. # ste: Sundance Technologies ST201 PCI fast ethernet controller, includes # the D-Link DFE-550TX. +# stge: Support for gigabit ethernet adapters based on the Sundance/Tamarack +# TC9021 family of controllers, including the Sundance ST2021/ST2023, +# the Sundance/Tamarack TC9021, the D-Link DL-4000 and ASUS NX1101. # ti: Support for PCI gigabit ethernet NICs based on the Alteon Networks # Tigon 1 and Tigon 2 chipsets. This includes the Alteon AceNIC, the # 3Com 3c985, the Netgear GA620 and various others. Note that you will ==== //depot/projects/soc2006/cdjones_jail/src/sys/conf/files#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/files,v 1.1031.2.33 2006/07/24 23:20:58 thompsa Exp $ +# $FreeBSD: src/sys/conf/files,v 1.1031.2.37 2006/08/10 10:40:45 glebius Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -681,8 +681,12 @@ dev/mii/e1000phy.c optional e1000phy dev/mii/exphy.c optional miibus dev/mii/exphy.c optional exphy +dev/mii/gentbi.c optional miibus +dev/mii/gentbi.c optional mii dev/mii/inphy.c optional miibus dev/mii/inphy.c optional inphy +dev/mii/ip1000phy.c optional miibus +dev/mii/ip1000phy.c optional ip1000phy dev/mii/lxtphy.c optional miibus dev/mii/lxtphy.c optional lxtphy dev/mii/mii.c optional miibus @@ -891,6 +895,7 @@ dev/stg/tmc18c30_pccard.c optional stg pccard dev/stg/tmc18c30_pci.c optional stg pci dev/stg/tmc18c30_subr.c optional stg +dev/stge/if_stge.c optional stge dev/streams/streams.c optional streams dev/sx/sx.c optional sx #dev/sx/sx_isa.c optional sx isa @@ -1300,6 +1305,7 @@ kern/subr_hints.c standard kern/subr_kdb.c standard kern/subr_kobj.c standard +kern/subr_lock.c standard kern/subr_log.c standard kern/subr_mbpool.c optional libmbpool kern/subr_mchain.c optional libmchain @@ -1623,6 +1629,7 @@ netgraph/ng_socket.c optional netgraph_socket netgraph/ng_split.c optional netgraph_split netgraph/ng_sppp.c optional netgraph_sppp +netgraph/ng_tag.c optional netgraph_tag netgraph/ng_tcpmss.c optional netgraph_tcpmss netgraph/ng_tee.c optional netgraph_tee netgraph/ng_tty.c optional netgraph_tty ==== //depot/projects/soc2006/cdjones_jail/src/sys/conf/options#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options,v 1.510.2.13 2006/07/24 23:20:58 thompsa Exp $ +# $FreeBSD: src/sys/conf/options,v 1.510.2.14 2006/08/10 10:40:45 glebius Exp $ # # On the handling of kernel options # @@ -440,6 +440,7 @@ NETGRAPH_SOCKET opt_netgraph.h NETGRAPH_SPLIT opt_netgraph.h NETGRAPH_SPPP opt_netgraph.h +NETGRAPH_TAG opt_netgraph.h NETGRAPH_TCPMSS opt_netgraph.h NETGRAPH_TEE opt_netgraph.h NETGRAPH_TTY opt_netgraph.h ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_mutex.c#6 (text+ko) ==== @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_mutex.c,v 1.154.2.5 2005/12/20 19:28:23 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_mutex.c,v 1.154.2.9 2006/08/11 18:54:10 jhb Exp $"); #include "opt_adaptive_mutexes.h" #include "opt_ddb.h" @@ -278,7 +278,9 @@ { MPASS(curthread != NULL); - KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_lock() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_sleep, ("mtx_lock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->mtx_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, @@ -287,6 +289,7 @@ LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + curthread->td_locks++; #ifdef MUTEX_PROFILING /* don't reset the timer when/if recursing */ if (m->mtx_acqtime == 0) { @@ -303,9 +306,12 @@ { MPASS(curthread != NULL); - KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_unlock() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_sleep, ("mtx_unlock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); + curthread->td_locks--; WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, line); @@ -382,7 +388,9 @@ { MPASS(curthread != NULL); - KASSERT(m->mtx_object.lo_class == &lock_class_mtx_spin, + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_lock_spin() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_spin, ("mtx_lock_spin() of sleep mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); WITNESS_CHECKORDER(&m->mtx_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE, @@ -398,7 +406,9 @@ { MPASS(curthread != NULL); - KASSERT(m->mtx_object.lo_class == &lock_class_mtx_spin, + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_unlock_spin() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_spin, ("mtx_unlock_spin() of sleep mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); @@ -419,7 +429,9 @@ int rval; MPASS(curthread != NULL); - KASSERT(m->mtx_object.lo_class == &lock_class_mtx_sleep, + KASSERT(m->mtx_lock != MTX_DESTROYED, + ("mtx_trylock() of destroyed mutex @ %s:%d", file, line)); + KASSERT(LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_sleep, ("mtx_trylock() of spin mutex %s @ %s:%d", m->mtx_object.lo_name, file, line)); @@ -431,9 +443,11 @@ rval = _obtain_lock(m, (uintptr_t)curthread); LOCK_LOG_TRY("LOCK", &m->mtx_object, opts, rval, file, line); - if (rval) + if (rval) { WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); + curthread->td_locks++; + } return (rval); } @@ -449,7 +463,7 @@ int line) { #if defined(SMP) && !defined(NO_ADAPTIVE_MUTEXES) - struct thread *owner; + volatile struct thread *owner; #endif uintptr_t v; #ifdef KTR @@ -830,7 +844,8 @@ void mtx_init(struct mtx *m, const char *name, const char *type, int opts) { - struct lock_object *lock; + struct lock_class *class; + int flags; MPASS((opts & ~(MTX_SPIN | MTX_QUIET | MTX_RECURSE | MTX_NOWITNESS | MTX_DUPOK)) == 0); @@ -840,30 +855,33 @@ mtx_validate(m); #endif - lock = &m->mtx_object; - KASSERT((lock->lo_flags & LO_INITIALIZED) == 0, - ("mutex \"%s\" %p already initialized", name, m)); - bzero(m, sizeof(*m)); + /* Determine lock class and lock flags. */ if (opts & MTX_SPIN) - lock->lo_class = &lock_class_mtx_spin; + class = &lock_class_mtx_spin; else - lock->lo_class = &lock_class_mtx_sleep; - lock->lo_name = name; - lock->lo_type = type != NULL ? type : name; + class = &lock_class_mtx_sleep; + flags = 0; if (opts & MTX_QUIET) - lock->lo_flags = LO_QUIET; + flags |= LO_QUIET; if (opts & MTX_RECURSE) - lock->lo_flags |= LO_RECURSABLE; + flags |= LO_RECURSABLE; if ((opts & MTX_NOWITNESS) == 0) - lock->lo_flags |= LO_WITNESS; + flags |= LO_WITNESS; if (opts & MTX_DUPOK) - lock->lo_flags |= LO_DUPOK; + flags |= LO_DUPOK; + /* Initialize mutex. */ m->mtx_lock = MTX_UNOWNED; + m->mtx_recurse = 0; +#ifdef MUTEX_PROFILING + m->mtx_acqtime = 0; + m->mtx_filename = NULL; + m->mtx_lineno = 0; + m->mtx_contest_holding = 0; + m->mtx_contest_locking = 0; +#endif - LOCK_LOG_INIT(lock, opts); - - WITNESS_INIT(lock); + lock_init(&m->mtx_object, class, name, type, flags); } /* @@ -876,19 +894,24 @@ mtx_destroy(struct mtx *m) { - LOCK_LOG_DESTROY(&m->mtx_object, 0); - if (!mtx_owned(m)) MPASS(mtx_unowned(m)); else { MPASS((m->mtx_lock & (MTX_RECURSED|MTX_CONTESTED)) == 0); + /* Perform the non-mtx related part of mtx_unlock_spin(). */ + if (LOCK_CLASS(&m->mtx_object) == &lock_class_mtx_spin) + spinlock_exit(); + else + curthread->td_locks--; + /* Tell witness this isn't locked to make it happy. */ WITNESS_UNLOCK(&m->mtx_object, LOP_EXCLUSIVE, __FILE__, __LINE__); } - WITNESS_DESTROY(&m->mtx_object); + m->mtx_lock = MTX_DESTROYED; + lock_destroy(&m->mtx_object); } /* @@ -900,9 +923,6 @@ mutex_init(void) { - /* Setup thread0 so that mutexes work. */ - LIST_INIT(&thread0.td_contested); - /* Setup turnstiles so that sleep mutexes work. */ init_turnstiles(); @@ -917,27 +937,6 @@ } #ifdef DDB -/* XXX: This function is not mutex-specific. */ -DB_SHOW_COMMAND(lock, db_show_lock) -{ - struct lock_object *lock; - - if (!have_addr) - return; - lock = (struct lock_object *)addr; - if (lock->lo_class != &lock_class_mtx_sleep && - lock->lo_class != &lock_class_mtx_spin && - lock->lo_class != &lock_class_sx) { - db_printf("Unknown lock class\n"); - return; - } - db_printf(" class: %s\n", lock->lo_class->lc_name); - db_printf(" name: %s\n", lock->lo_name); - if (lock->lo_type && lock->lo_type != lock->lo_name) - db_printf(" type: %s\n", lock->lo_type); - lock->lo_class->lc_ddb_show(lock); -} - void db_show_mtx(struct lock_object *lock) { @@ -947,7 +946,7 @@ m = (struct mtx *)lock; db_printf(" flags: {"); - if (m->mtx_object.lo_class == &lock_class_mtx_spin) + if (LOCK_CLASS(lock) == &lock_class_mtx_spin) db_printf("SPIN"); else db_printf("DEF"); ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_sx.c#5 (text+ko) ==== @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_sx.c,v 1.25.2.1 2005/12/20 19:28:23 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_sx.c,v 1.25.2.3 2006/08/11 18:54:10 jhb Exp $"); #include "opt_ddb.h" @@ -77,16 +77,7 @@ void sx_init(struct sx *sx, const char *description) { - struct lock_object *lock; - lock = &sx->sx_object; - KASSERT((lock->lo_flags & LO_INITIALIZED) == 0, - ("sx lock %s %p already initialized", description, sx)); - bzero(sx, sizeof(*sx)); - lock->lo_class = &lock_class_sx; - lock->lo_type = lock->lo_name = description; - lock->lo_flags = LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE | - LO_UPGRADABLE; sx->sx_lock = mtx_pool_find(mtxpool_lockbuilder, sx); sx->sx_cnt = 0; cv_init(&sx->sx_shrd_cv, description); @@ -94,18 +85,14 @@ cv_init(&sx->sx_excl_cv, description); sx->sx_excl_wcnt = 0; sx->sx_xholder = NULL; - - LOCK_LOG_INIT(lock, 0); - - WITNESS_INIT(lock); + lock_init(&sx->sx_object, &lock_class_sx, description, NULL, + LO_WITNESS | LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE); } void sx_destroy(struct sx *sx) { - LOCK_LOG_DESTROY(&sx->sx_object, 0); - KASSERT((sx->sx_cnt == 0 && sx->sx_shrd_wcnt == 0 && sx->sx_excl_wcnt == 0), ("%s (%s): holders or waiters\n", __func__, sx->sx_object.lo_name)); @@ -114,7 +101,7 @@ cv_destroy(&sx->sx_shrd_cv); cv_destroy(&sx->sx_excl_cv); - WITNESS_DESTROY(&sx->sx_object); + lock_destroy(&sx->sx_object); } void @@ -141,6 +128,7 @@ LOCK_LOG_LOCK("SLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, 0, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); } @@ -154,6 +142,7 @@ sx->sx_cnt++; LOCK_LOG_TRY("SLOCK", &sx->sx_object, 0, 1, file, line); WITNESS_LOCK(&sx->sx_object, LOP_TRYLOCK, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); return (1); } else { @@ -197,6 +186,7 @@ LOCK_LOG_LOCK("XLOCK", &sx->sx_object, 0, 0, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); } @@ -212,6 +202,7 @@ LOCK_LOG_TRY("XLOCK", &sx->sx_object, 0, 1, file, line); WITNESS_LOCK(&sx->sx_object, LOP_EXCLUSIVE | LOP_TRYLOCK, file, line); + curthread->td_locks++; mtx_unlock(sx->sx_lock); return (1); } else { @@ -228,6 +219,7 @@ _sx_assert(sx, SX_SLOCKED, file, line); mtx_lock(sx->sx_lock); + curthread->td_locks--; WITNESS_UNLOCK(&sx->sx_object, 0, file, line); /* Release. */ @@ -258,6 +250,7 @@ mtx_lock(sx->sx_lock); MPASS(sx->sx_cnt == -1); + curthread->td_locks--; WITNESS_UNLOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line); /* Release. */ ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_syscalls.c#5 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_syscalls.c,v 1.11 2004/07/15 08:26:05 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_syscalls.c,v 1.11.8.1 2006/08/11 19:23:48 jhb Exp $"); #include <sys/param.h> #include <sys/sysproto.h> @@ -97,8 +97,11 @@ case MOD_LOAD : error = syscall_register(data->offset, data->new_sysent, &data->old_sysent); - if (error) + if (error) { + /* Leave a mark so we know to safely unload below. */ + data->offset = NULL; return error; + } ms.intval = *data->offset; MOD_XLOCK; module_setspecific(mod, &ms); @@ -108,6 +111,13 @@ return error; case MOD_UNLOAD : + /* + * MOD_LOAD failed, so just return without calling the + * chained handler since we didn't pass along the MOD_LOAD + * event. + */ + if (data->offset == NULL) + return (0); if (data->chainevh) { error = data->chainevh(mod, what, data->chainarg); if (error) ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_sysctl.c#6 (text+ko) ==== @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_sysctl.c,v 1.165.2.3 2006/03/01 21:08:53 andre Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_sysctl.c,v 1.165.2.4 2006/08/07 10:12:56 yar Exp $"); #include "opt_compat.h" #include "opt_mac.h" @@ -1135,10 +1135,6 @@ /* * Wire the user space destination buffer. If set to a value greater than * zero, the len parameter limits the maximum amount of wired memory. - * - * XXX - The len parameter is currently ignored due to the lack of - * a place to save it in the sysctl_req structure so that the matching - * amount of memory can be unwired in the sysctl exit code. */ int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len) ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/sched_hier.c#7 (text+ko) ==== ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_autoconf.c#5 (text+ko) ==== @@ -35,10 +35,12 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/subr_autoconf.c,v 1.22 2005/01/06 23:35:39 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_autoconf.c,v 1.22.2.1 2006/07/31 18:53:55 jhb Exp $"); #include <sys/param.h> #include <sys/kernel.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/systm.h> /* @@ -50,26 +52,32 @@ */ static TAILQ_HEAD(, intr_config_hook) intr_config_hook_list = TAILQ_HEAD_INITIALIZER(intr_config_hook_list); - +static struct mtx intr_config_hook_lock; +MTX_SYSINIT(intr_config_hook, &intr_config_hook_lock, "intr config", MTX_DEF); /* ARGSUSED */ static void run_interrupt_driven_config_hooks(void *dummy); + static void run_interrupt_driven_config_hooks(dummy) void *dummy; { struct intr_config_hook *hook_entry, *next_entry; - for (hook_entry = TAILQ_FIRST(&intr_config_hook_list); - hook_entry != NULL; - hook_entry = next_entry) { + mtx_lock(&intr_config_hook_lock); + TAILQ_FOREACH_SAFE(hook_entry, &intr_config_hook_list, ich_links, + next_entry) { next_entry = TAILQ_NEXT(hook_entry, ich_links); + mtx_unlock(&intr_config_hook_lock); (*hook_entry->ich_func)(hook_entry->ich_arg); + mtx_lock(&intr_config_hook_lock); } while (!TAILQ_EMPTY(&intr_config_hook_list)) { - tsleep(&intr_config_hook_list, PCONFIG, "conifhk", 0); + msleep(&intr_config_hook_list, &intr_config_hook_lock, PCONFIG, + "conifhk", 0); } + mtx_unlock(&intr_config_hook_lock); } SYSINIT(intr_config_hooks, SI_SUB_INT_CONFIG_HOOKS, SI_ORDER_FIRST, run_interrupt_driven_config_hooks, NULL) @@ -85,17 +93,18 @@ { struct intr_config_hook *hook_entry; - for (hook_entry = TAILQ_FIRST(&intr_config_hook_list); - hook_entry != NULL; - hook_entry = TAILQ_NEXT(hook_entry, ich_links)) + mtx_lock(&intr_config_hook_lock); + TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) if (hook_entry == hook) break; if (hook_entry != NULL) { + mtx_unlock(&intr_config_hook_lock); printf("config_intrhook_establish: establishing an " "already established hook.\n"); return (1); } TAILQ_INSERT_TAIL(&intr_config_hook_list, hook, ich_links); + mtx_unlock(&intr_config_hook_lock); if (cold == 0) /* XXX Sufficient for modules loaded after initial config??? */ run_interrupt_driven_config_hooks(NULL); @@ -108,9 +117,8 @@ { struct intr_config_hook *hook_entry; - for (hook_entry = TAILQ_FIRST(&intr_config_hook_list); - hook_entry != NULL; - hook_entry = TAILQ_NEXT(hook_entry, ich_links)) + mtx_lock(&intr_config_hook_lock); + TAILQ_FOREACH(hook_entry, &intr_config_hook_list, ich_links) if (hook_entry == hook) break; if (hook_entry == NULL) @@ -118,6 +126,8 @@ "unestablished hook"); TAILQ_REMOVE(&intr_config_hook_list, hook, ich_links); + /* Wakeup anyone watching the list */ wakeup(&intr_config_hook_list); + mtx_unlock(&intr_config_hook_lock); } ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_turnstile.c#5 (text+ko) ==== @@ -59,7 +59,7 @@ #include "opt_turnstile_profiling.h" #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/subr_turnstile.c,v 1.152.2.2 2006/04/05 21:15:19 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_turnstile.c,v 1.152.2.3 2006/08/01 17:40:13 jhb Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -334,6 +334,7 @@ NULL, MTX_SPIN); } mtx_init(&td_contested_lock, "td_contested", NULL, MTX_SPIN); + LIST_INIT(&thread0.td_contested); thread0.td_turnstile = NULL; } ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_witness.c#5 (text+ko) ==== @@ -82,7 +82,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.195.2.9 2006/04/19 15:45:29 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.195.2.10 2006/08/01 17:40:13 jhb Exp $"); #include "opt_ddb.h" #include "opt_witness.h" @@ -511,7 +511,7 @@ TAILQ_FOREACH(lock, &all_locks, lo_list) { if (lock->lo_flags & LO_WITNESS) lock->lo_witness = enroll(lock->lo_type, - lock->lo_class); + LOCK_CLASS(lock)); else lock->lo_witness = NULL; } @@ -549,10 +549,7 @@ { struct lock_class *class; - class = lock->lo_class; - if (lock->lo_flags & LO_INITIALIZED) - panic("%s: lock (%s) %s is already initialized", __func__, - class->lc_name, lock->lo_name); + class = LOCK_CLASS(lock); if ((lock->lo_flags & LO_RECURSABLE) != 0 && (class->lc_flags & LC_RECURSABLE) == 0) panic("%s: lock (%s) %s can not be recursable", __func__, @@ -568,7 +565,6 @@ mtx_lock(&all_mtx); TAILQ_INSERT_TAIL(&all_locks, lock, lo_list); - lock->lo_flags |= LO_INITIALIZED; lock_cur_cnt++; if (lock_cur_cnt > lock_max_cnt) lock_max_cnt = lock_cur_cnt; @@ -583,14 +579,13 @@ void witness_destroy(struct lock_object *lock) { + struct lock_class *class; struct witness *w; + class = LOCK_CLASS(lock); if (witness_cold) panic("lock (%s) %s destroyed while witness_cold", - lock->lo_class->lc_name, lock->lo_name); - if ((lock->lo_flags & LO_INITIALIZED) == 0) - panic("%s: lock (%s) %s is not initialized", __func__, - lock->lo_class->lc_name, lock->lo_name); + class->lc_name, lock->lo_name); /* XXX: need to verify that no one holds the lock */ w = lock->lo_witness; @@ -610,7 +605,6 @@ mtx_lock(&all_mtx); lock_cur_cnt--; TAILQ_REMOVE(&all_locks, lock, lo_list); - lock->lo_flags &= ~LO_INITIALIZED; mtx_unlock(&all_mtx); } @@ -822,7 +816,7 @@ __func__); w = lock->lo_witness; - class = lock->lo_class; + class = LOCK_CLASS(lock); td = curthread; file = fixup_filename(file); @@ -1102,7 +1096,7 @@ file = fixup_filename(file); /* Determine lock list for this lock. */ - if (lock->lo_class->lc_flags & LC_SLEEPLOCK) + if (LOCK_CLASS(lock)->lc_flags & LC_SLEEPLOCK) lock_list = &td->td_sleeplocks; else lock_list = PCPU_PTR(spinlocks); @@ -1155,7 +1149,7 @@ KASSERT(!witness_cold, ("%s: witness_cold", __func__)); if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL) return; - class = lock->lo_class; + class = LOCK_CLASS(lock); file = fixup_filename(file); if ((lock->lo_flags & LO_UPGRADABLE) == 0) panic("upgrade of non-upgradable lock (%s) %s @ %s:%d", @@ -1163,7 +1157,7 @@ if ((flags & LOP_TRYLOCK) == 0) panic("non-try upgrade of lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); - if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) + if ((class->lc_flags & LC_SLEEPLOCK) == 0) panic("upgrade of non-sleep lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); instance = find_instance(curthread->td_sleeplocks, lock); @@ -1190,12 +1184,12 @@ KASSERT(!witness_cold, ("%s: witness_cold", __func__)); if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL) return; - class = lock->lo_class; + class = LOCK_CLASS(lock); file = fixup_filename(file); if ((lock->lo_flags & LO_UPGRADABLE) == 0) panic("downgrade of non-upgradable lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); - if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) + if ((class->lc_flags & LC_SLEEPLOCK) == 0) panic("downgrade of non-sleep lock (%s) %s @ %s:%d", class->lc_name, lock->lo_name, file, line); instance = find_instance(curthread->td_sleeplocks, lock); @@ -1226,7 +1220,7 @@ panicstr != NULL) return; td = curthread; - class = lock->lo_class; + class = LOCK_CLASS(lock); file = fixup_filename(file); /* Find lock instance associated with this lock. */ @@ -1737,7 +1731,7 @@ lock = instance->li_lock; printf("%s %s %s", (instance->li_flags & LI_EXCLUSIVE) != 0 ? - "exclusive" : "shared", lock->lo_class->lc_name, lock->lo_name); + "exclusive" : "shared", LOCK_CLASS(lock)->lc_name, lock->lo_name); if (lock->lo_type != lock->lo_name) printf(" (%s)", lock->lo_type); printf(" r = %d (%p) locked @ %s:%d\n", @@ -1805,18 +1799,25 @@ void witness_save(struct lock_object *lock, const char **filep, int *linep) { + struct lock_list_entry *lock_list; struct lock_instance *instance; + struct lock_class *class; KASSERT(!witness_cold, ("%s: witness_cold", __func__)); if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL) return; - if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) - panic("%s: lock (%s) %s is not a sleep lock", __func__, - lock->lo_class->lc_name, lock->lo_name); - instance = find_instance(curthread->td_sleeplocks, lock); + class = LOCK_CLASS(lock); + if (class->lc_flags & LC_SLEEPLOCK) + lock_list = curthread->td_sleeplocks; + else { + if (witness_skipspin) + return; + lock_list = PCPU_GET(spinlocks); + } + instance = find_instance(lock_list, lock); if (instance == NULL) panic("%s: lock (%s) %s not locked", __func__, - lock->lo_class->lc_name, lock->lo_name); + class->lc_name, lock->lo_name); *filep = instance->li_file; *linep = instance->li_line; } @@ -1824,18 +1825,25 @@ void witness_restore(struct lock_object *lock, const char *file, int line) { + struct lock_list_entry *lock_list; struct lock_instance *instance; + struct lock_class *class; KASSERT(!witness_cold, ("%s: witness_cold", __func__)); if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL) return; - if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) == 0) - panic("%s: lock (%s) %s is not a sleep lock", __func__, - lock->lo_class->lc_name, lock->lo_name); - instance = find_instance(curthread->td_sleeplocks, lock); + class = LOCK_CLASS(lock); + if (class->lc_flags & LC_SLEEPLOCK) + lock_list = curthread->td_sleeplocks; + else { + if (witness_skipspin) + return; + lock_list = PCPU_GET(spinlocks); + } + instance = find_instance(lock_list, lock); if (instance == NULL) panic("%s: lock (%s) %s not locked", __func__, - lock->lo_class->lc_name, lock->lo_name); + class->lc_name, lock->lo_name); lock->lo_witness->w_file = file; lock->lo_witness->w_line = line; instance->li_file = file; @@ -1847,23 +1855,25 @@ { #ifdef INVARIANT_SUPPORT struct lock_instance *instance; + struct lock_class *class; if (lock->lo_witness == NULL || witness_watch == 0 || panicstr != NULL) return; - if ((lock->lo_class->lc_flags & LC_SLEEPLOCK) != 0) + class = LOCK_CLASS(lock); + if ((class->lc_flags & LC_SLEEPLOCK) != 0) instance = find_instance(curthread->td_sleeplocks, lock); - else if ((lock->lo_class->lc_flags & LC_SPINLOCK) != 0) + else if ((class->lc_flags & LC_SPINLOCK) != 0) instance = find_instance(PCPU_GET(spinlocks), lock); else { panic("Lock (%s) %s is not sleep or spin!", - lock->lo_class->lc_name, lock->lo_name); + class->lc_name, lock->lo_name); } file = fixup_filename(file); switch (flags) { case LA_UNLOCKED: if (instance != NULL) panic("Lock (%s) %s locked @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); break; case LA_LOCKED: case LA_LOCKED | LA_RECURSED: @@ -1876,25 +1886,25 @@ case LA_XLOCKED | LA_NOTRECURSED: if (instance == NULL) { panic("Lock (%s) %s not locked @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); break; } if ((flags & LA_XLOCKED) != 0 && (instance->li_flags & LI_EXCLUSIVE) == 0) panic("Lock (%s) %s not exclusively locked @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); if ((flags & LA_SLOCKED) != 0 && (instance->li_flags & LI_EXCLUSIVE) != 0) panic("Lock (%s) %s exclusively locked @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); if ((flags & LA_RECURSED) != 0 && (instance->li_flags & LI_RECURSEMASK) == 0) panic("Lock (%s) %s not recursed @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); if ((flags & LA_NOTRECURSED) != 0 && (instance->li_flags & LI_RECURSEMASK) != 0) panic("Lock (%s) %s recursed @ %s:%d.", - lock->lo_class->lc_name, lock->lo_name, file, line); + class->lc_name, lock->lo_name, file, line); break; default: panic("Invalid lock assertion at %s:%d.", file, line); ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/kernel.h#5 (text+ko) ==== @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * @(#)kernel.h 8.3 (Berkeley) 1/21/94 - * $FreeBSD: src/sys/sys/kernel.h,v 1.126.2.1 2005/11/12 20:55:59 csjp Exp $ + * $FreeBSD: src/sys/sys/kernel.h,v 1.126.2.2 2006/08/11 19:23:49 jhb Exp $ */ #ifndef _SYS_KERNEL_H_ @@ -160,6 +160,7 @@ SI_SUB_MOUNT_ROOT = 0xb400000, /* root mount*/ SI_SUB_SWAP = 0xc000000, /* swap */ SI_SUB_INTRINSIC_POST = 0xd000000, /* proc 0 cleanup*/ + SI_SUB_SYSCALLS = 0xd800000, /* register system calls */ SI_SUB_KTHREAD_INIT = 0xe000000, /* init process*/ SI_SUB_KTHREAD_PAGE = 0xe400000, /* pageout daemon*/ SI_SUB_KTHREAD_VM = 0xe800000, /* vm daemon*/ ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/lock.h#5 (text+ko) ==== @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD: src/sys/sys/lock.h,v 1.52.2.1 2005/12/20 19:28:24 jhb Exp $ + * $FreeBSD: src/sys/sys/lock.h,v 1.52.2.2 2006/08/01 17:40:13 jhb Exp $ */ #ifndef _SYS_LOCK_H_ @@ -68,6 +68,8 @@ #define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */ #define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */ +#define LOCK_CLASS(lock) ((lock)->lo_class) + #define LI_RECURSEMASK 0x0000ffff /* Recursion depth of lock instance. */ #define LI_EXCLUSIVE 0x00010000 /* Exclusive lock instance. */ @@ -165,25 +167,27 @@ #define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ if (LOCK_LOG_TEST((lo), (flags))) \ CTR5(KTR_LOCK, opname " (%s) %s r = %d at %s:%d", \ - (lo)->lo_class->lc_name, (lo)->lo_name, \ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ (u_int)(recurse), (file), (line)); \ } while (0) #define LOCK_LOG_TRY(opname, lo, flags, result, file, line) do { \ if (LOCK_LOG_TEST((lo), (flags))) \ CTR5(KTR_LOCK, "TRY_" opname " (%s) %s result=%d at %s:%d",\ - (lo)->lo_class->lc_name, (lo)->lo_name, \ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ (u_int)(result), (file), (line)); \ } while (0) #define LOCK_LOG_INIT(lo, flags) do { \ if (LOCK_LOG_TEST((lo), (flags))) \ CTR4(KTR_LOCK, "%s: %p (%s) %s", __func__, (lo), \ - (lo)->lo_class->lc_name, (lo)->lo_name); \ + LOCK_CLASS(lo)->lc_name, (lo)->lo_name); \ } while (0) #define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) +#define lock_initalized(lo) ((lo)->lo_flags & LO_INITIALIZED) + /* * Helpful macros for quickly coming up with assertions with informative * panic messages. @@ -198,6 +202,9 @@ extern struct lock_class lock_class_mtx_spin; extern struct lock_class lock_class_sx; +void lock_init(struct lock_object *lock, struct lock_class *class, + const char *name, const char *type, int flags); +void lock_destroy(struct lock_object *lock); void spinlock_enter(void); void spinlock_exit(void); void witness_init(struct lock_object *); @@ -269,8 +276,8 @@ witness_line(lock) #else /* WITNESS */ -#define WITNESS_INIT(lock) ((lock)->lo_flags |= LO_INITIALIZED) -#define WITNESS_DESTROY(lock) ((lock)->lo_flags &= ~LO_INITIALIZED) +#define WITNESS_INIT(lock) +#define WITNESS_DESTROY(lock) #define WITNESS_DEFINEORDER(lock1, lock2) 0 #define WITNESS_CHECKORDER(lock, flags, file, line) #define WITNESS_LOCK(lock, flags, file, line) ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/mutex.h#5 (text+ko) ==== @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ - * $FreeBSD: src/sys/sys/mutex.h,v 1.79.2.2 2005/08/05 20:21:46 jhb Exp $ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608130103.k7D13O2X014685>