Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src * treat kern_malloc.c as an unreal allocator (it's so lightw...
details: https://anonhg.NetBSD.org/src/rev/a1af8e3e902f
branches: trunk
changeset: 786364:a1af8e3e902f
user: pooka <pooka%NetBSD.org@localhost>
date: Sat Apr 27 15:34:53 2013 +0000
description:
* treat kern_malloc.c as an unreal allocator (it's so lightweight)
* get rid of the rumpuser_realloc() hypercall
* pass size to rumpuser_free()
diffstat:
lib/librumpuser/rumpuser.c | 14 ++-----
sys/rump/include/rump/rumpuser.h | 5 +-
sys/rump/librump/rumpkern/Makefile.rumpkern | 5 +-
sys/rump/librump/rumpkern/memalloc.c | 52 ++--------------------------
sys/rump/librump/rumpkern/vm.c | 8 ++--
5 files changed, 18 insertions(+), 66 deletions(-)
diffs (215 lines):
diff -r fe09689e3035 -r a1af8e3e902f lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Sat Apr 27 15:32:36 2013 +0000
+++ b/lib/librumpuser/rumpuser.c Sat Apr 27 15:34:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.c,v 1.31 2013/04/27 15:01:21 pooka Exp $ */
+/* $NetBSD: rumpuser.c,v 1.32 2013/04/27 15:34:53 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.31 2013/04/27 15:01:21 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.32 2013/04/27 15:34:53 pooka Exp $");
#endif /* !lint */
#include <sys/ioctl.h>
@@ -261,15 +261,9 @@
return mem;
}
-void *
-rumpuser_realloc(void *ptr, size_t howmuch)
-{
-
- return realloc(ptr, howmuch);
-}
-
+/*ARGSUSED1*/
void
-rumpuser_free(void *ptr)
+rumpuser_free(void *ptr, size_t size)
{
free(ptr);
diff -r fe09689e3035 -r a1af8e3e902f sys/rump/include/rump/rumpuser.h
--- a/sys/rump/include/rump/rumpuser.h Sat Apr 27 15:32:36 2013 +0000
+++ b/sys/rump/include/rump/rumpuser.h Sat Apr 27 15:34:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.h,v 1.80 2013/04/27 15:32:36 pooka Exp $ */
+/* $NetBSD: rumpuser.h,v 1.81 2013/04/27 15:34:53 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -55,8 +55,7 @@
int rumpuser_nanosleep(uint64_t *, uint64_t *, int *);
void *rumpuser_malloc(size_t, int);
-void *rumpuser_realloc(void *, size_t);
-void rumpuser_free(void *);
+void rumpuser_free(void *, size_t);
void *rumpuser_anonmmap(void *, size_t, int, int, int *);
#define RUMPUSER_FILEMMAP_READ 0x01
diff -r fe09689e3035 -r a1af8e3e902f sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern Sat Apr 27 15:32:36 2013 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern Sat Apr 27 15:34:53 2013 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.rumpkern,v 1.124 2013/03/15 12:09:58 pooka Exp $
+# $NetBSD: Makefile.rumpkern,v 1.125 2013/04/27 15:34:53 pooka Exp $
#
.include "${RUMPTOP}/Makefile.rump"
@@ -66,6 +66,7 @@
kern_event.c \
kern_hook.c \
kern_ksyms.c \
+ kern_malloc.c \
kern_module.c \
kern_mutex_obj.c \
kern_ntptime.c \
@@ -139,7 +140,7 @@
.if defined(RUMP_UNREAL_ALLOCATORS) && ${RUMP_UNREAL_ALLOCATORS} == "yes"
SRCS+= memalloc.c
.else
-SRCS+= kern_malloc.c subr_kmem.c subr_pool.c
+SRCS+= subr_kmem.c subr_pool.c
.endif
.ifdef RUMP_LOCKDEBUG
diff -r fe09689e3035 -r a1af8e3e902f sys/rump/librump/rumpkern/memalloc.c
--- a/sys/rump/librump/rumpkern/memalloc.c Sat Apr 27 15:32:36 2013 +0000
+++ b/sys/rump/librump/rumpkern/memalloc.c Sat Apr 27 15:34:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: memalloc.c,v 1.20 2013/03/10 17:05:12 pooka Exp $ */
+/* $NetBSD: memalloc.c,v 1.21 2013/04/27 15:34:53 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.20 2013/03/10 17:05:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.21 2013/04/27 15:34:53 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -44,54 +44,12 @@
* libc malloc.
*
* Supported:
- * + malloc
* + kmem
* + pool
* + pool_cache
*/
/*
- * malloc
- */
-
-void
-kmeminit(void)
-{
-
- return;
-}
-
-void *
-kern_malloc(unsigned long size, int flags)
-{
- 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);
-
- return rv;
-}
-
-void *
-kern_realloc(void *ptr, unsigned long size, int flags)
-{
-
- return rumpuser_realloc(ptr, size);
-}
-
-void
-kern_free(void *ptr)
-{
-
- rumpuser_free(ptr);
-}
-
-/*
* Kmem
*/
@@ -125,7 +83,7 @@
kmem_free(void *p, size_t size)
{
- rumpuser_free(p);
+ rumpuser_free(p, size);
}
__strong_alias(kmem_intr_alloc, kmem_alloc);
@@ -198,7 +156,7 @@
{
pool_destroy(&pc->pc_pool);
- rumpuser_free(pc);
+ rumpuser_free(pc, sizeof(*pc));
}
void *
@@ -255,7 +213,7 @@
pool_put(struct pool *pp, void *item)
{
- rumpuser_free(item);
+ rumpuser_free(item, pp->pr_size);
}
void
diff -r fe09689e3035 -r a1af8e3e902f sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c Sat Apr 27 15:32:36 2013 +0000
+++ b/sys/rump/librump/rumpkern/vm.c Sat Apr 27 15:34:53 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vm.c,v 1.137 2013/03/10 17:05:12 pooka Exp $ */
+/* $NetBSD: vm.c,v 1.138 2013/04/27 15:34:53 pooka Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.137 2013/03/10 17:05:12 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.138 2013/04/27 15:34:53 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -742,7 +742,7 @@
if (__predict_false(map == module_map))
rumpuser_unmap((void *)vaddr, size);
else
- rumpuser_free((void *)vaddr);
+ rumpuser_free((void *)vaddr, size);
}
struct vm_map *
@@ -1189,5 +1189,5 @@
if (rump_physmemlimit != RUMPMEM_UNLIMITED) {
atomic_add_long(&curphysmem, -size);
}
- rumpuser_free(what);
+ rumpuser_free(what, size);
}
Home |
Main Index |
Thread Index |
Old Index