include/linux/slab.h
changeset 2 d1f6d8b6f81c
parent 0 aa628870c1d3
equal deleted inserted replaced
1:0056487c491e 2:d1f6d8b6f81c
   125  * Common kmalloc functions provided by all allocators
   125  * Common kmalloc functions provided by all allocators
   126  */
   126  */
   127 void * __must_check __krealloc(const void *, size_t, gfp_t);
   127 void * __must_check __krealloc(const void *, size_t, gfp_t);
   128 void * __must_check krealloc(const void *, size_t, gfp_t);
   128 void * __must_check krealloc(const void *, size_t, gfp_t);
   129 void kfree(const void *);
   129 void kfree(const void *);
       
   130 void kzfree(const void *);
   130 size_t ksize(const void *);
   131 size_t ksize(const void *);
   131 
   132 
   132 /*
   133 /*
   133  * Allocator specific definitions. These are mainly used to establish optimized
   134  * Allocator specific definitions. These are mainly used to establish optimized
   134  * ways to convert kmalloc() calls to kmem_cache_alloc() invocations by
   135  * ways to convert kmalloc() calls to kmem_cache_alloc() invocations by
   251  * It's useful when the call to kmalloc comes from a widely-used standard
   252  * It's useful when the call to kmalloc comes from a widely-used standard
   252  * allocator where we care about the real place the memory allocation
   253  * allocator where we care about the real place the memory allocation
   253  * request comes from.
   254  * request comes from.
   254  */
   255  */
   255 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
   256 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
   256 extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
   257 extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
   257 #define kmalloc_track_caller(size, flags) \
   258 #define kmalloc_track_caller(size, flags) \
   258 	__kmalloc_track_caller(size, flags, __builtin_return_address(0))
   259 	__kmalloc_track_caller(size, flags, _RET_IP_)
   259 #else
   260 #else
   260 #define kmalloc_track_caller(size, flags) \
   261 #define kmalloc_track_caller(size, flags) \
   261 	__kmalloc(size, flags)
   262 	__kmalloc(size, flags)
   262 #endif /* DEBUG_SLAB */
   263 #endif /* DEBUG_SLAB */
   263 
   264 
   269  * It's useful when the call to kmalloc_node comes from a widely-used
   270  * It's useful when the call to kmalloc_node comes from a widely-used
   270  * standard allocator where we care about the real place the memory
   271  * standard allocator where we care about the real place the memory
   271  * allocation request comes from.
   272  * allocation request comes from.
   272  */
   273  */
   273 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
   274 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB)
   274 extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
   275 extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
   275 #define kmalloc_node_track_caller(size, flags, node) \
   276 #define kmalloc_node_track_caller(size, flags, node) \
   276 	__kmalloc_node_track_caller(size, flags, node, \
   277 	__kmalloc_node_track_caller(size, flags, node, \
   277 			__builtin_return_address(0))
   278 			_RET_IP_)
   278 #else
   279 #else
   279 #define kmalloc_node_track_caller(size, flags, node) \
   280 #define kmalloc_node_track_caller(size, flags, node) \
   280 	__kmalloc_node(size, flags, node)
   281 	__kmalloc_node(size, flags, node)
   281 #endif
   282 #endif
   282 
   283 
   283 #else /* CONFIG_NUMA */
   284 #else /* CONFIG_NUMA */
   284 
   285 
   285 #define kmalloc_node_track_caller(size, flags, node) \
   286 #define kmalloc_node_track_caller(size, flags, node) \
   286 	kmalloc_track_caller(size, flags)
   287 	kmalloc_track_caller(size, flags)
   287 
   288 
   288 #endif /* DEBUG_SLAB */
   289 #endif /* CONFIG_NUMA */
   289 
   290 
   290 /*
   291 /*
   291  * Shortcuts
   292  * Shortcuts
   292  */
   293  */
   293 static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
   294 static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)