The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/zalloc.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993,1991,1990,1989,1988,1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        zalloc.h,v $
   29  * Revision 2.10  93/11/17  17:34:29  dbg
   30  *      Added ANSI function prototypes.
   31  *      [93/01/27            dbg]
   32  * 
   33  * Revision 2.9  91/05/18  14:34:57  rpd
   34  *      Removed ZALLOC, ZGET, ZFREE.
   35  *      Moved ADD_TO_ZONE, REMOVE_FROM_ZONE to kern/zalloc.c.
   36  *      Moved extraneous zone GC declarations to kern/zalloc.c.
   37  *      [91/03/31            rpd]
   38  *      Added zdata, zdata_size.
   39  *      [91/03/22            rpd]
   40  * 
   41  * Revision 2.8  91/05/14  16:50:52  mrt
   42  *      Correcting copyright
   43  * 
   44  * Revision 2.7  91/02/05  17:31:33  mrt
   45  *      Changed to new Mach copyright
   46  *      [91/02/01  16:22:11  mrt]
   47  * 
   48  * Revision 2.6  91/01/08  15:18:37  rpd
   49  *      Removed COLLECT_ZONE_GARBAGE.  Added consider_zone_gc.
   50  *      [91/01/03            rpd]
   51  * 
   52  * Revision 2.5  90/12/20  16:39:32  jeffreyh
   53  *      Merged in changes done by jvs@osf from OSF/1 
   54  *      [90/12/10            jeffreyh]
   55  * 
   56  * Revision 2.4  90/06/02  14:57:37  rpd
   57  *      Use decl_simple_lock_data for the zone structure lock.
   58  *      [90/04/23            rpd]
   59  * 
   60  * Revision 2.3  89/11/29  14:09:29  af
   61  *      Now we know that collectible zones worked on mips all the time.
   62  *      [89/11/16  15:05:58  af]
   63  * 
   64  *      Made obvious that mips cannot collect zone garbage for now.
   65  *      [89/10/28            af]
   66  * 
   67  * Revision 2.2  89/08/11  17:56:27  rwd
   68  *      Added collectible zones.  Collectible zones allow storage to be
   69  *      returned to system via kmem_free when pages are no longer used.
   70  *      This option should only be used when zone memory is virtual
   71  *      (rather than physical as in a MIPS architecture).
   72  *      [89/07/22            rfr]
   73  * 
   74  * Revision 2.8  89/05/11  14:41:36  gm0w
   75  *      Added next_zone field, to link all zones onto a list.
   76  *      [89/05/08  21:35:14  rpd]
   77  * 
   78  * Revision 2.7  89/03/09  20:17:58  rpd
   79  *      More cleanup.
   80  * 
   81  * Revision 2.6  89/02/25  18:11:22  gm0w
   82  *      Kernel code cleanup.
   83  *      Put macros under #indef KERNEL.
   84  *      [89/02/15            mrt]
   85  * 
   86  * Revision 2.5  89/02/07  01:06:22  mwyoung
   87  * Relocated from sys/zalloc.h
   88  * 
   89  * Revision 2.4  89/01/15  16:36:01  rpd
   90  *      Use decl_simple_lock_data.
   91  *      [89/01/15  15:20:28  rpd]
   92  * 
   93  * Revision 2.3  88/12/19  02:52:11  mwyoung
   94  *      Use MACRO_BEGIN and MACRO_END.  This corrects a problem
   95  *      in the ZGET macro under lint.
   96  *      [88/12/09            mwyoung]
   97  * 
   98  * Revision 2.2  88/08/24  02:56:21  mwyoung
   99  *      Adjusted include file references.
  100  *      [88/08/17  02:30:22  mwyoung]
  101  *
  102  *  8-Jan-88  Rick Rashid (rfr) at Carnegie-Mellon University
  103  *      Pageable zone lock added. NOTE ZALLOC and ZFREE macros assume
  104  *      non-pageable zones.
  105  *
  106  * 30-Sep-87  Michael Young (mwyoung) at Carnegie-Mellon University
  107  *      Make ZALLOC, ZFREE not macros for lint.
  108  *
  109  * 12-Sep-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  110  *      Modified to use a list instead of a queue - no need for expense
  111  *      of queue.  Also removed warning about assembly language hacks as
  112  *      there are none left that I know of.
  113  *
  114  *  1-Sep-87  Michael Young (mwyoung) at Carnegie-Mellon University
  115  *      Added zchange() declaration; added sleepable, exhaustible flags.
  116  *
  117  * 18-Apr-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  118  *      Added ZALLOC and ZGET macros, note that the arguments are
  119  *      different that zalloc and zget due to language restrictions.
  120  *      For consistency, also made a ZFREE macro, zfree is now always
  121  *      a procedure call.
  122  *
  123  * 15-Apr-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  124  *      Added warning about implementations that inline expand zalloc
  125  *      and zget.
  126  *
  127  * 23-Mar-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  128  *      Simplified zfree macro.
  129  *
  130  *  9-Mar-87  Michael Young (mwyoung) at Carnegie-Mellon University
  131  *      Make zfree a macro: a big win on a register-based machine
  132  *      with expensive procedure call; smaller change elsewhere.
  133  *
  134  *  3-Mar-87  Michael Young (mwyoung) at Carnegie-Mellon University
  135  *      Reduce include of "../h/types.h" to "../mach/machine/vm_types.h".
  136  *
  137  * 12-Feb-87  Robert Sansom (rds) at Carnegie Mellon University
  138  *      Added zget.
  139  *
  140  * 12-Jan-87  Michael Young (mwyoung) at Carnegie-Mellon University
  141  *      Eliminated use of the interlocked queue package.
  142  *
  143  *  9-Jun-85  Avadis Tevanian (avie) at Carnegie-Mellon University
  144  *      Created.
  145  */
  146 /*
  147  *      File:   zalloc.h
  148  *      Author: Avadis Tevanian, Jr.
  149  *      Date:    1985
  150  *
  151  */
  152 
  153 #ifndef _KERN_ZALLOC_H_
  154 #define _KERN_ZALLOC_H_
  155 
  156 #include <mach/machine/vm_types.h>
  157 #include <kern/lock.h>
  158 #include <kern/queue.h>
  159 
  160 /*
  161  *      A zone is a collection of fixed size blocks for which there
  162  *      is fast allocation/deallocation access.  Kernel routines can
  163  *      use zones to manage data structures dynamically, creating a zone
  164  *      for each type of data structure to be managed.
  165  *
  166  */
  167 
  168 typedef struct zone {
  169         decl_simple_lock_data(,lock)    /* generic lock */
  170         int             count;          /* Number of elements used now */
  171         vm_offset_t     free_elements;
  172         vm_size_t       cur_size;       /* current memory utilization */
  173         vm_size_t       max_size;       /* how large can this zone grow */
  174         vm_size_t       elem_size;      /* size of an element */
  175         vm_size_t       alloc_size;     /* size used for more memory */
  176         boolean_t       doing_alloc;    /* is zone expanding now? */
  177         char            *zone_name;     /* a name for the zone */
  178         unsigned int
  179         /* boolean_t */ pageable :1,    /* zone pageable? */
  180         /* boolean_t */ sleepable :1,   /* sleep if empty? */
  181         /* boolean_t */ exhaustible :1, /* merely return if empty? */
  182         /* boolean_t */ collectable :1, /* garbage collect empty pages */
  183         /* boolean_t */ expandable :1;  /* expand zone (with message)? */
  184         lock_data_t     complex_lock;   /* Lock for pageable zones */
  185         struct zone *   next_zone;      /* Link for all-zones list */
  186 } *zone_t;
  187 
  188 #define         ZONE_NULL       ((zone_t) 0)
  189 
  190 extern void             zone_gc(void);
  191 extern void             consider_zone_gc(void);
  192 
  193 extern vm_offset_t      zalloc(
  194         zone_t  zone);
  195 extern vm_offset_t      zget(
  196         zone_t  zone);
  197 extern zone_t           zinit(
  198         vm_size_t       size,           /* the size of an element */
  199         vm_size_t       max,            /* maximum memory to use */
  200         vm_size_t       alloc,          /* allocation size */
  201         boolean_t       pageable,       /* is this zone pageable? */
  202         char            *name);         /* a name for the zone */
  203 extern void             zfree(
  204         zone_t  zone,
  205         vm_offset_t elem);
  206 extern void             zchange(
  207         zone_t          zone,
  208         boolean_t       pageable,
  209         boolean_t       sleepable,
  210         boolean_t       exhaustible,
  211         boolean_t       collectable);
  212 extern void             zcollectable(
  213         zone_t  zone);
  214 
  215 extern vm_offset_t      zdata;
  216 extern vm_offset_t      zdata_size;
  217 
  218 extern void             zcram(
  219         zone_t          zone,
  220         vm_offset_t     newmem,
  221         vm_size_t       size);
  222 extern void             zone_bootstrap(void);
  223 extern void             zone_init(void);
  224 
  225 #endif  /* _KERN_ZALLOC_H_ */

Cache object: 22350dfbcf3b4a5ca7ae7296a0ed9606


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.