summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2014-04-03 21:37:00 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2014-04-03 21:37:00 +0000
commit4504cd982a1daa793107c70f1265768892ebef81 (patch)
tree756b524924e39d59cf2c1b2702fa8ca7e30f9c53 /sys/kern
parent6a027512e8bc0ebe46c29b5bb53d6469002fd208 (diff)
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')
-rw-r--r--sys/kern/kern_malloc.c10
-rw-r--r--sys/kern/subr_pool.c10
2 files changed, 14 insertions, 6 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)) {
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 2fd1e897cfe..3e065b61bf1 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.125 2014/03/28 17:57:11 mpi Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.126 2014/04/03 21:36:59 tedu Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -478,13 +478,17 @@ pool_get(struct pool *pp, int flags)
KASSERT(flags & (PR_WAITOK | PR_NOWAIT));
-#ifdef DIAGNOSTIC
if ((flags & PR_WAITOK) != 0) {
+#ifdef DIAGNOSTIC
assertwaitok();
if (pool_debug == 2)
yield();
+#endif
+ if (!cold) {
+ KERNEL_UNLOCK();
+ KERNEL_LOCK();
+ }
}
-#endif /* DIAGNOSTIC */
mtx_enter(&pp->pr_mtx);
#ifdef POOL_DEBUG