summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_task.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2013-12-10 17:08:01 +0000
committerkettenis <kettenis@openbsd.org>2013-12-10 17:08:01 +0000
commit4e29e7ad95cf5d3ec044bff5c35f1eb912300b5d (patch)
tree9e28c5c2f3436350fd91cd322d8b8642404c7beb /sys/kern/kern_task.c
parentOops. Missed file. (diff)
downloadwireguard-openbsd-4e29e7ad95cf5d3ec044bff5c35f1eb912300b5d.tar.xz
wireguard-openbsd-4e29e7ad95cf5d3ec044bff5c35f1eb912300b5d.zip
Add infrastructure to create un-biglocked task queues. Stolen from blambert@
who is slacking to much. ok dlg@
Diffstat (limited to 'sys/kern/kern_task.c')
-rw-r--r--sys/kern/kern_task.c16
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);