1 #ifndef _LINUX_SLUB_DEF_H
2 #define _LINUX_SLUB_DEF_H
9 #include <linux/types.h>
51 #ifdef CONFIG_SLUB_STATS
60 #ifdef CONFIG_SLUB_DEBUG
109 int remote_node_defrag_ratio;
117 #if defined(ARCH_DMA_MINALIGN) && ARCH_DMA_MINALIGN > 8
118 #define KMALLOC_MIN_SIZE ARCH_DMA_MINALIGN
120 #define KMALLOC_MIN_SIZE 8
123 #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE)
134 #define SLUB_MAX_SIZE (2 * PAGE_SIZE)
136 #define SLUB_PAGE_SHIFT (PAGE_SHIFT + 2)
138 #ifdef CONFIG_ZONE_DMA
139 #define SLUB_DMA __GFP_DMA
142 #define SLUB_DMA (__force gfp_t)0
163 if (KMALLOC_MIN_SIZE <= 32 && size > 64 && size <= 96)
165 if (KMALLOC_MIN_SIZE <= 64 && size > 128 && size <= 192)
167 if (size <= 8)
return 3;
168 if (size <= 16)
return 4;
169 if (size <= 32)
return 5;
170 if (size <= 64)
return 6;
171 if (size <= 128)
return 7;
172 if (size <= 256)
return 8;
173 if (size <= 512)
return 9;
174 if (size <= 1024)
return 10;
175 if (size <= 2 * 1024)
return 11;
176 if (size <= 4 * 1024)
return 12;
182 if (size <= 8 * 1024)
return 13;
183 if (size <= 16 * 1024)
return 14;
184 if (size <= 32 * 1024)
return 15;
185 if (size <= 64 * 1024)
return 16;
186 if (size <= 128 * 1024)
return 17;
187 if (size <= 256 * 1024)
return 18;
188 if (size <= 512 * 1024)
return 19;
189 if (size <= 1024 * 1024)
return 20;
190 if (size <= 2 * 1024 * 1024)
return 21;
211 int index = kmalloc_index(size);
216 return kmalloc_caches[
index];
234 #ifdef CONFIG_SLUB_DEBUG
235 extern bool verify_mem_not_deleted(
const void *
x);
237 static inline bool verify_mem_not_deleted(
const void *
x)
243 #ifdef CONFIG_TRACING
246 extern void *kmalloc_order_trace(
size_t size,
gfp_t flags,
unsigned int order);
255 kmalloc_order_trace(
size_t size,
gfp_t flags,
unsigned int order)
257 return kmalloc_order(size, flags, order);
264 return kmalloc_order_trace(size, flags, order);
269 if (__builtin_constant_p(size)) {
271 return kmalloc_large(size, flags);
279 return kmem_cache_alloc_trace(s, flags, size);
289 #ifdef CONFIG_TRACING
290 extern void *kmem_cache_alloc_node_trace(
struct kmem_cache *
s,
292 int node,
size_t size);
297 int node,
size_t size)
305 if (__builtin_constant_p(size) &&
312 return kmem_cache_alloc_node_trace(s, flags, node, size);