summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_malloc.c8
-rw-r--r--sys/kern/subr_pool.c8
-rw-r--r--sys/uvm/uvm_pdaemon.c8
3 files changed, 21 insertions, 3 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index 1df4acfdcc0..5ea2bc176ae 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_malloc.c,v 1.132 2018/01/02 06:07:21 guenther Exp $ */
+/* $OpenBSD: kern_malloc.c,v 1.133 2018/01/18 18:08:51 bluhm Exp $ */
/* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */
/*
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/proc.h>
#include <sys/stdint.h>
#include <sys/systm.h>
#include <sys/sysctl.h>
@@ -205,6 +206,11 @@ malloc(size_t size, int type, int flags)
mtx_leave(&malloc_mtx);
return (NULL);
}
+#ifdef DIAGNOSTIC
+ if (ISSET(flags, M_WAITOK) && curproc == &proc0)
+ panic("%s: cannot sleep for memory during boot",
+ __func__);
+#endif
if (ksp->ks_limblocks < 65535)
ksp->ks_limblocks++;
msleep(ksp, &malloc_mtx, PSWP+2, memname[type], 0);
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 54688dfe0ea..cbcbffbfa3b 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.220 2017/08/13 20:26:33 guenther Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.221 2018/01/18 18:08:51 bluhm Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -37,6 +37,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/pool.h>
+#include <sys/proc.h>
#include <sys/syslog.h>
#include <sys/sysctl.h>
#include <sys/task.h>
@@ -596,6 +597,11 @@ pool_get(struct pool *pp, int flags)
struct pool_get_memory mem = { .v = NULL };
struct pool_request pr;
+#ifdef DIAGNOSTIC
+ if (ISSET(flags, PR_WAITOK) && curproc == &proc0)
+ panic("%s: cannot sleep for memory during boot",
+ __func__);
+#endif
pl_init(pp, &mem.lock);
pool_request_init(&pr, pool_get_done, &mem);
pool_request(pp, &pr);
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 822b5e23633..c0368f66815 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.78 2017/02/14 10:31:15 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.79 2018/01/18 18:08:51 bluhm Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -70,6 +70,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/pool.h>
+#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/mount.h>
#include <sys/atomic.h>
@@ -111,6 +112,11 @@ uvm_wait(const char *wmsg)
{
int timo = 0;
+#ifdef DIAGNOSTIC
+ if (curproc == &proc0)
+ panic("%s: cannot sleep for memory during boot", __func__);
+#endif
+
/* check for page daemon going to sleep (waiting for itself) */
if (curproc == uvm.pagedaemon_proc) {
printf("uvm_wait emergency bufbackoff\n");