Module Name:    src
Committed By:   pooka
Date:           Tue Jun  1 20:11:33 UTC 2010

Modified Files:
        src/lib/librumpuser: rumpuser.c
        src/sys/rump/include/rump: rumpuser.h
        src/sys/rump/librump/rumpkern: locks_up.c memalloc.c vm.c

Log Message:
Don't pass "canfail" down to rumpuser_malloc -- there's quite little
we can do with that info way down there.  Instead, pass alignment.
Implement rumpuser_malloc() with posix_memalign().


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/librumpuser/rumpuser.c
cvs rdiff -u -r1.42 -r1.43 src/sys/rump/include/rump/rumpuser.h
cvs rdiff -u -r1.1 -r1.2 src/sys/rump/librump/rumpkern/locks_up.c
cvs rdiff -u -r1.5 -r1.6 src/sys/rump/librump/rumpkern/memalloc.c
cvs rdiff -u -r1.77 -r1.78 src/sys/rump/librump/rumpkern/vm.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser.c
diff -u src/lib/librumpuser/rumpuser.c:1.4 src/lib/librumpuser/rumpuser.c:1.5
--- src/lib/librumpuser/rumpuser.c:1.4	Wed Apr 28 00:33:45 2010
+++ src/lib/librumpuser/rumpuser.c	Tue Jun  1 20:11:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.c,v 1.4 2010/04/28 00:33:45 pooka Exp $	*/
+/*	$NetBSD: rumpuser.c,v 1.5 2010/06/01 20:11:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.4 2010/04/28 00:33:45 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.5 2010/06/01 20:11:33 pooka Exp $");
 #endif /* !lint */
 
 /* thank the maker for this */
@@ -193,32 +193,23 @@
 }
 
 void *
-rumpuser__malloc(size_t howmuch, int canfail, const char *func, int line)
+rumpuser_malloc(size_t howmuch, int alignment)
 {
-	void *rv;
+	void *mem;
 
-	rv = malloc(howmuch);
-	if (rv == NULL && canfail == 0) {
-		warn("malloc failed %s (%d)", func, line);
-		abort();
-	}
+	if (alignment == 0)
+		alignment = sizeof(void *);
 
-	return rv;
+	posix_memalign(&mem, alignment, howmuch);
+
+	return mem;
 }
 
 void *
-rumpuser__realloc(void *ptr, size_t howmuch, int canfail,
-	const char *func, int line)
+rumpuser_realloc(void *ptr, size_t howmuch)
 {
-	void *rv;
 
-	rv = realloc(ptr, howmuch);
-	if (rv == NULL && canfail == 0) {
-		warn("realloc failed %s (%d)", func, line);
-		abort();
-	}
-
-	return rv;
+	return realloc(ptr, howmuch);
 }
 
 void

Index: src/sys/rump/include/rump/rumpuser.h
diff -u src/sys/rump/include/rump/rumpuser.h:1.42 src/sys/rump/include/rump/rumpuser.h:1.43
--- src/sys/rump/include/rump/rumpuser.h:1.42	Mon May 31 23:09:29 2010
+++ src/sys/rump/include/rump/rumpuser.h	Tue Jun  1 20:11:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: rumpuser.h,v 1.42 2010/05/31 23:09:29 pooka Exp $	*/
+/*	$NetBSD: rumpuser.h,v 1.43 2010/06/01 20:11:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -51,11 +51,8 @@
 #define RUMPUSER_FT_CHR 4
 int rumpuser_nanosleep(uint64_t *, uint64_t *, int *);
 
-#define rumpuser_malloc(a,b) rumpuser__malloc(a,b,__func__,__LINE__);
-#define rumpuser_realloc(a,b,c) rumpuser__realloc(a,b,c,__func__,__LINE__);
-
-void *rumpuser__malloc(size_t, int, const char *, int);
-void *rumpuser__realloc(void *, size_t, int, const char *, int);
+void *rumpuser_malloc(size_t, int);
+void *rumpuser_realloc(void *, size_t);
 void rumpuser_free(void *);
 
 void *rumpuser_anonmmap(size_t, int, int, int *);

Index: src/sys/rump/librump/rumpkern/locks_up.c
diff -u src/sys/rump/librump/rumpkern/locks_up.c:1.1 src/sys/rump/librump/rumpkern/locks_up.c:1.2
--- src/sys/rump/librump/rumpkern/locks_up.c:1.1	Tue May 18 16:29:36 2010
+++ src/sys/rump/librump/rumpkern/locks_up.c	Tue Jun  1 20:11:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: locks_up.c,v 1.1 2010/05/18 16:29:36 pooka Exp $	*/
+/*	$NetBSD: locks_up.c,v 1.2 2010/06/01 20:11:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks_up.c,v 1.1 2010/05/18 16:29:36 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks_up.c,v 1.2 2010/06/01 20:11:33 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -74,7 +74,7 @@
 	 * XXX: pool_cache would be nice, but not easily possible,
 	 * as pool cache init wants to call mutex_init() ...
 	 */
-	upm = rumpuser_malloc(sizeof(*upm), 1);
+	upm = rumpuser_malloc(sizeof(*upm), 0);
 	memset(upm, 0, sizeof(*upm));
 	rumpuser_cv_init(&upm->upm_rucv);
 	memcpy(mtx, &upm, sizeof(void *));

Index: src/sys/rump/librump/rumpkern/memalloc.c
diff -u src/sys/rump/librump/rumpkern/memalloc.c:1.5 src/sys/rump/librump/rumpkern/memalloc.c:1.6
--- src/sys/rump/librump/rumpkern/memalloc.c:1.5	Fri Jan 15 19:01:04 2010
+++ src/sys/rump/librump/rumpkern/memalloc.c	Tue Jun  1 20:11:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: memalloc.c,v 1.5 2010/01/15 19:01:04 pooka Exp $	*/
+/*	$NetBSD: memalloc.c,v 1.6 2010/06/01 20:11:33 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.5 2010/01/15 19:01:04 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.6 2010/06/01 20:11:33 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -73,7 +73,7 @@
 {
 	void *rv;
 
-	rv = rumpuser_malloc(size, (flags & (M_CANFAIL | M_NOWAIT)) != 0);
+	rv = rumpuser_malloc(size, 0);
 	if (rv && flags & M_ZERO)
 		memset(rv, 0, size);
 
@@ -84,7 +84,7 @@
 kern_realloc(void *ptr, unsigned long size, struct malloc_type *type, int flags)
 {
 
-	return rumpuser_realloc(ptr, size, (flags & (M_CANFAIL|M_NOWAIT)) != 0);
+	return rumpuser_realloc(ptr, size);
 }
 
 void
@@ -110,7 +110,7 @@
 kmem_alloc(size_t size, km_flag_t kmflag)
 {
 
-	return rumpuser_malloc(size, kmflag == KM_NOSLEEP);
+	return rumpuser_malloc(size, 0);
 }
 
 void *
@@ -153,6 +153,7 @@
 {
 
 	pp->pr_size = size;
+	pp->pr_align = align;
 }
 
 void
@@ -246,7 +247,7 @@
 		panic("%s: pool unit size 0.  not initialized?", __func__);
 #endif
 
-	rv = rumpuser_malloc(pp->pr_size, 1);
+	rv = rumpuser_malloc(pp->pr_size, pp->pr_align);
 	if (rv == NULL && (flags & PR_WAITOK && (flags & PR_LIMITFAIL) == 0))
 		panic("%s: out of memory and PR_WAITOK", __func__);
 

Index: src/sys/rump/librump/rumpkern/vm.c
diff -u src/sys/rump/librump/rumpkern/vm.c:1.77 src/sys/rump/librump/rumpkern/vm.c:1.78
--- src/sys/rump/librump/rumpkern/vm.c:1.77	Tue Jun  1 19:18:20 2010
+++ src/sys/rump/librump/rumpkern/vm.c	Tue Jun  1 20:11:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm.c,v 1.77 2010/06/01 19:18:20 pooka Exp $	*/
+/*	$NetBSD: vm.c,v 1.78 2010/06/01 20:11:33 pooka Exp $	*/
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.77 2010/06/01 19:18:20 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.78 2010/06/01 20:11:33 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -582,7 +582,7 @@
 uvm_km_alloc_poolpage(struct vm_map *map, bool waitok)
 {
 
-	return (vaddr_t)rumpuser_malloc(PAGE_SIZE, !waitok);
+	return (vaddr_t)rumpuser_malloc(PAGE_SIZE, PAGE_SIZE);
 }
 
 void

Reply via email to