aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/slab.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r--include/linux/slab.h43
1 files changed, 33 insertions, 10 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 5ff9676c1e2c..f96d13c281e8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -23,6 +23,34 @@
23#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */ 23#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
24#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */ 24#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
25#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */ 25#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */
26/*
27 * SLAB_DESTROY_BY_RCU - **WARNING** READ THIS!
28 *
29 * This delays freeing the SLAB page by a grace period, it does _NOT_
30 * delay object freeing. This means that if you do kmem_cache_free()
31 * that memory location is free to be reused at any time. Thus it may
32 * be possible to see another object there in the same RCU grace period.
33 *
34 * This feature only ensures the memory location backing the object
35 * stays valid, the trick to using this is relying on an independent
36 * object validation pass. Something like:
37 *
38 * rcu_read_lock()
39 * again:
40 * obj = lockless_lookup(key);
41 * if (obj) {
42 * if (!try_get_ref(obj)) // might fail for free objects
43 * goto again;
44 *
45 * if (obj->key != key) { // not the object we expected
46 * put_ref(obj);
47 * goto again;
48 * }
49 * }
50 * rcu_read_unlock();
51 *
52 * See also the comment on struct slab_rcu in mm/slab.c.
53 */
26#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */ 54#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
27#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 55#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
28#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 56#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
@@ -225,9 +253,9 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
225 * request comes from. 253 * request comes from.
226 */ 254 */
227#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) 255#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
228extern void *__kmalloc_track_caller(size_t, gfp_t, void*); 256extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
229#define kmalloc_track_caller(size, flags) \ 257#define kmalloc_track_caller(size, flags) \
230 __kmalloc_track_caller(size, flags, __builtin_return_address(0)) 258 __kmalloc_track_caller(size, flags, _RET_IP_)
231#else 259#else
232#define kmalloc_track_caller(size, flags) \ 260#define kmalloc_track_caller(size, flags) \
233 __kmalloc(size, flags) 261 __kmalloc(size, flags)
@@ -243,10 +271,10 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
243 * allocation request comes from. 271 * allocation request comes from.
244 */ 272 */
245#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) 273#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
246extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *); 274extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
247#define kmalloc_node_track_caller(size, flags, node) \ 275#define kmalloc_node_track_caller(size, flags, node) \
248 __kmalloc_node_track_caller(size, flags, node, \ 276 __kmalloc_node_track_caller(size, flags, node, \
249 __builtin_return_address(0)) 277 _RET_IP_)
250#else 278#else
251#define kmalloc_node_track_caller(size, flags, node) \ 279#define kmalloc_node_track_caller(size, flags, node) \
252 __kmalloc_node(size, flags, node) 280 __kmalloc_node(size, flags, node)
@@ -257,7 +285,7 @@ extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
257#define kmalloc_node_track_caller(size, flags, node) \ 285#define kmalloc_node_track_caller(size, flags, node) \
258 kmalloc_track_caller(size, flags) 286 kmalloc_track_caller(size, flags)
259 287
260#endif /* DEBUG_SLAB */ 288#endif /* CONFIG_NUMA */
261 289
262/* 290/*
263 * Shortcuts 291 * Shortcuts
@@ -288,9 +316,4 @@ static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
288 return kmalloc_node(size, flags | __GFP_ZERO, node); 316 return kmalloc_node(size, flags | __GFP_ZERO, node);
289} 317}
290 318
291#ifdef CONFIG_SLABINFO
292extern const struct seq_operations slabinfo_op;
293ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
294#endif
295
296#endif /* _LINUX_SLAB_H */ 319#endif /* _LINUX_SLAB_H */