diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-01-18 18:08:52 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-01-18 18:08:52 +0000 |
commit | ccf0881c871f543205eb93a9e93ec8ac0fd47245 (patch) | |
tree | 5c0a02e4d6883256e2b7da3cd5058774d98d0e52 /sys/kern/kern_malloc.c | |
parent | 67e88f61504d67567168403d731c3047913201cc (diff) |
While booting it does not make sense to wait for memory, there is
no other process which could free it. Better panic in malloc(9)
or pool_get(9) instead of sleeping forever.
tested by visa@ patrick@ Jan Klemkow
suggested by kettenis@; OK deraadt@
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r-- | sys/kern/kern_malloc.c | 8 |
1 files changed, 7 insertions, 1 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); |