13 #include <linux/types.h>
19 #define SLAB_DEBUG_FREE 0x00000100UL
20 #define SLAB_RED_ZONE 0x00000400UL
21 #define SLAB_POISON 0x00000800UL
22 #define SLAB_HWCACHE_ALIGN 0x00002000UL
23 #define SLAB_CACHE_DMA 0x00004000UL
24 #define SLAB_STORE_USER 0x00010000UL
25 #define SLAB_PANIC 0x00040000UL
54 #define SLAB_DESTROY_BY_RCU 0x00080000UL
55 #define SLAB_MEM_SPREAD 0x00100000UL
56 #define SLAB_TRACE 0x00200000UL
59 #ifdef CONFIG_DEBUG_OBJECTS
60 # define SLAB_DEBUG_OBJECTS 0x00400000UL
62 # define SLAB_DEBUG_OBJECTS 0x00000000UL
65 #define SLAB_NOLEAKTRACE 0x00800000UL
68 #ifdef CONFIG_KMEMCHECK
69 # define SLAB_NOTRACK 0x01000000UL
71 # define SLAB_NOTRACK 0x00000000UL
73 #ifdef CONFIG_FAILSLAB
74 # define SLAB_FAILSLAB 0x02000000UL
76 # define SLAB_FAILSLAB 0x00000000UL
80 #define SLAB_RECLAIM_ACCOUNT 0x00020000UL
81 #define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT
90 #define ZERO_SIZE_PTR ((void *)16)
92 #define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
93 (unsigned long)ZERO_SIZE_PTR)
141 #define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\
142 sizeof(struct __struct), __alignof__(struct __struct),\
154 #define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \
155 (MAX_ORDER + PAGE_SHIFT - 1) : 25)
157 #define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_HIGH)
158 #define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_HIGH - PAGE_SHIFT)
165 #ifdef ARCH_DMA_MINALIGN
166 #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
168 #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
176 #ifndef ARCH_SLAB_MINALIGN
177 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
185 void kfree(
const void *);
186 void kzfree(
const void *);
187 size_t ksize(
const void *);
210 #elif defined(CONFIG_SLOB)
269 if (size != 0 && n >
SIZE_MAX / size)
280 static inline void *kcalloc(
size_t n,
size_t size,
gfp_t flags)
282 return kmalloc_array(n, size, flags |
__GFP_ZERO);
285 #if !defined(CONFIG_NUMA) && !defined(CONFIG_SLOB)
296 static inline void *kmalloc_node(
size_t size,
gfp_t flags,
int node)
301 static inline void *__kmalloc_node(
size_t size,
gfp_t flags,
int node)
308 static inline void *kmem_cache_alloc_node(
struct kmem_cache *cachep,
323 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
324 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
325 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
327 #define kmalloc_track_caller(size, flags) \
328 __kmalloc_track_caller(size, flags, _RET_IP_)
330 #define kmalloc_track_caller(size, flags) \
331 __kmalloc(size, flags)
343 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
344 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
345 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
346 extern void *__kmalloc_node_track_caller(
size_t,
gfp_t,
int,
unsigned long);
347 #define kmalloc_node_track_caller(size, flags, node) \
348 __kmalloc_node_track_caller(size, flags, node, \
351 #define kmalloc_node_track_caller(size, flags, node) \
352 __kmalloc_node(size, flags, node)
357 #define kmalloc_node_track_caller(size, flags, node) \
358 kmalloc_track_caller(size, flags)
375 static inline void *kzalloc(
size_t size,
gfp_t flags)
386 static inline void *kzalloc_node(
size_t size,
gfp_t flags,
int node)
388 return kmalloc_node(size, flags |
__GFP_ZERO, node);