Date: Wed, 26 Jul 2006 08:16:51 GMT From: Chris Jones <cdjones@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 102438 for review Message-ID: <200607260816.k6Q8GpIr079711@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102438 Change 102438 by cdjones@cdjones-impulse on 2006/07/26 08:16:11 Bring VM tree in for slotting memory limits in. While at it, update the rest of the tree as req'd. Affected files ... .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/bus_if.m#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_synch.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_bus.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_taskqueue.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/sysv_shm.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/uipc_usrreq.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/vfs_subr.c#6 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/kern/vfs_vnops.c#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/bus.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/gpt.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/param.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/sysctl.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/systm.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/sys/taskqueue.h#5 integrate .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/default_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/device_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/memguard.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/memguard.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/phys_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/pmap.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/swap_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/swap_pager.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/uma.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/uma_core.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/uma_dbg.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/uma_dbg.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/uma_int.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_contig.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_extern.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_fault.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_glue.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_init.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_kern.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_kern.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_map.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_map.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_meter.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_mmap.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_object.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_object.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_page.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_page.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_pageout.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_pageq.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_pager.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_param.h#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_unix.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vm_zeroidle.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vnode_pager.c#1 branch .. //depot/projects/soc2006/cdjones_jail/src/sys/vm/vnode_pager.h#1 branch Differences ... ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/bus_if.m#5 (text+ko) ==== @@ -23,7 +23,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/sys/kern/bus_if.m,v 1.29 2005/01/06 23:35:38 imp Exp $ +# $FreeBSD: src/sys/kern/bus_if.m,v 1.29.2.1 2006/07/12 22:57:57 imp Exp $ # #include <sys/bus.h> @@ -507,3 +507,25 @@ enum intr_trigger _trig; enum intr_polarity _pol; } DEFAULT bus_generic_config_intr; + +/** + * @brief Notify a (bus) driver about a child that the hints mechanism + * believes it has discovered. + * + * The bus is responsible for then adding the child in the right order + * and discovering other things about the child. The bus driver is + * free to ignore this hint, to do special things, etc. It is all up + * to the bus driver to interpret. + * + * This method is only called in response to the parent bus asking for + * hinted devices to be enumerated. + * + * @param _dev the bus device + * @param _dname the name of the device w/o unit numbers + * @param _dunit the unit number of the device + */ +METHOD void hinted_child { + device_t _dev; + const char * _dname; + int _dunit; +}; ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/kern_synch.c#6 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/kern_synch.c,v 1.270.2.5 2006/06/16 22:11:55 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/kern_synch.c,v 1.270.2.6 2006/07/06 08:32:50 glebius Exp $"); #include "opt_ktrace.h" @@ -223,6 +223,88 @@ return (rval); } +int +msleep_spin(ident, mtx, wmesg, timo) + void *ident; + struct mtx *mtx; + const char *wmesg; + int timo; +{ + struct thread *td; + struct proc *p; + int rval; + WITNESS_SAVE_DECL(mtx); + + td = curthread; + p = td->td_proc; + KASSERT(mtx != NULL, ("sleeping without a mutex")); + KASSERT(p != NULL, ("msleep1")); + KASSERT(ident != NULL && TD_IS_RUNNING(td), ("msleep")); + + if (cold) { + /* + * During autoconfiguration, just return; + * don't run any other threads or panic below, + * in case this is the idle thread and already asleep. + * XXX: this used to do "s = splhigh(); splx(safepri); + * splx(s);" to give interrupts a chance, but there is + * no way to give interrupts a chance now. + */ + return (0); + } + + sleepq_lock(ident); + CTR5(KTR_PROC, "msleep_spin: thread %p (pid %ld, %s) on %s (%p)", + (void *)td, (long)p->p_pid, p->p_comm, wmesg, ident); + + DROP_GIANT(); + mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED); + WITNESS_SAVE(&mtx->mtx_object, mtx); + mtx_unlock_spin(mtx); + + /* + * We put ourselves on the sleep queue and start our timeout. + */ + sleepq_add(ident, mtx, wmesg, SLEEPQ_MSLEEP); + if (timo) + sleepq_set_timeout(ident, timo); + + /* + * Can't call ktrace with any spin locks held so it can lock the + * ktrace_mtx lock, and WITNESS_WARN considers it an error to hold + * any spin lock. Thus, we have to drop the sleepq spin lock while + * we handle those requests. This is safe since we have placed our + * thread on the sleep queue already. + */ +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) { + sleepq_release(ident); + ktrcsw(1, 0); + sleepq_lock(ident); + } +#endif +#ifdef WITNESS + sleepq_release(ident); + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "Sleeping on \"%s\"", + wmesg); + sleepq_lock(ident); +#endif + if (timo) + rval = sleepq_timedwait(ident); + else { + sleepq_wait(ident); + rval = 0; + } +#ifdef KTRACE + if (KTRPOINT(td, KTR_CSW)) + ktrcsw(0, 0); +#endif + PICKUP_GIANT(); + mtx_lock_spin(mtx); + WITNESS_RESTORE(&mtx->mtx_object, mtx); + return (rval); +} + /* * Make all threads sleeping on the specified identifier runnable. */ ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_bus.c#6 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/subr_bus.c,v 1.184.2.1 2005/10/06 23:15:18 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_bus.c,v 1.184.2.3 2006/07/15 22:53:53 njl Exp $"); #include "opt_bus.h" @@ -3556,7 +3556,19 @@ return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen)); } +/* Resume all devices and then notify userland that we're up again. */ static int +root_resume(device_t dev) +{ + int error; + + error = bus_generic_resume(dev); + if (error == 0) + devctl_notify("kern", "power", "resume", NULL); + return (error); +} + +static int root_print_child(device_t dev, device_t child) { int retval = 0; @@ -3594,7 +3606,7 @@ /* Device interface */ KOBJMETHOD(device_shutdown, bus_generic_shutdown), KOBJMETHOD(device_suspend, bus_generic_suspend), - KOBJMETHOD(device_resume, bus_generic_resume), + KOBJMETHOD(device_resume, root_resume), /* Bus interface */ KOBJMETHOD(bus_print_child, root_print_child), @@ -3745,6 +3757,40 @@ return (error); } +/** + * @brief Enumerate all hinted devices for this bus. + * + * Walks throught he hints for this bus and calls the bus_hinted_child + * routine for each one it fines. It searches first for the specific + * bus that's being probed for hinted children (eg isa0), and then for + * generic children (eg isa). + * + * @param dev bus device to enumerate + */ +void +bus_enumerate_hinted_children(device_t bus) +{ + int i; + const char *dname, *busname; + int dunit; + + /* + * enumerate all devices on the specific bus + */ + busname = device_get_nameunit(bus); + i = 0; + while (resource_find_match(&i, &dname, &dunit, "at", busname) == 0) + BUS_HINTED_CHILD(bus, dname, dunit); + + /* + * and all the generic ones. + */ + busname = device_get_name(bus); + i = 0; + while (resource_find_match(&i, &dname, &dunit, "at", busname) == 0) + BUS_HINTED_CHILD(bus, dname, dunit); +} + #ifdef BUS_DEBUG /* the _short versions avoid iteration by not calling anything that prints ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/subr_taskqueue.c#5 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/subr_taskqueue.c,v 1.27.2.3 2006/04/02 00:14:57 sam Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/subr_taskqueue.c,v 1.27.2.4 2006/07/06 08:32:50 glebius Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -37,8 +37,10 @@ #include <sys/malloc.h> #include <sys/mutex.h> #include <sys/proc.h> +#include <sys/sched.h> #include <sys/taskqueue.h> #include <sys/unistd.h> +#include <machine/stdarg.h> static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues"); static void *taskqueue_giant_ih; @@ -55,10 +57,42 @@ struct task *tq_running; struct mtx tq_mutex; struct proc **tq_pproc; + int tq_pcount; + int tq_spin; + int tq_flags; }; +#define TQ_FLAGS_ACTIVE (1 << 0) + +static __inline void +TQ_LOCK(struct taskqueue *tq) +{ + if (tq->tq_spin) + mtx_lock_spin(&tq->tq_mutex); + else + mtx_lock(&tq->tq_mutex); +} + +static __inline void +TQ_UNLOCK(struct taskqueue *tq) +{ + if (tq->tq_spin) + mtx_unlock_spin(&tq->tq_mutex); + else + mtx_unlock(&tq->tq_mutex); +} + static void init_taskqueue_list(void *data); +static __inline int +TQ_SLEEP(struct taskqueue *tq, void *p, struct mtx *m, int pri, const char *wm, + int t) +{ + if (tq->tq_spin) + return (msleep_spin(p, m, wm, t)); + return (msleep(p, m, pri, wm, t)); +} + static void init_taskqueue_list(void *data __unused) { @@ -69,10 +103,10 @@ SYSINIT(taskqueue_list, SI_SUB_INTRINSIC, SI_ORDER_ANY, init_taskqueue_list, NULL); -struct taskqueue * -taskqueue_create(const char *name, int mflags, +static struct taskqueue * +_taskqueue_create(const char *name, int mflags, taskqueue_enqueue_fn enqueue, void *context, - struct proc **pp) + int mtxflags, const char *mtxname) { struct taskqueue *queue; @@ -84,8 +118,9 @@ queue->tq_name = name; queue->tq_enqueue = enqueue; queue->tq_context = context; - queue->tq_pproc = pp; - mtx_init(&queue->tq_mutex, "taskqueue", NULL, MTX_DEF); + queue->tq_spin = (mtxflags & MTX_SPIN) != 0; + queue->tq_flags |= TQ_FLAGS_ACTIVE; + mtx_init(&queue->tq_mutex, mtxname, NULL, mtxflags); mtx_lock(&taskqueue_queues_mutex); STAILQ_INSERT_TAIL(&taskqueue_queues, queue, tq_link); @@ -94,23 +129,26 @@ return queue; } +struct taskqueue * +taskqueue_create(const char *name, int mflags, + taskqueue_enqueue_fn enqueue, void *context, + struct proc **pp) +{ + (void) pp; + return _taskqueue_create(name, mflags, enqueue, context, + MTX_DEF, "taskqueue"); +} + /* * Signal a taskqueue thread to terminate. */ static void taskqueue_terminate(struct proc **pp, struct taskqueue *tq) { - struct proc *p; - p = *pp; - *pp = NULL; - if (p) { - wakeup_one(tq); - PROC_LOCK(p); /* NB: insure we don't miss wakeup */ - mtx_unlock(&tq->tq_mutex); /* let taskqueue thread run */ - msleep(p, &p->p_mtx, PWAIT, "taskqueue_destroy", 0); - PROC_UNLOCK(p); - mtx_lock(&tq->tq_mutex); + while (tq->tq_pcount > 0) { + wakeup(tq); + TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); } } @@ -122,10 +160,12 @@ STAILQ_REMOVE(&taskqueue_queues, queue, taskqueue, tq_link); mtx_unlock(&taskqueue_queues_mutex); - mtx_lock(&queue->tq_mutex); + TQ_LOCK(queue); + queue->tq_flags &= ~TQ_FLAGS_ACTIVE; taskqueue_run(queue); taskqueue_terminate(queue->tq_pproc, queue); mtx_destroy(&queue->tq_mutex); + free(queue->tq_pproc, M_TASKQUEUE); free(queue, M_TASKQUEUE); } @@ -140,7 +180,7 @@ mtx_lock(&taskqueue_queues_mutex); STAILQ_FOREACH(queue, &taskqueue_queues, tq_link) { if (strcmp(queue->tq_name, name) == 0) { - mtx_lock(&queue->tq_mutex); + TQ_LOCK(queue); mtx_unlock(&taskqueue_queues_mutex); return queue; } @@ -155,14 +195,14 @@ struct task *ins; struct task *prev; - mtx_lock(&queue->tq_mutex); + TQ_LOCK(queue); /* * Count multiple enqueues. */ if (task->ta_pending) { task->ta_pending++; - mtx_unlock(&queue->tq_mutex); + TQ_UNLOCK(queue); return 0; } @@ -188,7 +228,7 @@ task->ta_pending = 1; queue->tq_enqueue(queue->tq_context); - mtx_unlock(&queue->tq_mutex); + TQ_UNLOCK(queue); return 0; } @@ -201,7 +241,7 @@ owned = mtx_owned(&queue->tq_mutex); if (!owned) - mtx_lock(&queue->tq_mutex); + TQ_LOCK(queue); while (STAILQ_FIRST(&queue->tq_queue)) { /* * Carefully remove the first task from the queue and @@ -212,11 +252,11 @@ pending = task->ta_pending; task->ta_pending = 0; queue->tq_running = task; - mtx_unlock(&queue->tq_mutex); + TQ_UNLOCK(queue); task->ta_func(task->ta_context, pending); - mtx_lock(&queue->tq_mutex); + TQ_LOCK(queue); queue->tq_running = NULL; wakeup(task); } @@ -226,18 +266,25 @@ * on entry, although this opens a race window. */ if (!owned) - mtx_unlock(&queue->tq_mutex); + TQ_UNLOCK(queue); } void taskqueue_drain(struct taskqueue *queue, struct task *task) { - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "taskqueue_drain"); + if (queue->tq_spin) { /* XXX */ + mtx_lock_spin(&queue->tq_mutex); + while (task->ta_pending != 0 || task == queue->tq_running) + msleep_spin(task, &queue->tq_mutex, "-", 0); + mtx_unlock_spin(&queue->tq_mutex); + } else { + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__); - mtx_lock(&queue->tq_mutex); - while (task->ta_pending != 0 || task == queue->tq_running) - msleep(task, &queue->tq_mutex, PWAIT, "-", 0); - mtx_unlock(&queue->tq_mutex); + mtx_lock(&queue->tq_mutex); + while (task->ta_pending != 0 || task == queue->tq_running) + msleep(task, &queue->tq_mutex, PWAIT, "-", 0); + mtx_unlock(&queue->tq_mutex); + } } static void @@ -264,6 +311,43 @@ taskqueue_run(taskqueue_swi_giant); } +int +taskqueue_start_threads(struct taskqueue **tqp, int count, int pri, + const char *name, ...) +{ + va_list ap; + struct taskqueue *tq; + char ktname[MAXCOMLEN]; + int i; + + if (count <= 0) + return (EINVAL); + tq = *tqp; + + if ((tq->tq_pproc = malloc(sizeof(struct proc *) * count, M_TASKQUEUE, + M_NOWAIT | M_ZERO)) == NULL) + return (ENOMEM); + + va_start(ap, name); + vsnprintf(ktname, MAXCOMLEN, name, ap); + va_end(ap); + + for (i = 0; i < count; i++) { + if (count == 1) + kthread_create(taskqueue_thread_loop, tqp, + &tq->tq_pproc[i], 0, 0, ktname); + else + kthread_create(taskqueue_thread_loop, tqp, + &tq->tq_pproc[i], 0, 0, "%s_%d", ktname, i); + mtx_lock_spin(&sched_lock); + sched_prio(FIRST_THREAD_IN_PROC(tq->tq_pproc[i]), pri); + mtx_unlock_spin(&sched_lock); + tq->tq_pcount++; + } + + return (0); +} + void taskqueue_thread_loop(void *arg) { @@ -271,15 +355,16 @@ tqp = arg; tq = *tqp; - mtx_lock(&tq->tq_mutex); + TQ_LOCK(tq); do { taskqueue_run(tq); - msleep(tq, &tq->tq_mutex, PWAIT, "-", 0); - } while (*tq->tq_pproc != NULL); + TQ_SLEEP(tq, tq, &tq->tq_mutex, curthread->td_priority, "-", 0); + } while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0); /* rendezvous with thread that asked us to terminate */ - wakeup_one(tq); - mtx_unlock(&tq->tq_mutex); + tq->tq_pcount--; + wakeup_one(tq->tq_pproc); + TQ_UNLOCK(tq); kthread_exit(0); } @@ -300,85 +385,30 @@ INTR_MPSAFE, &taskqueue_ih)); TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, 0, - swi_add(NULL, "Giant task queue", taskqueue_swi_giant_run, + swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run, NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)); TASKQUEUE_DEFINE_THREAD(thread); -int -taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task) +struct taskqueue * +taskqueue_create_fast(const char *name, int mflags, + taskqueue_enqueue_fn enqueue, void *context) { - struct task *ins; - struct task *prev; - - mtx_lock_spin(&queue->tq_mutex); - - /* - * Count multiple enqueues. - */ - if (task->ta_pending) { - task->ta_pending++; - mtx_unlock_spin(&queue->tq_mutex); - return 0; - } - - /* - * Optimise the case when all tasks have the same priority. - */ - prev = STAILQ_LAST(&queue->tq_queue, task, ta_link); - if (!prev || prev->ta_priority >= task->ta_priority) { - STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); - } else { - prev = 0; - for (ins = STAILQ_FIRST(&queue->tq_queue); ins; - prev = ins, ins = STAILQ_NEXT(ins, ta_link)) - if (ins->ta_priority < task->ta_priority) - break; - - if (prev) - STAILQ_INSERT_AFTER(&queue->tq_queue, prev, task, ta_link); - else - STAILQ_INSERT_HEAD(&queue->tq_queue, task, ta_link); - } - - task->ta_pending = 1; - queue->tq_enqueue(queue->tq_context); - - mtx_unlock_spin(&queue->tq_mutex); - - return 0; + return _taskqueue_create(name, mflags, enqueue, context, + MTX_SPIN, "fast_taskqueue"); } -static void -taskqueue_run_fast(struct taskqueue *queue) +/* NB: for backwards compatibility */ +int +taskqueue_enqueue_fast(struct taskqueue *queue, struct task *task) { - struct task *task; - int pending; - - mtx_lock_spin(&queue->tq_mutex); - while (STAILQ_FIRST(&queue->tq_queue)) { - /* - * Carefully remove the first task from the queue and - * zero its pending count. - */ - task = STAILQ_FIRST(&queue->tq_queue); - STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link); - pending = task->ta_pending; - task->ta_pending = 0; - mtx_unlock_spin(&queue->tq_mutex); - - task->ta_func(task->ta_context, pending); - - mtx_lock_spin(&queue->tq_mutex); - } - mtx_unlock_spin(&queue->tq_mutex); + return taskqueue_enqueue(queue, task); } -struct taskqueue *taskqueue_fast; static void *taskqueue_fast_ih; static void -taskqueue_fast_schedule(void *context) +taskqueue_fast_enqueue(void *context) { swi_sched(taskqueue_fast_ih, 0); } @@ -386,31 +416,9 @@ static void taskqueue_fast_run(void *dummy) { - taskqueue_run_fast(taskqueue_fast); + taskqueue_run(taskqueue_fast); } -static void -taskqueue_define_fast(void *arg) -{ - - taskqueue_fast = malloc(sizeof(struct taskqueue), M_TASKQUEUE, - M_NOWAIT | M_ZERO); - if (!taskqueue_fast) { - printf("%s: Unable to allocate fast task queue!\n", __func__); - return; - } - - STAILQ_INIT(&taskqueue_fast->tq_queue); - taskqueue_fast->tq_name = "fast"; - taskqueue_fast->tq_enqueue = taskqueue_fast_schedule; - mtx_init(&taskqueue_fast->tq_mutex, "taskqueue_fast", NULL, MTX_SPIN); - - mtx_lock(&taskqueue_queues_mutex); - STAILQ_INSERT_TAIL(&taskqueue_queues, taskqueue_fast, tq_link); - mtx_unlock(&taskqueue_queues_mutex); - - swi_add(NULL, "Fast task queue", taskqueue_fast_run, - NULL, SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih); -} -SYSINIT(taskqueue_fast, SI_SUB_CONFIGURE, SI_ORDER_SECOND, - taskqueue_define_fast, NULL); +TASKQUEUE_FAST_DEFINE(fast, taskqueue_fast_enqueue, 0, + swi_add(NULL, "Fast task queue", taskqueue_fast_run, NULL, + SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih)); ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/sysv_shm.c#6 (text+ko) ==== @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/sysv_shm.c,v 1.102.2.1 2006/05/15 18:47:52 ps Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/sysv_shm.c,v 1.102.2.2 2006/07/24 23:41:38 rwatson Exp $"); #include "opt_compat.h" #include "opt_sysvipc.h" @@ -732,12 +732,14 @@ } if ((uap->shmflg & (IPC_CREAT | IPC_EXCL)) == (IPC_CREAT | IPC_EXCL)) return (EEXIST); - error = ipcperm(td, &shmseg->u.shm_perm, mode); #ifdef MAC error = mac_check_sysv_shmget(td->td_ucred, shmseg, uap->shmflg); - if (error != 0) + if (error != 0) { MPRINTF(("mac_check_sysv_shmget returned %d\n", error)); + return (error); + } #endif + error = ipcperm(td, &shmseg->u.shm_perm, mode); if (error) return (error); if (uap->size && uap->size > shmseg->u.shm_segsz) ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/uipc_usrreq.c#6 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.155.2.5 2006/05/21 09:12:24 maxim Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.155.2.6 2006/07/13 13:42:37 maxim Exp $"); #include "opt_mac.h" @@ -1561,8 +1561,9 @@ struct mbuf * unp_addsockcred(struct thread *td, struct mbuf *control) { - struct mbuf *m, *n; + struct mbuf *m, *n, *n_prev; struct sockcred *sc; + const struct cmsghdr *cm; int ngroups; int i; @@ -1571,7 +1572,6 @@ m = sbcreatecontrol(NULL, SOCKCREDSIZE(ngroups), SCM_CREDS, SOL_SOCKET); if (m == NULL) return (control); - m->m_next = NULL; sc = (struct sockcred *) CMSG_DATA(mtod(m, struct cmsghdr *)); sc->sc_uid = td->td_ucred->cr_ruid; @@ -1583,16 +1583,30 @@ sc->sc_groups[i] = td->td_ucred->cr_groups[i]; /* - * If a control message already exists, append us to the end. + * Unlink SCM_CREDS control messages (struct cmsgcred), since + * just created SCM_CREDS control message (struct sockcred) has + * another format. */ - if (control != NULL) { - for (n = control; n->m_next != NULL; n = n->m_next) - ; - n->m_next = m; - } else - control = m; + if (control != NULL) + for (n = control, n_prev = NULL; n != NULL;) { + cm = mtod(n, struct cmsghdr *); + if (cm->cmsg_level == SOL_SOCKET && + cm->cmsg_type == SCM_CREDS) { + if (n_prev == NULL) + control = n->m_next; + else + n_prev->m_next = n->m_next; + n = m_free(n); + } else { + n_prev = n; + n = n->m_next; + } + } + + /* Prepend it to the head. */ + m->m_next = control; - return (control); + return (m); } /* ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/vfs_subr.c#6 (text+ko) ==== @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.635.2.18 2006/05/13 14:01:35 pjd Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_subr.c,v 1.635.2.19 2006/07/05 16:34:16 kib Exp $"); #include "opt_ddb.h" #include "opt_mac.h" @@ -790,6 +790,7 @@ VNASSERT(bo->bo_dirty.bv_root == NULL, vp, ("dirtyblkroot not NULL")); VNASSERT(TAILQ_EMPTY(&vp->v_cache_dst), vp, ("vp has namecache dst")); VNASSERT(LIST_EMPTY(&vp->v_cache_src), vp, ("vp has namecache src")); + VI_UNLOCK(vp); #ifdef MAC mac_destroy_vnode(vp); #endif ==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/vfs_vnops.c#5 (text+ko) ==== @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/vfs_vnops.c,v 1.233.2.2 2006/05/30 02:58:36 ps Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/vfs_vnops.c,v 1.233.2.3 2006/07/16 16:05:50 pjd Exp $"); #include "opt_mac.h" @@ -1070,23 +1070,19 @@ struct thread *td = curthread; int error; - error = 0; MNT_ILOCK(mp); - if (mp->mnt_kern_flag & MNTK_SUSPEND) - goto unlock; + if (mp->mnt_kern_flag & MNTK_SUSPEND) { + MNT_IUNLOCK(mp); + return (0); + } mp->mnt_kern_flag |= MNTK_SUSPEND; if (mp->mnt_writeopcount > 0) (void) msleep(&mp->mnt_writeopcount, MNT_MTX(mp), (PUSER - 1)|PDROP, "suspwt", 0); else MNT_IUNLOCK(mp); - if ((error = VFS_SYNC(mp, MNT_SUSPEND, td)) != 0) { + if ((error = VFS_SYNC(mp, MNT_SUSPEND, td)) != 0) vfs_write_resume(mp); - return (error); - } - MNT_ILOCK(mp); -unlock: - MNT_IUNLOCK(mp); return (error); } ==== //depot/projects/soc2006/cdjones_jail/src/sys/sys/bus.h#5 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/sys/bus.h,v 1.70 2005/04/12 15:20:36 imp Exp $ + * $FreeBSD: src/sys/sys/bus.h,v 1.70.2.2 2006/07/12 22:57:57 imp Exp $ */ #ifndef _SYS_BUS_H_ @@ -317,6 +317,7 @@ int bus_child_present(device_t child); int bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen); int bus_child_location_str(device_t child, char *buf, size_t buflen); +void bus_enumerate_hinted_children(device_t bus); static __inline struct resource * bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags) @@ -513,6 +514,141 @@ ivarp ## _IVAR_ ## ivar, v); \ } +/** + * Shorthand macros, taking resource argument + */ + +#define bus_barrier(r, o, l, f) \ + bus_space_barrier(rman_get_bustag(r), rman_get_bushandle(r), (o), (l), (f)) +#define bus_read_1(r, o) \ + bus_space_read_1(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_1(r, o, d, c) \ + bus_space_read_multi_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_1(r, o, d, c) \ + bus_space_read_region_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_1(r, o, v, c) \ + bus_space_set_multi_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_1(r, o, v, c) \ + bus_space_set_region_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_1(r, o, v) \ + bus_space_write_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_1(r, o, d, c) \ + bus_space_write_multi_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_1(r, o, d, c) \ + bus_space_write_region_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_stream_1(r, o) \ + bus_space_read_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_stream_1(r, o, d, c) \ + bus_space_read_multi_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_stream_1(r, o, d, c) \ + bus_space_read_region_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_stream_1(r, o, v, c) \ + bus_space_set_multi_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_stream_1(r, o, v, c) \ + bus_space_set_region_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_stream_1(r, o, v) \ + bus_space_write_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_stream_1(r, o, d, c) \ + bus_space_write_multi_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_stream_1(r, o, d, c) \ + bus_space_write_region_stream_1(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_2(r, o) \ + bus_space_read_2(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_2(r, o, d, c) \ + bus_space_read_multi_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_2(r, o, d, c) \ + bus_space_read_region_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_2(r, o, v, c) \ + bus_space_set_multi_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_2(r, o, v, c) \ + bus_space_set_region_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_2(r, o, v) \ + bus_space_write_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_2(r, o, d, c) \ + bus_space_write_multi_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_2(r, o, d, c) \ + bus_space_write_region_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_stream_2(r, o) \ + bus_space_read_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_stream_2(r, o, d, c) \ + bus_space_read_multi_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_stream_2(r, o, d, c) \ + bus_space_read_region_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_stream_2(r, o, v, c) \ + bus_space_set_multi_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_stream_2(r, o, v, c) \ + bus_space_set_region_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_stream_2(r, o, v) \ + bus_space_write_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_stream_2(r, o, d, c) \ + bus_space_write_multi_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_stream_2(r, o, d, c) \ + bus_space_write_region_stream_2(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_4(r, o) \ + bus_space_read_4(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_4(r, o, d, c) \ + bus_space_read_multi_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_4(r, o, d, c) \ + bus_space_read_region_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_4(r, o, v, c) \ + bus_space_set_multi_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_4(r, o, v, c) \ + bus_space_set_region_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_4(r, o, v) \ + bus_space_write_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_4(r, o, d, c) \ + bus_space_write_multi_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_4(r, o, d, c) \ + bus_space_write_region_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_stream_4(r, o) \ + bus_space_read_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o)) +#define bus_read_multi_stream_4(r, o, d, c) \ + bus_space_read_multi_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_region_stream_4(r, o, d, c) \ + bus_space_read_region_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_set_multi_stream_4(r, o, v, c) \ + bus_space_set_multi_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_set_region_stream_4(r, o, v, c) \ + bus_space_set_region_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v), (c)) +#define bus_write_stream_4(r, o, v) \ + bus_space_write_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (v)) +#define bus_write_multi_stream_4(r, o, d, c) \ + bus_space_write_multi_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_write_region_stream_4(r, o, d, c) \ + bus_space_write_region_stream_4(rman_get_bustag(r), rman_get_bushandle(r), (o), (d), (c)) +#define bus_read_8(r, o) \ >>> TRUNCATED FOR MAIL (1000 lines) <<<
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607260816.k6Q8GpIr079711>