summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_malloc.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-04-03 21:36:59 +0000
committertedu <tedu@openbsd.org>2014-04-03 21:36:59 +0000
commit2e819bd6dd7768e568dbcbd9a78809a995a78a26 (patch)
treec0554a041c2cb9deaebcdeee6141f18d039a4f8b /sys/kern/kern_malloc.c
parentOn second thought, make that manpage MI, even though the binary is not (diff)
downloadwireguard-openbsd-2e819bd6dd7768e568dbcbd9a78809a995a78a26.tar.xz
wireguard-openbsd-2e819bd6dd7768e568dbcbd9a78809a995a78a26.zip
if it's ok to wait, it must also be ok to give the kernel lock. do so.
(then immediately reacquire it). this has the effect of giving interrupts on other CPUs to a chance to run and reduces latency in many cases. ok deraadt
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r--sys/kern/kern_malloc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index c583d69e9fc..1862aa171cd 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.105 2014/03/28 17:57:11 mpi Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.106 2014/04/03 21:36:59 tedu Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -180,14 +180,18 @@ malloc(unsigned long size, int type, int flags)
KASSERT(flags & (M_WAITOK | M_NOWAIT));
-#ifdef DIAGNOSTIC
if ((flags & M_NOWAIT) == 0) {
+#ifdef DIAGNOSTIC
extern int pool_debug;
assertwaitok();
if (pool_debug == 2)
yield();
- }
#endif
+ if (!cold) {
+ KERNEL_UNLOCK();
+ KERNEL_LOCK();
+ }
+ }
#ifdef MALLOC_DEBUG
if (debug_malloc(size, type, flags, (void **)&va)) {