Thu Sep 25 16:23:46 2008 UTC ()
Move global malloc types from kern_malloc into a separate module.


(pooka)
diff -r1.916 -r1.917 src/sys/conf/files
diff -r1.119 -r1.120 src/sys/kern/kern_malloc.c
diff -r0 -r1.1 src/sys/kern/kern_malloc_stdtype.c
diff -r1.6 -r1.7 src/sys/rump/librump/rumpkern/Makefile.rumpkern
diff -r1.47 -r1.48 src/sys/rump/librump/rumpkern/emul.c

cvs diff -r1.916 -r1.917 src/sys/conf/files (expand / switch to unified diff)

--- src/sys/conf/files 2008/09/14 16:10:19 1.916
+++ src/sys/conf/files 2008/09/25 16:23:45 1.917
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: files,v 1.916 2008/09/14 16:10:19 hannken Exp $ 1# $NetBSD: files,v 1.917 2008/09/25 16:23:45 pooka Exp $
2 2
3# @(#)files.newconf 7.5 (Berkeley) 5/10/93 3# @(#)files.newconf 7.5 (Berkeley) 5/10/93
4 4
5version 20080610 5version 20080610
6 6
7# 7#
8# device classes 8# device classes
9# 9#
10devclass disk 10devclass disk
11devclass tape 11devclass tape
12devclass ifnet 12devclass ifnet
13devclass tty 13devclass tty
14devclass audiodev 14devclass audiodev
@@ -1375,26 +1375,27 @@ file kern/kern_cpu.c @@ -1375,26 +1375,27 @@ file kern/kern_cpu.c
1375file kern/kern_descrip.c 1375file kern/kern_descrip.c
1376file kern/kern_event.c 1376file kern/kern_event.c
1377file kern/kern_exec.c 1377file kern/kern_exec.c
1378file kern/kern_exit.c 1378file kern/kern_exit.c
1379file kern/kern_fork.c 1379file kern/kern_fork.c
1380file kern/kern_idle.c 1380file kern/kern_idle.c
1381file kern/kern_kthread.c 1381file kern/kern_kthread.c
1382file kern/kern_ktrace.c ktrace 1382file kern/kern_ktrace.c ktrace
1383file kern/kern_ksyms.c ksyms | ddb | lkm needs-flag 1383file kern/kern_ksyms.c ksyms | ddb | lkm needs-flag
1384file kern/kern_lkm.c lkm 1384file kern/kern_lkm.c lkm
1385file kern/kern_lock.c 1385file kern/kern_lock.c
1386file kern/kern_lwp.c 1386file kern/kern_lwp.c
1387file kern/kern_malloc.c 1387file kern/kern_malloc.c
 1388file kern/kern_malloc_stdtype.c
1388file kern/kern_malloc_debug.c malloc_debug 1389file kern/kern_malloc_debug.c malloc_debug
1389file kern/kern_module.c 1390file kern/kern_module.c
1390file kern/kern_mutex.c 1391file kern/kern_mutex.c
1391file kern/kern_fileassoc.c fileassoc 1392file kern/kern_fileassoc.c fileassoc
1392file kern/kern_ntptime.c 1393file kern/kern_ntptime.c
1393file kern/kern_pax.c pax_mprotect | pax_segvguard 1394file kern/kern_pax.c pax_mprotect | pax_segvguard
1394file kern/kern_physio.c 1395file kern/kern_physio.c
1395file kern/kern_pmf.c 1396file kern/kern_pmf.c
1396file kern/kern_proc.c 1397file kern/kern_proc.c
1397file kern/kern_prot.c 1398file kern/kern_prot.c
1398file kern/kern_ras.c 1399file kern/kern_ras.c
1399file kern/kern_resource.c 1400file kern/kern_resource.c
1400file kern/kern_runq.c 1401file kern/kern_runq.c

cvs diff -r1.119 -r1.120 src/sys/kern/kern_malloc.c (expand / switch to unified diff)

--- src/sys/kern/kern_malloc.c 2008/03/17 17:05:54 1.119
+++ src/sys/kern/kern_malloc.c 2008/09/25 16:23:45 1.120
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_malloc.c,v 1.119 2008/03/17 17:05:54 ad Exp $ */ 1/* $NetBSD: kern_malloc.c,v 1.120 2008/09/25 16:23:45 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1987, 1991, 1993 4 * Copyright (c) 1987, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -56,27 +56,27 @@ @@ -56,27 +56,27 @@
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)kern_malloc.c 8.4 (Berkeley) 5/20/95 65 * @(#)kern_malloc.c 8.4 (Berkeley) 5/20/95
66 */ 66 */
67 67
68#include <sys/cdefs.h> 68#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.119 2008/03/17 17:05:54 ad Exp $"); 69__KERNEL_RCSID(0, "$NetBSD: kern_malloc.c,v 1.120 2008/09/25 16:23:45 pooka Exp $");
70 70
71#include <sys/param.h> 71#include <sys/param.h>
72#include <sys/proc.h> 72#include <sys/proc.h>
73#include <sys/kernel.h> 73#include <sys/kernel.h>
74#include <sys/malloc.h> 74#include <sys/malloc.h>
75#include <sys/systm.h> 75#include <sys/systm.h>
76#include <sys/debug.h> 76#include <sys/debug.h>
77#include <sys/mutex.h> 77#include <sys/mutex.h>
78#include <sys/lockdebug.h> 78#include <sys/lockdebug.h>
79 79
80#include <uvm/uvm_extern.h> 80#include <uvm/uvm_extern.h>
81 81
82static struct vm_map_kernel kmem_map_store; 82static struct vm_map_kernel kmem_map_store;
@@ -270,48 +270,26 @@ struct freelist { @@ -270,48 +270,26 @@ struct freelist {
270 uint32_t spare0; 270 uint32_t spare0;
271#ifdef _LP64 271#ifdef _LP64
272 uint32_t spare1; /* explicit padding */ 272 uint32_t spare1; /* explicit padding */
273#endif 273#endif
274 struct malloc_type *type; 274 struct malloc_type *type;
275 void * next; 275 void * next;
276}; 276};
277#else /* !DIAGNOSTIC */ 277#else /* !DIAGNOSTIC */
278struct freelist { 278struct freelist {
279 void * next; 279 void * next;
280}; 280};
281#endif /* DIAGNOSTIC */ 281#endif /* DIAGNOSTIC */
282 282
283/* 
284 * The following are standard, built-in malloc types and are not 
285 * specific to any subsystem. 
286 */ 
287MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory"); 
288MALLOC_DEFINE(M_DMAMAP, "DMA map", "bus_dma(9) structures"); 
289MALLOC_DEFINE(M_FREE, "free", "should be on free list"); 
290MALLOC_DEFINE(M_PCB, "pcb", "protocol control block"); 
291MALLOC_DEFINE(M_SOFTINTR, "softintr", "Softinterrupt structures"); 
292MALLOC_DEFINE(M_TEMP, "temp", "misc. temporary data buffers"); 
293 
294/* XXX These should all be elsewhere. */ 
295MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables"); 
296MALLOC_DEFINE(M_FTABLE, "fragtbl", "fragment reassembly header"); 
297MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure"); 
298MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure"); 
299MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "internet multicast options"); 
300MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address"); 
301MALLOC_DEFINE(M_MRTABLE, "mrt", "multicast routing tables"); 
302MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters"); 
303MALLOC_DEFINE(M_1394DATA, "1394data", "IEEE 1394 data buffers"); 
304 
305kmutex_t malloc_lock; 283kmutex_t malloc_lock;
306 284
307/* 285/*
308 * Allocate a block of memory 286 * Allocate a block of memory
309 */ 287 */
310#ifdef MALLOCLOG 288#ifdef MALLOCLOG
311void * 289void *
312_malloc(unsigned long size, struct malloc_type *ksp, int flags, 290_malloc(unsigned long size, struct malloc_type *ksp, int flags,
313 const char *file, long line) 291 const char *file, long line)
314#else 292#else
315void * 293void *
316malloc(unsigned long size, struct malloc_type *ksp, int flags) 294malloc(unsigned long size, struct malloc_type *ksp, int flags)
317#endif /* MALLOCLOG */ 295#endif /* MALLOCLOG */

File Added: src/sys/kern/Attic/kern_malloc_stdtype.c
/*	$NetBSD: kern_malloc_stdtype.c,v 1.1 2008/09/25 16:23:45 pooka Exp $	*/

/*
 * Copyright (c) 1987, 1991, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)kern_malloc.c	8.4 (Berkeley) 5/20/95
 */

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_malloc_stdtype.c,v 1.1 2008/09/25 16:23:45 pooka Exp $");

#include <sys/param.h>
#include <sys/malloc.h>

/*
 * The following are standard, built-in malloc types and are not
 * specific to any subsystem.
 */
MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory");
MALLOC_DEFINE(M_DMAMAP, "DMA map", "bus_dma(9) structures");
MALLOC_DEFINE(M_FREE, "free", "should be on free list");
MALLOC_DEFINE(M_PCB, "pcb", "protocol control block");
MALLOC_DEFINE(M_SOFTINTR, "softintr", "Softinterrupt structures");
MALLOC_DEFINE(M_TEMP, "temp", "misc. temporary data buffers");

/* XXX These should all be elsewhere. */
MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
MALLOC_DEFINE(M_FTABLE, "fragtbl", "fragment reassembly header");
MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure");
MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "internet multicast options");
MALLOC_DEFINE(M_IPMADDR, "in_multi", "internet multicast address");
MALLOC_DEFINE(M_MRTABLE, "mrt", "multicast routing tables");
MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast upcall bw meters");
MALLOC_DEFINE(M_1394DATA, "1394data", "IEEE 1394 data buffers");

cvs diff -r1.6 -r1.7 src/sys/rump/librump/rumpkern/Makefile.rumpkern (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/Makefile.rumpkern 2008/08/04 15:02:16 1.6
+++ src/sys/rump/librump/rumpkern/Makefile.rumpkern 2008/09/25 16:23:45 1.7
@@ -1,43 +1,44 @@ @@ -1,43 +1,44 @@
1# $NetBSD: Makefile.rumpkern,v 1.6 2008/08/04 15:02:16 pooka Exp $ 1# $NetBSD: Makefile.rumpkern,v 1.7 2008/09/25 16:23:45 pooka Exp $
2# 2#
3 3
4.include "${RUMPTOP}/Makefile.rump" 4.include "${RUMPTOP}/Makefile.rump"
5 5
6LIB= rump 6LIB= rump
7LDFLAGS+= -Wl,--wrap=malloc 7LDFLAGS+= -Wl,--wrap=malloc
8 8
9INCSDIR=/usr/include/rump 9INCSDIR=/usr/include/rump
10INCS+= rump.h rumpdefs.h rump_syscalls.h rumpvnode_if.h 10INCS+= rump.h rumpdefs.h rump_syscalls.h rumpvnode_if.h
11 11
12.PATH: ${RUMPTOP}/librump/rumpkern \ 12.PATH: ${RUMPTOP}/librump/rumpkern \
13 ${RUMPTOP}/../kern ${RUMPTOP}/../lib/libkern \ 13 ${RUMPTOP}/../kern ${RUMPTOP}/../lib/libkern \
14 ${RUMPTOP}/../conf ${RUMPTOP}/../dev \ 14 ${RUMPTOP}/../conf ${RUMPTOP}/../dev \
15 ${RUMPTOP}/../miscfs/genfs ${RUMPTOP}/../miscfs/syncfs 15 ${RUMPTOP}/../miscfs/genfs ${RUMPTOP}/../miscfs/syncfs
16 16
17# implement something 17# implement something
18SRCS= rump.c atomic.c auth.c emul.c intr.c genfs_io.c locks.c \ 18SRCS= rump.c atomic.c auth.c emul.c intr.c genfs_io.c locks.c \
19 ltsleep.c pool.c specfs.c vfs.c vm.c 19 ltsleep.c pool.c specfs.c vfs.c vm.c
20 20
21# just stubs 21# just stubs
22SRCS+= fstrans_stub.c misc_stub.c pmap_stub.c vfsops_stub.c 22SRCS+= fstrans_stub.c misc_stub.c pmap_stub.c vfsops_stub.c
23 23
24# sys/kern 24# sys/kern
25SRCS+= clock_subr.c kern_descrip.c kern_module.c kern_stub.c \ 25SRCS+= clock_subr.c kern_descrip.c kern_malloc_stdtype.c \
26 kern_sysctl.c param.c subr_bufq.c subr_callback.c subr_hash.c \ 26 kern_module.c kern_stub.c kern_sysctl.c param.c subr_bufq.c \
27 subr_kobj.c subr_prf2.c subr_specificdata.c subr_time.c \ 27 subr_callback.c subr_hash.c subr_kobj.c subr_prf2.c \
28 subr_workqueue.c sys_descrip.c sys_generic.c vfs_bio.c \ 28 subr_specificdata.c subr_time.c subr_workqueue.c sys_descrip.c \
29 vfs_cache.c vfs_getcwd.c vfs_hooks.c vfs_init.c vfs_lookup.c \ 29 sys_generic.c vfs_bio.c vfs_cache.c vfs_getcwd.c vfs_hooks.c \
30 vfs_subr.c vfs_syscalls.c vfs_vnops.c vfs_wapbl.c vnode_if.c 30 vfs_init.c vfs_lookup.c vfs_subr.c vfs_syscalls.c vfs_vnops.c \
 31 vfs_wapbl.c vnode_if.c
31 32
32# sys/miscfs 33# sys/miscfs
33SRCS+= genfs_vfsops.c genfs_vnops.c sync_subr.c 34SRCS+= genfs_vfsops.c genfs_vnops.c sync_subr.c
34 35
35# src/kern bufq 36# src/kern bufq
36SRCS+= subr_bufq.c bufq_disksort.c bufq_fcfs.c bufq_priocscan.c \ 37SRCS+= subr_bufq.c bufq_disksort.c bufq_fcfs.c bufq_priocscan.c \
37 bufq_readprio.c 38 bufq_readprio.c
38 39
39# src/lib/libkern 40# src/lib/libkern
40SRCS+= __assert.c scanc.c skpc.c 41SRCS+= __assert.c scanc.c skpc.c
41 42
42SRCS+= rumpvnode_if.c rump_syscalls.c 43SRCS+= rumpvnode_if.c rump_syscalls.c
43 44

cvs diff -r1.47 -r1.48 src/sys/rump/librump/rumpkern/emul.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/emul.c 2008/08/12 10:04:57 1.47
+++ src/sys/rump/librump/rumpkern/emul.c 2008/09/25 16:23:46 1.48
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: emul.c,v 1.47 2008/08/12 10:04:57 pooka Exp $ */ 1/* $NetBSD: emul.c,v 1.48 2008/09/25 16:23:46 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by Google Summer of Code. 6 * Development of this software was supported by Google Summer of Code.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -59,31 +59,26 @@ @@ -59,31 +59,26 @@
59time_t time_second = 1; 59time_t time_second = 1;
60 60
61kmutex_t *proc_lock; 61kmutex_t *proc_lock;
62struct lwp lwp0; 62struct lwp lwp0;
63struct vnode *rootvp; 63struct vnode *rootvp;
64struct device *root_device; 64struct device *root_device;
65dev_t rootdev; 65dev_t rootdev;
66int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */ 66int physmem = 256*256; /* 256 * 1024*1024 / 4k, PAGE_SIZE not always set */
67int doing_shutdown; 67int doing_shutdown;
68int ncpu = 1; 68int ncpu = 1;
69const int schedppq = 1; 69const int schedppq = 1;
70int hardclock_ticks; 70int hardclock_ticks;
71 71
72MALLOC_DEFINE(M_UFSMNT, "UFS mount", "UFS mount structure"); 
73MALLOC_DEFINE(M_TEMP, "temp", "misc. temporary data buffers"); 
74MALLOC_DEFINE(M_DEVBUF, "devbuf", "device driver memory"); 
75MALLOC_DEFINE(M_KEVENT, "kevent", "kevents/knotes"); 
76 
77char hostname[MAXHOSTNAMELEN]; 72char hostname[MAXHOSTNAMELEN];
78size_t hostnamelen; 73size_t hostnamelen;
79 74
80u_long bufmem_valimit; 75u_long bufmem_valimit;
81u_long bufmem_hiwater; 76u_long bufmem_hiwater;
82u_long bufmem_lowater; 77u_long bufmem_lowater;
83u_long bufmem; 78u_long bufmem;
84u_int nbuf; 79u_int nbuf;
85 80
86const char *panicstr; 81const char *panicstr;
87const char ostype[] = "NetBSD"; 82const char ostype[] = "NetBSD";
88const char osrelease[] = "999"; /* paradroid 4evah */ 83const char osrelease[] = "999"; /* paradroid 4evah */
89const char kernel_ident[] = "RUMP-ROAST"; 84const char kernel_ident[] = "RUMP-ROAST";