aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/slab.h
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2013-01-10 14:14:19 -0500
committerPekka Enberg <penberg@kernel.org>2013-02-01 05:32:07 -0500
commit95a05b428cc675694321c8f762591984f3fd2b1e (patch)
tree3a74205955201dd5e1abb0a85104d95cafa49df6 /include/linux/slab.h
parent6a67368c36e2c0c2578ba62f6264ab739af08cce (diff)
slab: Common constants for kmalloc boundaries
Standardize the constants that describe the smallest and largest object kept in the kmalloc arrays for SLAB and SLUB. Differentiate between the maximum size for which a slab cache is used (KMALLOC_MAX_CACHE_SIZE) and the maximum allocatable size (KMALLOC_MAX_SIZE, KMALLOC_MAX_ORDER). Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r--include/linux/slab.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index c97fe92532d1..c01780540054 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -163,7 +163,12 @@ struct kmem_cache {
163#else /* CONFIG_SLOB */ 163#else /* CONFIG_SLOB */
164 164
165/* 165/*
166 * The largest kmalloc size supported by the slab allocators is 166 * Kmalloc array related definitions
167 */
168
169#ifdef CONFIG_SLAB
170/*
171 * The largest kmalloc size supported by the SLAB allocators is
167 * 32 megabyte (2^25) or the maximum allocatable page order if that is 172 * 32 megabyte (2^25) or the maximum allocatable page order if that is
168 * less than 32 MB. 173 * less than 32 MB.
169 * 174 *
@@ -173,9 +178,24 @@ struct kmem_cache {
173 */ 178 */
174#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \ 179#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \
175 (MAX_ORDER + PAGE_SHIFT - 1) : 25) 180 (MAX_ORDER + PAGE_SHIFT - 1) : 25)
181#define KMALLOC_SHIFT_MAX KMALLOC_SHIFT_HIGH
182#define KMALLOC_SHIFT_LOW 5
183#else
184/*
185 * SLUB allocates up to order 2 pages directly and otherwise
186 * passes the request to the page allocator.
187 */
188#define KMALLOC_SHIFT_HIGH (PAGE_SHIFT + 1)
189#define KMALLOC_SHIFT_MAX (MAX_ORDER + PAGE_SHIFT)
190#define KMALLOC_SHIFT_LOW 3
191#endif
176 192
177#define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_HIGH) 193/* Maximum allocatable size */
178#define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_HIGH - PAGE_SHIFT) 194#define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_MAX)
195/* Maximum size for which we actually use a slab cache */
196#define KMALLOC_MAX_CACHE_SIZE (1UL << KMALLOC_SHIFT_HIGH)
197/* Maximum order allocatable via the slab allocagtor */
198#define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_MAX - PAGE_SHIFT)
179 199
180/* 200/*
181 * Kmalloc subsystem. 201 * Kmalloc subsystem.
@@ -183,15 +203,9 @@ struct kmem_cache {
183#if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8 203#if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8
184#define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN 204#define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN
185#else 205#else
186#ifdef CONFIG_SLAB 206#define KMALLOC_MIN_SIZE (1 << KMALLOC_SHIFT_LOW)
187#define KMALLOC_MIN_SIZE 32
188#else
189#define KMALLOC_MIN_SIZE 8
190#endif
191#endif 207#endif
192 208
193#define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE)
194
195/* 209/*
196 * Figure out which kmalloc slab an allocation of a certain size 210 * Figure out which kmalloc slab an allocation of a certain size
197 * belongs to. 211 * belongs to.