diff options
author | Richard Braun <rbraun@sceen.net> | 2013-04-19 20:09:42 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-08-26 16:29:35 +0200 |
commit | 6a0f92326547fd13dd0824973da6668c9eb7d201 (patch) | |
tree | fc555fef058a4ccca1a54cc2e2ea87bb4ce906af /kern/slab.h | |
parent | 8f33c42eb691ddfd15749058a597594f19f20f43 (diff) |
kern/slab: move internal data to slab_i.h
As it's done for other modules, this separation makes the public interface
easy to identify.
Diffstat (limited to 'kern/slab.h')
-rw-r--r-- | kern/slab.h | 133 |
1 files changed, 3 insertions, 130 deletions
diff --git a/kern/slab.h b/kern/slab.h index 64daa61..9466f2d 100644 --- a/kern/slab.h +++ b/kern/slab.h @@ -48,82 +48,14 @@ #define _KERN_SLAB_H #include <cache.h> -#include <kern/lock.h> -#include <kern/list.h> #include <mach/machine/vm_types.h> #include <sys/types.h> #include <vm/vm_types.h> -#if SLAB_USE_CPU_POOLS /* - * L1 cache line size. + * Object cache. */ -#define CPU_L1_SIZE (1 << CPU_L1_SHIFT) - -/* - * Per-processor cache of pre-constructed objects. - * - * The flags member is a read-only CPU-local copy of the parent cache flags. - */ -struct kmem_cpu_pool { - simple_lock_data_t lock; - int flags; - int size; - int transfer_size; - int nr_objs; - void **array; -} __attribute__((aligned(CPU_L1_SIZE))); - -/* - * When a cache is created, its CPU pool type is determined from the buffer - * size. For small buffer sizes, many objects can be cached in a CPU pool. - * Conversely, for large buffer sizes, this would incur much overhead, so only - * a few objects are stored in a CPU pool. - */ -struct kmem_cpu_pool_type { - size_t buf_size; - int array_size; - size_t array_align; - struct kmem_cache *array_cache; -}; -#endif /* SLAB_USE_CPU_POOLS */ - -/* - * Buffer descriptor. - * - * For normal caches (i.e. without SLAB_CF_VERIFY), bufctls are located at the - * end of (but inside) each buffer. If SLAB_CF_VERIFY is set, bufctls are - * located after each buffer. - * - * When an object is allocated to a client, its bufctl isn't used. This memory - * is instead used for redzoning if cache debugging is in effect. - */ -union kmem_bufctl { - union kmem_bufctl *next; - unsigned long redzone; -}; - -/* - * Buffer tag. - * - * This structure is only used for SLAB_CF_VERIFY caches. It is located after - * the bufctl and includes information about the state of the buffer it - * describes (allocated or not). It should be thought of as a debugging - * extension of the bufctl. - */ -struct kmem_buftag { - unsigned long state; -}; - -/* - * Page-aligned collection of unconstructed buffers. - */ -struct kmem_slab { - struct list node; - unsigned long nr_refs; - union kmem_bufctl *first_free; - void *addr; -}; +struct kmem_cache; /* * Type for constructor functions. @@ -145,66 +77,7 @@ typedef void (*kmem_cache_ctor_t)(void *obj); typedef vm_offset_t (*kmem_slab_alloc_fn_t)(vm_size_t); typedef void (*kmem_slab_free_fn_t)(vm_offset_t, vm_size_t); -/* - * Cache name buffer size. The size is chosen so that struct - * kmem_cache fits into two cache lines. The size of a cache line on - * a typical CPU is 64 bytes. - */ -#define KMEM_CACHE_NAME_SIZE 24 - -/* - * Cache flags. - * - * The flags don't change once set and can be tested without locking. - */ -#define KMEM_CF_NO_CPU_POOL 0x1 /* CPU pool layer disabled */ -#define KMEM_CF_SLAB_EXTERNAL 0x2 /* Slab data is off slab */ -#define KMEM_CF_VERIFY 0x4 /* Debugging facilities enabled */ -#define KMEM_CF_DIRECT 0x8 /* Quick buf-to-slab lookup */ - -/* - * Cache of objects. - * - * Locking order : cpu_pool -> cache. CPU pools locking is ordered by CPU ID. - * - * Currently, SLAB_USE_CPU_POOLS is not defined. KMEM_CACHE_NAME_SIZE - * is chosen so that the struct fits into two cache lines. The first - * cache line contains all hot fields. - */ -struct kmem_cache { -#if SLAB_USE_CPU_POOLS - /* CPU pool layer */ - struct kmem_cpu_pool cpu_pools[NCPUS]; - struct kmem_cpu_pool_type *cpu_pool_type; -#endif /* SLAB_USE_CPU_POOLS */ - - /* Slab layer */ - simple_lock_data_t lock; - struct list node; /* Cache list linkage */ - struct list partial_slabs; - struct list free_slabs; - int flags; - size_t bufctl_dist; /* Distance from buffer to bufctl */ - size_t slab_size; - unsigned long bufs_per_slab; - unsigned long nr_objs; /* Number of allocated objects */ - unsigned long nr_free_slabs; - kmem_cache_ctor_t ctor; - /* All fields below are cold */ - size_t obj_size; /* User-provided size */ - /* Assuming ! SLAB_USE_CPU_POOLS, here is the cacheline boundary */ - size_t align; - size_t buf_size; /* Aligned object size */ - size_t color; - size_t color_max; - unsigned long nr_bufs; /* Total number of buffers */ - unsigned long nr_slabs; - kmem_slab_alloc_fn_t slab_alloc_fn; - kmem_slab_free_fn_t slab_free_fn; - char name[KMEM_CACHE_NAME_SIZE]; - size_t buftag_dist; /* Distance from buffer to buftag */ - size_t redzone_pad; /* Bytes from end of object to redzone word */ -} __cacheline_aligned; +#include <kern/slab_i.h> /* * Mach-style declarations for struct kmem_cache. |