Module Name:    src
Committed By:   pooka
Date:           Thu Jul  8 11:39:58 UTC 2010

Modified Files:
        src/sys/rump/librump/rumpkern: memalloc.c

Log Message:
Emulate malloc(9) a little better by panicking if a should-not-fail
allocation fails.  We could invoke the pagedaemon here, but since
malloc(9) is panicky when it runs out of kmem_map, let's do the
"same".


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/rump/librump/rumpkern/memalloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/memalloc.c
diff -u src/sys/rump/librump/rumpkern/memalloc.c:1.9 src/sys/rump/librump/rumpkern/memalloc.c:1.10
--- src/sys/rump/librump/rumpkern/memalloc.c:1.9	Mon Jun 14 21:04:56 2010
+++ src/sys/rump/librump/rumpkern/memalloc.c	Thu Jul  8 11:39:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: memalloc.c,v 1.9 2010/06/14 21:04:56 pooka Exp $	*/
+/*	$NetBSD: memalloc.c,v 1.10 2010/07/08 11:39:58 pooka Exp $	*/
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.9 2010/06/14 21:04:56 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.10 2010/07/08 11:39:58 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -74,6 +74,10 @@
 	void *rv;
 
 	rv = rumpuser_malloc(size, 0);
+
+	if (__predict_false(rv == NULL && (flags & (M_CANFAIL|M_NOWAIT)) == 0))
+		panic("malloc %lu bytes failed", size);
+
 	if (rv && flags & M_ZERO)
 		memset(rv, 0, size);
 

Reply via email to