Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add extensible malloc types, adapted from FreeBSD. This...



details:   https://anonhg.NetBSD.org/src/rev/41438970729a
branches:  trunk
changeset: 542535:41438970729a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Feb 01 06:23:35 2003 +0000

description:
Add extensible malloc types, adapted from FreeBSD.  This turns
malloc types into a structure, a pointer to which is passed around,
instead of an int constant.  Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.

diffstat:

 sys/arch/x68k/dev/vs.c              |   11 +-
 sys/coda/cnode.h                    |    5 +-
 sys/coda/coda_vfsops.c              |    6 +-
 sys/dev/audio_if.h                  |    7 +-
 sys/dev/ic/interwave.c              |    9 +-
 sys/dev/ic/interwavevar.h           |    7 +-
 sys/dev/isa/ad1848_isa.c            |    9 +-
 sys/dev/isa/ad1848var.h             |    6 +-
 sys/dev/isa/ess.c                   |   13 +-
 sys/dev/isa/isadma.c                |    8 +-
 sys/dev/isa/isadmavar.h             |    8 +-
 sys/dev/isa/sbdsp.c                 |    9 +-
 sys/dev/isa/sbdspvar.h              |    8 +-
 sys/dev/pci/agp.c                   |    6 +-
 sys/dev/pci/agpvar.h                |    5 +-
 sys/dev/pci/auich.c                 |   13 +-
 sys/dev/pci/autri.c                 |   11 +-
 sys/dev/pci/auvia.c                 |   13 +-
 sys/dev/pci/cmpci.c                 |   24 +-
 sys/dev/pci/cs428x.c                |   11 +-
 sys/dev/pci/cs428x.h                |    9 +-
 sys/dev/pci/eap.c                   |   13 +-
 sys/dev/pci/emuxki.c                |   39 ++-
 sys/dev/pci/esa.c                   |   11 +-
 sys/dev/pci/esm.c                   |    9 +-
 sys/dev/pci/esmvar.h                |    6 +-
 sys/dev/pci/eso.c                   |   13 +-
 sys/dev/pci/fms.c                   |   13 +-
 sys/dev/pci/neo.c                   |   13 +-
 sys/dev/pci/sv.c                    |   13 +-
 sys/dev/pci/yds.c                   |   13 +-
 sys/dev/raidframe/raidframevar.h    |    7 +-
 sys/dev/raidframe/rf_netbsdkintf.c  |    9 +-
 sys/dev/usb/usb_mem.c               |    8 +-
 sys/dev/usb/usb_port.h              |   13 +-
 sys/fs/adosfs/adosfs.h              |    5 +-
 sys/fs/adosfs/advfsops.c            |    8 +-
 sys/fs/cd9660/cd9660_extern.h       |    5 +-
 sys/fs/cd9660/cd9660_vfsops.c       |    6 +-
 sys/fs/filecorefs/filecore_extern.h |    6 +-
 sys/fs/filecorefs/filecore_vfsops.c |    6 +-
 sys/fs/msdosfs/msdosfs_vfsops.c     |    7 +-
 sys/fs/msdosfs/msdosfsmount.h       |    5 +-
 sys/fs/ntfs/ntfs.h                  |   14 +-
 sys/fs/ntfs/ntfs_subr.c             |    6 +-
 sys/fs/ntfs/ntfs_vfsops.c           |    6 +-
 sys/fs/smbfs/smbfs_node.c           |    6 +-
 sys/fs/smbfs/smbfs_subr.c           |    4 +-
 sys/fs/smbfs/smbfs_vfsops.c         |    4 +-
 sys/kern/kern_descrip.c             |    8 +-
 sys/kern/kern_event.c               |    4 +-
 sys/kern/kern_exec.c                |    6 +-
 sys/kern/kern_malloc.c              |  209 ++++++++++++++++-----
 sys/kern/kern_malloc_debug.c        |   33 +-
 sys/kern/kern_proc.c                |    9 +-
 sys/kern/kern_prot.c                |    6 +-
 sys/kern/kern_sa.c                  |    6 +-
 sys/kern/kern_subr.c                |   11 +-
 sys/kern/subr_extent.c              |    6 +-
 sys/kern/subr_prof.c                |    6 +-
 sys/kern/subr_prop.c                |    6 +-
 sys/kern/sys_pipe.c                 |    6 +-
 sys/kern/sysv_shm.c                 |    6 +-
 sys/kern/tty_subr.c                 |    6 +-
 sys/kern/uipc_mbuf.c                |    6 +-
 sys/kern/uipc_mbuf2.c               |    6 +-
 sys/kern/uipc_sem.c                 |    4 +-
 sys/kern/uipc_socket.c              |    7 +-
 sys/kern/vfs_cache.c                |    6 +-
 sys/kern/vfs_lockf.c                |    6 +-
 sys/kern/vfs_lookup.c               |    6 +-
 sys/kern/vfs_subr.c                 |    6 +-
 sys/kern/vfs_syscalls.c             |    6 +-
 sys/miscfs/kernfs/kernfs_vfsops.c   |   10 +-
 sys/net/if.c                        |    7 +-
 sys/net/if.h                        |    6 +-
 sys/netinet6/in6.c                  |    6 +-
 sys/netinet6/in6_var.h              |    4 +-
 sys/netinet6/nd6.c                  |    6 +-
 sys/netinet6/nd6.h                  |    5 +-
 sys/netkey/keydb.c                  |    6 +-
 sys/netkey/keydb.h                  |    5 +-
 sys/netns/spp_usrreq.c              |   12 +-
 sys/netsmb/smb_conn.c               |    6 +-
 sys/netsmb/smb_dev.c                |    8 +-
 sys/netsmb/smb_iod.c                |    4 +-
 sys/netsmb/smb_rq.c                 |    4 +-
 sys/netsmb/smb_subr.c               |    5 +-
 sys/netsmb/smb_subr.h               |    4 +-
 sys/nfs/nfs_bootparam.c             |    5 +-
 sys/nfs/nfs_node.c                  |    8 +-
 sys/nfs/nfs_nqlease.c               |    7 +-
 sys/nfs/nfs_socket.c                |    6 +-
 sys/nfs/nfs_syscalls.c              |   10 +-
 sys/nfs/nfs_var.h                   |   13 +-
 sys/nfs/nfs_vfsops.c                |    6 +-
 sys/sys/Makefile                    |    8 +-
 sys/sys/event.h                     |    5 +-
 sys/sys/exec.h                      |    6 +-
 sys/sys/extent.h                    |   10 +-
 sys/sys/file.h                      |    6 +-
 sys/sys/malloc.h                    |  334 +++--------------------------------
 sys/sys/mallocvar.h                 |   92 +++++++++
 sys/sys/mbuf.h                      |   12 +-
 sys/sys/mount.h                     |    5 +-
 sys/sys/namei.h                     |    5 +-
 sys/sys/param.h                     |    6 +-
 sys/sys/proc.h                      |    8 +-
 sys/sys/savar.h                     |    5 +-
 sys/sys/socketvar.h                 |    5 +-
 sys/sys/systm.h                     |    8 +-
 sys/sys/tty.h                       |    5 +-
 sys/sys/uio.h                       |    6 +-
 sys/sys/vnode.h                     |    6 +-
 sys/ufs/ffs/ffs_softdep.c           |    9 +-
 sys/ufs/lfs/lfs_extern.h            |    5 +-
 sys/ufs/lfs/lfs_segment.c           |    6 +-
 sys/ufs/mfs/mfs_extern.h            |    5 +-
 sys/ufs/mfs/mfs_vfsops.c            |    6 +-
 sys/ufs/ufs/ufs_quota.c             |    6 +-
 sys/uvm/uvm_amap.c                  |    6 +-
 sys/uvm/uvm_amap.h                  |    4 +-
 sys/uvm/uvm_aobj.c                  |    6 +-
 sys/uvm/uvm_extern.h                |    5 +-
 sys/uvm/uvm_map.c                   |    7 +-
 sys/uvm/uvm_page.c                  |    6 +-
 sys/uvm/uvm_swap.c                  |    6 +-
 127 files changed, 891 insertions(+), 718 deletions(-)

diffs (truncated from 4685 to 300 lines):

diff -r 7a17d697bdee -r 41438970729a sys/arch/x68k/dev/vs.c
--- a/sys/arch/x68k/dev/vs.c    Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/arch/x68k/dev/vs.c    Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vs.c,v 1.20 2002/11/24 13:33:45 isaki Exp $    */
+/*     $NetBSD: vs.c,v 1.21 2003/02/01 06:23:35 thorpej Exp $  */
 
 /*
  * Copyright (c) 2001 Tetsuya Isaki. All rights reserved.
@@ -93,8 +93,8 @@
 static int  vs_set_port __P((void *, mixer_ctrl_t *));
 static int  vs_get_port __P((void *, mixer_ctrl_t *));
 static int  vs_query_devinfo __P((void *, mixer_devinfo_t *));
-static void *vs_allocm __P((void *, int, size_t, int, int));
-static void vs_freem __P((void *, void *, int));
+static void *vs_allocm __P((void *, int, size_t, struct malloc_type *, int));
+static void vs_freem __P((void *, void *, struct malloc_type *));
 static size_t vs_round_buffersize __P((void *, int, size_t));
 static int  vs_get_props __P((void *));
 
@@ -713,7 +713,8 @@
 }
 
 static void *
-vs_allocm(void *hdl, int direction, size_t size, int type, int flags)
+vs_allocm(void *hdl, int direction, size_t size, struct malloc_type *type,
+    int flags)
 {
        struct vs_softc *sc = hdl;
        struct vs_dma *vd;
@@ -736,7 +737,7 @@
 }
 
 static void
-vs_freem(void *hdl, void *addr, int type)
+vs_freem(void *hdl, void *addr, struct malloc_type *type)
 {
        struct vs_softc *sc = hdl;
        struct vs_dma *p, **pp;
diff -r 7a17d697bdee -r 41438970729a sys/coda/cnode.h
--- a/sys/coda/cnode.h  Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/coda/cnode.h  Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cnode.h,v 1.9 2002/11/02 07:18:35 perry Exp $  */
+/*     $NetBSD: cnode.h,v 1.10 2003/02/01 06:23:36 thorpej Exp $       */
 
 /*
  * 
@@ -48,6 +48,9 @@
 #define        _CNODE_H_
 
 #include <sys/vnode.h>
+#include <sys/mallocvar.h>
+
+MALLOC_DECLARE(M_CODA);
 
 /*
  * tmp below since we need struct queue
diff -r 7a17d697bdee -r 41438970729a sys/coda/coda_vfsops.c
--- a/sys/coda/coda_vfsops.c    Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/coda/coda_vfsops.c    Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.c,v 1.20 2002/12/26 12:40:01 jdolecek Exp $        */
+/*     $NetBSD: coda_vfsops.c,v 1.21 2003/02/01 06:23:36 thorpej Exp $ */
 
 /*
  * 
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.20 2002/12/26 12:40:01 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.21 2003/02/01 06:23:36 thorpej Exp $");
 
 #ifdef _LKM
 #define        NVCODA 4
@@ -71,6 +71,8 @@
 /* for VN_RDEV */
 #include <miscfs/specfs/specdev.h>
 
+MALLOC_DEFINE(M_CODA, "coda", "Coda file system structures and tables");
+
 int codadebug = 0;
 
 int coda_vfsop_print_entry = 0;
diff -r 7a17d697bdee -r 41438970729a sys/dev/audio_if.h
--- a/sys/dev/audio_if.h        Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/audio_if.h        Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: audio_if.h,v 1.46 2002/06/04 14:02:32 isaki Exp $      */
+/*     $NetBSD: audio_if.h,v 1.47 2003/02/01 06:23:36 thorpej Exp $    */
 
 /*
  * Copyright (c) 1994 Havard Eidnes.
@@ -69,6 +69,7 @@
 /* The default audio mode: 8 kHz mono ulaw */
 extern struct audio_params audio_default;
 
+struct malloc_type;
 struct audio_hw_if {
        int     (*open)(void *, int);   /* open hardware */
        void    (*close)(void *);       /* close hardware */
@@ -124,8 +125,8 @@
        int     (*query_devinfo)(void *, mixer_devinfo_t *);
 
        /* Allocate/free memory for the ring buffer. Usually malloc/free. */
-       void    *(*allocm)(void *, int, size_t, int, int);
-       void    (*freem)(void *, void *, int);
+       void    *(*allocm)(void *, int, size_t, struct malloc_type *, int);
+       void    (*freem)(void *, void *, struct malloc_type *);
        size_t  (*round_buffersize)(void *, int, size_t);
        paddr_t (*mappage)(void *, void *, off_t, int);
 
diff -r 7a17d697bdee -r 41438970729a sys/dev/ic/interwave.c
--- a/sys/dev/ic/interwave.c    Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/ic/interwave.c    Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: interwave.c,v 1.15 2002/02/06 14:50:42 pooka Exp $     */
+/*     $NetBSD: interwave.c,v 1.16 2003/02/01 06:23:37 thorpej Exp $   */
 
 /*
  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.15 2002/02/06 14:50:42 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interwave.c,v 1.16 2003/02/01 06:23:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1615,7 +1615,8 @@
        void    *addr;
        int     direction;
        size_t  size;
-       int     pool, flags;
+       struct malloc_type *pool;
+       int     flags;
 {
        struct iw_softc *sc = addr;
        int drq;
@@ -1631,7 +1632,7 @@
 iw_free(addr, ptr, pool)
        void    *addr;
        void    *ptr;
-       int     pool;
+       struct malloc_type *pool;
 {
        isa_free(ptr, pool);
 }
diff -r 7a17d697bdee -r 41438970729a sys/dev/ic/interwavevar.h
--- a/sys/dev/ic/interwavevar.h Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/ic/interwavevar.h Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: interwavevar.h,v 1.8 2000/06/26 04:56:18 simonb Exp $  */
+/*     $NetBSD: interwavevar.h,v 1.9 2003/02/01 06:23:37 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
@@ -247,8 +247,9 @@
 
 int     iw_query_devinfo __P((void *, mixer_devinfo_t *));
 
-void *  iw_malloc __P((void *, int, size_t, int, int));
-void    iw_free __P((void *,void *,int));
+struct malloc_type;
+void *  iw_malloc __P((void *, int, size_t, struct malloc_type *, int));
+void    iw_free __P((void *,void *,struct malloc_type *));
 size_t iw_round_buffersize __P((void *, int, size_t));
 paddr_t        iw_mappage __P((void *, void *, off_t, int));
 int     iw_get_props __P((void *));
diff -r 7a17d697bdee -r 41438970729a sys/dev/isa/ad1848_isa.c
--- a/sys/dev/isa/ad1848_isa.c  Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/isa/ad1848_isa.c  Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ad1848_isa.c,v 1.21 2002/03/06 07:12:04 itohy Exp $    */
+/*     $NetBSD: ad1848_isa.c,v 1.22 2003/02/01 06:23:37 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ad1848_isa.c,v 1.21 2002/03/06 07:12:04 itohy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ad1848_isa.c,v 1.22 2003/02/01 06:23:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -729,7 +729,8 @@
        void *addr;
        int direction;
        size_t size;
-       int pool, flags;
+       struct malloc_type *pool;
+       int flags;
 {
        struct ad1848_isa_softc *isc = addr;
        int drq;
@@ -745,7 +746,7 @@
 ad1848_isa_free(addr, ptr, pool)
        void *addr;
        void *ptr;
-       int pool;
+       struct malloc_type *pool;
 {
        isa_free(ptr, pool);
 }
diff -r 7a17d697bdee -r 41438970729a sys/dev/isa/ad1848var.h
--- a/sys/dev/isa/ad1848var.h   Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/isa/ad1848var.h   Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ad1848var.h,v 1.35 2000/12/18 21:31:32 thorpej Exp $   */
+/*     $NetBSD: ad1848var.h,v 1.36 2003/02/01 06:23:37 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -121,8 +121,8 @@
 
 int    ad1848_isa_intr (void *);
 
-void   *ad1848_isa_malloc (void *, int, size_t, int, int);
-void   ad1848_isa_free (void *, void *, int);
+void   *ad1848_isa_malloc (void *, int, size_t, struct malloc_type *, int);
+void   ad1848_isa_free (void *, void *, struct malloc_type *);
 size_t ad1848_isa_round_buffersize (void *, int, size_t);
 paddr_t        ad1848_isa_mappage (void *, void *, off_t, int);
 int    ad1848_isa_get_props (void *);
diff -r 7a17d697bdee -r 41438970729a sys/dev/isa/ess.c
--- a/sys/dev/isa/ess.c Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/isa/ess.c Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ess.c,v 1.55 2001/11/13 08:01:13 lukem Exp $   */
+/*     $NetBSD: ess.c,v 1.56 2003/02/01 06:23:37 thorpej Exp $ */
 
 /*
  * Copyright 1997
@@ -66,7 +66,7 @@
 */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ess.c,v 1.55 2001/11/13 08:01:13 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ess.c,v 1.56 2003/02/01 06:23:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -146,8 +146,8 @@
 int    ess_set_port __P((void *, mixer_ctrl_t *));
 int    ess_get_port __P((void *, mixer_ctrl_t *));
 
-void   *ess_malloc __P((void *, int, size_t, int, int));
-void   ess_free __P((void *, void *, int));
+void   *ess_malloc __P((void *, int, size_t, struct malloc_type *, int));
+void   ess_free __P((void *, void *, struct malloc_type *));
 size_t ess_round_buffersize __P((void *, int, size_t));
 paddr_t        ess_mappage __P((void *, void *, off_t, int));
 
@@ -2168,7 +2168,8 @@
        void *addr;
        int direction;
        size_t size;
-       int pool, flags;
+       struct malloc_type *pool;
+       int flags;
 {
        struct ess_softc *sc = addr;
        int drq;
@@ -2184,7 +2185,7 @@
 ess_free(addr, ptr, pool)
        void *addr;
        void *ptr;
-       int pool;
+       struct malloc_type *pool;
 {
        isa_free(ptr, pool);
 }
diff -r 7a17d697bdee -r 41438970729a sys/dev/isa/isadma.c
--- a/sys/dev/isa/isadma.c      Sat Feb 01 05:03:42 2003 +0000
+++ b/sys/dev/isa/isadma.c      Sat Feb 01 06:23:35 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isadma.c,v 1.50 2002/09/27 15:37:22 provos Exp $       */
+/*     $NetBSD: isadma.c,v 1.51 2003/02/01 06:23:37 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.50 2002/09/27 15:37:22 provos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma.c,v 1.51 2003/02/01 06:23:37 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -748,7 +748,7 @@
        struct isa_dma_state *ids;
        int chan;
        size_t size;
-       int pool;
+       struct malloc_type *pool;



Home | Main Index | Thread Index | Old Index