diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2013-12-10 17:08:02 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2013-12-10 17:08:02 +0000 |
commit | 9161399ddeec8c9f32f47a1a521da4d510427ec8 (patch) | |
tree | 29ba389501734dec4649962ad2f1e21627467095 /sys | |
parent | cba22bd6c4765c855def800869b582ab1fa0d2aa (diff) |
Add infrastructure to create un-biglocked task queues. Stolen from blambert@
who is slacking to much.
ok dlg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_task.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/kern_task.c b/sys/kern/kern_task.c index 4299c1983f1..9e7aae936f3 100644 --- a/sys/kern/kern_task.c +++ b/sys/kern/kern_task.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_task.c,v 1.6 2013/11/18 20:21:51 deraadt Exp $ */ +/* $OpenBSD: kern_task.c,v 1.7 2013/12/10 17:08:01 kettenis Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> @@ -33,6 +33,7 @@ struct taskq { } tq_state; unsigned int tq_running; unsigned int tq_nthreads; + unsigned int tq_unlocked; const char *tq_name; struct mutex tq_mtx; @@ -43,6 +44,7 @@ struct taskq taskq_sys = { TQ_S_CREATED, 0, 1, + 0, "systq", MUTEX_INITIALIZER(IPL_HIGH), TAILQ_HEAD_INITIALIZER(taskq_sys.tq_worklist) @@ -75,6 +77,12 @@ taskq_create(const char *name, unsigned int nthreads, int ipl) tq->tq_nthreads = nthreads; tq->tq_name = name; + if (ipl & IPL_MPSAFE) + tq->tq_unlocked = 1; + else + tq->tq_unlocked = 0; + ipl &= IPL_MPSAFE; + mtx_init(&tq->tq_mtx, ipl); TAILQ_INIT(&tq->tq_worklist); @@ -238,6 +246,9 @@ taskq_thread(void *xtq) struct task work; int last; + if (tq->tq_unlocked) + KERNEL_UNLOCK(); + while (taskq_next_work(tq, &work)) (*work.t_func)(work.t_arg1, work.t_arg2); @@ -245,6 +256,9 @@ taskq_thread(void *xtq) last = (--tq->tq_running == 0); mtx_leave(&tq->tq_mtx); + if (tq->tq_unlocked) + KERNEL_LOCK(); + if (last) wakeup_one(&tq->tq_running); |