Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Don't pass "canfail" down to rumpuser_malloc -- there's quit...
details: https://anonhg.NetBSD.org/src/rev/17f9d6422971
branches: trunk
changeset: 755328:17f9d6422971
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Jun 01 20:11:33 2010 +0000
description:
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().
diffstat:
lib/librumpuser/rumpuser.c | 31 +++++++++++--------------------
sys/rump/include/rump/rumpuser.h | 9 +++------
sys/rump/librump/rumpkern/locks_up.c | 6 +++---
sys/rump/librump/rumpkern/memalloc.c | 13 +++++++------
sys/rump/librump/rumpkern/vm.c | 6 +++---
5 files changed, 27 insertions(+), 38 deletions(-)
diffs (199 lines):
diff -r 5722181e67f9 -r 17f9d6422971 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Tue Jun 01 19:20:43 2010 +0000
+++ b/lib/librumpuser/rumpuser.c Tue Jun 01 20:11:33 2010 +0000
@@ -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
diff -r 5722181e67f9 -r 17f9d6422971 sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Tue Jun 01 19:20:43 2010 +0000
+++ b/sys/rump/include/rump/rumpuser.h Tue Jun 01 20:11:33 2010 +0000
@@ -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 *);
diff -r 5722181e67f9 -r 17f9d6422971 sys/rump/librump/rumpkern/locks_up.c
--- a/sys/rump/librump/rumpkern/locks_up.c Tue Jun 01 19:20:43 2010 +0000
+++ b/sys/rump/librump/rumpkern/locks_up.c Tue Jun 01 20:11:33 2010 +0000
@@ -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 *));
diff -r 5722181e67f9 -r 17f9d6422971 sys/rump/librump/rumpkern/memalloc.c
--- a/sys/rump/librump/rumpkern/memalloc.c Tue Jun 01 19:20:43 2010 +0000
+++ b/sys/rump/librump/rumpkern/memalloc.c Tue Jun 01 20:11:33 2010 +0000
@@ -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__);
diff -r 5722181e67f9 -r 17f9d6422971 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c Tue Jun 01 19:20:43 2010 +0000
+++ b/sys/rump/librump/rumpkern/vm.c Tue Jun 01 20:11:33 2010 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index