aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/slub_def.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/slub_def.h')
-rw-r--r--include/linux/slub_def.h33
1 files changed, 8 insertions, 25 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 6207a3d8da71..07f7e4cbcee3 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -16,7 +16,9 @@ struct kmem_cache_node {
16 unsigned long nr_partial; 16 unsigned long nr_partial;
17 atomic_long_t nr_slabs; 17 atomic_long_t nr_slabs;
18 struct list_head partial; 18 struct list_head partial;
19#ifdef CONFIG_SLUB_DEBUG
19 struct list_head full; 20 struct list_head full;
21#endif
20}; 22};
21 23
22/* 24/*
@@ -44,7 +46,9 @@ struct kmem_cache {
44 int align; /* Alignment */ 46 int align; /* Alignment */
45 const char *name; /* Name (only for display!) */ 47 const char *name; /* Name (only for display!) */
46 struct list_head list; /* List of slab caches */ 48 struct list_head list; /* List of slab caches */
49#ifdef CONFIG_SLUB_DEBUG
47 struct kobject kobj; /* For sysfs */ 50 struct kobject kobj; /* For sysfs */
51#endif
48 52
49#ifdef CONFIG_NUMA 53#ifdef CONFIG_NUMA
50 int defrag_ratio; 54 int defrag_ratio;
@@ -159,17 +163,8 @@ static inline struct kmem_cache *kmalloc_slab(size_t size)
159#define SLUB_DMA 0 163#define SLUB_DMA 0
160#endif 164#endif
161 165
162 166void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
163/* 167void *__kmalloc(size_t size, gfp_t flags);
164 * ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
165 *
166 * Dereferencing ZERO_SIZE_PTR will lead to a distinct access fault.
167 *
168 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
169 * Both make kfree a no-op.
170 */
171#define ZERO_SIZE_PTR ((void *)16)
172
173 168
174static inline void *kmalloc(size_t size, gfp_t flags) 169static inline void *kmalloc(size_t size, gfp_t flags)
175{ 170{
@@ -184,21 +179,9 @@ static inline void *kmalloc(size_t size, gfp_t flags)
184 return __kmalloc(size, flags); 179 return __kmalloc(size, flags);
185} 180}
186 181
187static inline void *kzalloc(size_t size, gfp_t flags)
188{
189 if (__builtin_constant_p(size) && !(flags & SLUB_DMA)) {
190 struct kmem_cache *s = kmalloc_slab(size);
191
192 if (!s)
193 return ZERO_SIZE_PTR;
194
195 return kmem_cache_zalloc(s, flags);
196 } else
197 return __kzalloc(size, flags);
198}
199
200#ifdef CONFIG_NUMA 182#ifdef CONFIG_NUMA
201extern void *__kmalloc_node(size_t size, gfp_t flags, int node); 183void *__kmalloc_node(size_t size, gfp_t flags, int node);
184void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
202 185
203static inline void *kmalloc_node(size_t size, gfp_t flags, int node) 186static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
204{ 187{