diff options
| author | 2018-07-05 14:42:30 +0000 | |
|---|---|---|
| committer | 2018-07-05 14:42:30 +0000 | |
| commit | 0fd5329e7ff3e902bc4a7d9b29554ad2fd4a3b0d (patch) | |
| tree | 6df6672c653a8ac8f842109b4caae75ebd5bad65 /sys/kern/kern_kthread.c | |
| parent | backout r1.11 "Add retguard macros for kernel asm", ok deraadt (diff) | |
| download | wireguard-openbsd-0fd5329e7ff3e902bc4a7d9b29554ad2fd4a3b0d.tar.xz wireguard-openbsd-0fd5329e7ff3e902bc4a7d9b29554ad2fd4a3b0d.zip | |
Grab the KERNEL_LOCK() in kthread_create(9) to enable unlocked code
paths create kernel threads. This will be utilized by sosplice()
for the taskq allocation.
OK mpi@
Diffstat (limited to 'sys/kern/kern_kthread.c')
| -rw-r--r-- | sys/kern/kern_kthread.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index c2f95169367..5a1eac96ff2 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_kthread.c,v 1.41 2017/02/12 04:55:08 guenther Exp $ */ +/* $OpenBSD: kern_kthread.c,v 1.42 2018/07/05 14:42:30 visa Exp $ */ /* $NetBSD: kern_kthread.c,v 1.3 1998/12/22 21:21:36 kleink Exp $ */ /*- @@ -60,6 +60,8 @@ kthread_create(void (*func)(void *), void *arg, struct proc *p; int error; + KERNEL_LOCK(); + /* * First, create the new process. Share the memory, file * descriptors and don't leave the exit status around for the @@ -67,12 +69,16 @@ kthread_create(void (*func)(void *), void *arg, */ error = fork1(&proc0, FORK_SHAREVM|FORK_SHAREFILES|FORK_NOZOMBIE| FORK_SYSTEM|FORK_SIGHAND, func, arg, NULL, &p); - if (error) + if (error) { + KERNEL_UNLOCK(); return (error); + } /* Name it as specified. */ strlcpy(p->p_p->ps_comm, name, sizeof p->p_p->ps_comm); + KERNEL_UNLOCK(); + /* All done! */ if (newpp != NULL) *newpp = p; |
