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/sys/slaballoc.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  * KERN_SLABALLOC.H     - Kernel SLAB memory allocator
    3  * 
    4  * Copyright (c) 2003,2004 The DragonFly Project.  All rights reserved.
    5  * 
    6  * This code is derived from software contributed to The DragonFly Project
    7  * by Matthew Dillon <dillon@backplane.com>
    8  * 
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in
   17  *    the documentation and/or other materials provided with the
   18  *    distribution.
   19  * 3. Neither the name of The DragonFly Project nor the names of its
   20  *    contributors may be used to endorse or promote products derived
   21  *    from this software without specific, prior written permission.
   22  * 
   23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   24  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
   27  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   28  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
   29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   31  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  * 
   36  * $DragonFly: src/sys/sys/slaballoc.h,v 1.8 2005/06/20 20:49:12 dillon Exp $
   37  */
   38 
   39 #ifndef _SYS_SLABALLOC_H_
   40 #define _SYS_SLABALLOC_H_
   41 
   42 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
   43 
   44 #ifndef _SYS_STDINT_H_
   45 #include <sys/stdint.h>
   46 #endif
   47 #ifndef _SYS_MALLOC_H_
   48 #include <sys/malloc.h>
   49 #endif
   50 
   51 /*
   52  * Note that any allocations which are exact multiples of PAGE_SIZE, or
   53  * which are >= ZALLOC_ZONE_LIMIT, will fall through to the kmem subsystem.
   54  */
   55 #define ZALLOC_ZONE_LIMIT       (16 * 1024)     /* max slab-managed alloc */
   56 #define ZALLOC_MIN_ZONE_SIZE    (32 * 1024)     /* minimum zone size */
   57 #define ZALLOC_MAX_ZONE_SIZE    (128 * 1024)    /* maximum zone size */
   58 #define ZALLOC_SLAB_MAGIC       0x736c6162      /* magic sanity */
   59 #define ZALLOC_OVSZ_MAGIC       0x736c6163      /* magic sanity */
   60 #define ZALLOC_SLAB_SLIDE       20
   61 
   62 
   63 #if ZALLOC_ZONE_LIMIT == 16384
   64 #define NZONES                  72
   65 #elif ZALLOC_ZONE_LIMIT == 32768
   66 #define NZONES                  80
   67 #else
   68 #error "I couldn't figure out NZONES"
   69 #endif
   70 
   71 /*
   72  * Chunk structure for free elements
   73  */
   74 typedef struct SLChunk {
   75     struct SLChunk *c_Next;
   76 } SLChunk;
   77 
   78 #if defined(SLAB_DEBUG)
   79 /*
   80  * Only used for kernels compiled w/SLAB_DEBUG
   81  */
   82 struct ZSources {
   83     const char *file;
   84     int line;
   85 };
   86 
   87 #endif
   88 
   89 /*
   90  * The IN-BAND zone header is placed at the beginning of each zone.
   91  *
   92  * NOTE! All fields are cpu-local except z_RChunks.  Remote cpus free
   93  *       chunks using atomic ops to z_RChunks and then signal local
   94  *       cpus as necessary.
   95  */
   96 typedef struct SLZone {
   97     __int32_t   z_Magic;        /* magic number for sanity check */
   98     int         z_Cpu;          /* which cpu owns this zone? */
   99     struct globaldata *z_CpuGd; /* which cpu owns this zone? */
  100     struct SLZone *z_Next;      /* ZoneAry[] link if z_NFree non-zero */
  101     int         z_NFree;        /* total free chunks / ualloc space in zone */
  102     int         z_NMax;         /* maximum free chunks */
  103     char        *z_BasePtr;     /* pointer to start of chunk array */
  104     int         z_UIndex;       /* current initial allocation index */
  105     int         z_UEndIndex;    /* last (first) allocation index */
  106     int         z_ChunkSize;    /* chunk size for validation */
  107     int         z_ZoneIndex;
  108     int         z_Flags;
  109     SLChunk     *z_LChunks;     /* linked list of chunks current cpu */
  110     SLChunk     **z_LChunksp;   /* tailp */
  111     SLChunk     *z_RChunks;     /* linked list of chunks remote cpu */
  112     int         z_RSignal;      /* signal interlock */
  113     int         z_RCount;       /* prevent local destruction w/inflight ipis */
  114 #if defined(SLAB_DEBUG)
  115 #define SLAB_DEBUG_ENTRIES      32      /* must be power of 2 */
  116     struct ZSources z_Sources[SLAB_DEBUG_ENTRIES];
  117     struct ZSources z_AltSources[SLAB_DEBUG_ENTRIES];
  118 #endif
  119 #if defined(INVARIANTS)
  120     __uint32_t  z_Bitmap[];     /* bitmap of free chunks for sanity check */
  121 #endif
  122 } SLZone;
  123 
  124 #define SLZF_UNOTZEROD          0x0001
  125 
  126 typedef struct SLGlobalData {
  127     SLZone      *ZoneAry[NZONES];       /* linked list of zones NFree > 0 */
  128     SLZone      *FreeZones;             /* whole zones that have become free */
  129     SLZone      *FreeOvZones;           /* oversized zones */
  130     int         NFreeZones;             /* free zone count */
  131     int         JunkIndex;
  132     struct malloc_type ZoneInfo;        /* stats on meta-zones allocated */
  133 } SLGlobalData;
  134 
  135 #endif  /* _KERNEL */
  136 
  137 #endif  /* _SYS_SLABALLOC_H_ */
  138 

Cache object: fc4fe1800c7dbecdae131aa4eba9dd75


[ 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.