summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblambert <blambert@openbsd.org>2014-06-11 08:47:53 +0000
committerblambert <blambert@openbsd.org>2014-06-11 08:47:53 +0000
commit53eebcffbe73328a504152429840dbfa9d7c406f (patch)
tree74738dcdcbc0a5e0110511e9998326502a60ad9e
parentem(4) receives jumbos by chaining its MCLBYTES sized descriptors (diff)
downloadwireguard-openbsd-53eebcffbe73328a504152429840dbfa9d7c406f.tar.xz
wireguard-openbsd-53eebcffbe73328a504152429840dbfa9d7c406f.zip
Create system taskq ("systqmp") which runs without the kernel lock;
currently unused. ok dlg@ manpage improvement and ok jmc@
-rw-r--r--share/man/man9/task_add.918
-rw-r--r--sys/kern/kern_task.c14
-rw-r--r--sys/sys/task.h3
3 files changed, 26 insertions, 9 deletions
diff --git a/share/man/man9/task_add.9 b/share/man/man9/task_add.9
index a7a8ec9a36a..a5b516d2ff7 100644
--- a/share/man/man9/task_add.9
+++ b/share/man/man9/task_add.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: task_add.9,v 1.11 2014/04/02 13:19:01 mpi Exp $
+.\" $OpenBSD: task_add.9,v 1.12 2014/06/11 08:47:53 blambert Exp $
.\"
.\" Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 2 2014 $
+.Dd $Mdocdate: June 11 2014 $
.Dt TASK_ADD 9
.Os
.Sh NAME
@@ -38,6 +38,7 @@
.Ft int
.Fn "task_del" "struct taskq *tq" "struct task *t"
.Vt extern struct taskq *const systq;
+.Vt extern struct taskq *const systqmp;
.Fn "TASK_INITIALIZER" "void (*fn)(void *, void *)" "void *arg1" "void *arg2"
.Sh DESCRIPTION
The
@@ -125,12 +126,15 @@ against a different taskq than the one given in a previous call to
.Fn task_add
is an error and will lead to undefined behaviour.
.Pp
-The kernel provides a system taskq
-.Va systq
-that can be used by any subsystem for short lived tasks.
-It is serviced by a single thread and can therefore provide predictable
+The kernel provides two system taskqs:
+.Va systq ,
+which executes while holding the kernel lock, and
+.Va systqmp ,
+which does not hold the kernel lock during execution.
+They can both be used by any subsystem for short lived tasks.
+They are serviced by a single thread and can therefore provide predictable
ordering of work.
-Work can be scheduled on the system taskq from callers at or below IPL_HIGH.
+Work can be scheduled on the system taskqs from callers at or below IPL_HIGH.
.Pp
A task declaration can be initialised with the
.Fn TASK_INITIALIZER
diff --git a/sys/kern/kern_task.c b/sys/kern/kern_task.c
index 2ba2d990ec0..04592ad7f4e 100644
--- a/sys/kern/kern_task.c
+++ b/sys/kern/kern_task.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_task.c,v 1.8 2013/12/11 22:39:49 kettenis Exp $ */
+/* $OpenBSD: kern_task.c,v 1.9 2014/06/11 08:47:53 blambert Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
@@ -50,7 +50,18 @@ struct taskq taskq_sys = {
TAILQ_HEAD_INITIALIZER(taskq_sys.tq_worklist)
};
+struct taskq taskq_sys_mp = {
+ TQ_S_CREATED,
+ 0,
+ 1,
+ 1,
+ "systqmp",
+ MUTEX_INITIALIZER(IPL_HIGH),
+ TAILQ_HEAD_INITIALIZER(taskq_sys_mp.tq_worklist)
+};
+
struct taskq *const systq = &taskq_sys;
+struct taskq *const systqmp = &taskq_sys_mp;
void taskq_init(void); /* called in init_main.c */
void taskq_create_thread(void *);
@@ -61,6 +72,7 @@ void
taskq_init(void)
{
kthread_create_deferred(taskq_create_thread, systq);
+ kthread_create_deferred(taskq_create_thread, systqmp);
}
struct taskq *
diff --git a/sys/sys/task.h b/sys/sys/task.h
index 1691aef3650..fc19aa5f83d 100644
--- a/sys/sys/task.h
+++ b/sys/sys/task.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: task.h,v 1.5 2013/12/23 04:20:47 dlg Exp $ */
+/* $OpenBSD: task.h,v 1.6 2014/06/11 08:47:53 blambert Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
@@ -33,6 +33,7 @@ struct task {
#ifdef _KERNEL
extern struct taskq *const systq;
+extern struct taskq *const systqmp;
struct taskq *taskq_create(const char *, unsigned int, int);
void taskq_destroy(struct taskq *);