Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
slab.h File Reference
#include <linux/gfp.h>
#include <linux/types.h>
#include <linux/slab_def.h>

Go to the source code of this file.

Macros

#define SLAB_DEBUG_FREE   0x00000100UL /* DEBUG: Perform (expensive) checks on free */
 
#define SLAB_RED_ZONE   0x00000400UL /* DEBUG: Red zone objs in a cache */
 
#define SLAB_POISON   0x00000800UL /* DEBUG: Poison objects */
 
#define SLAB_HWCACHE_ALIGN   0x00002000UL /* Align objs on cache lines */
 
#define SLAB_CACHE_DMA   0x00004000UL /* Use GFP_DMA memory */
 
#define SLAB_STORE_USER   0x00010000UL /* DEBUG: Store the last owner for bug hunting */
 
#define SLAB_PANIC   0x00040000UL /* Panic if kmem_cache_create() fails */
 
#define SLAB_DESTROY_BY_RCU   0x00080000UL /* Defer freeing slabs to RCU */
 
#define SLAB_MEM_SPREAD   0x00100000UL /* Spread some memory over cpuset */
 
#define SLAB_TRACE   0x00200000UL /* Trace allocations and frees */
 
#define SLAB_DEBUG_OBJECTS   0x00000000UL
 
#define SLAB_NOLEAKTRACE   0x00800000UL /* Avoid kmemleak tracing */
 
#define SLAB_NOTRACK   0x00000000UL
 
#define SLAB_FAILSLAB   0x00000000UL
 
#define SLAB_RECLAIM_ACCOUNT   0x00020000UL /* Objects are reclaimable */
 
#define SLAB_TEMPORARY   SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
 
#define ZERO_SIZE_PTR   ((void *)16)
 
#define ZERO_OR_NULL_PTR(x)
 
#define KMEM_CACHE(__struct, __flags)
 
#define KMALLOC_SHIFT_HIGH
 
#define KMALLOC_MAX_SIZE   (1UL << KMALLOC_SHIFT_HIGH)
 
#define KMALLOC_MAX_ORDER   (KMALLOC_SHIFT_HIGH - PAGE_SHIFT)
 
#define ARCH_KMALLOC_MINALIGN   __alignof__(unsigned long long)
 
#define ARCH_SLAB_MINALIGN   __alignof__(unsigned long long)
 
#define kmalloc_track_caller(size, flags)   __kmalloc(size, flags)
 
#define kmalloc_node_track_caller(size, flags, node)   kmalloc_track_caller(size, flags)
 

Functions

void __init kmem_cache_init (void)
 
int slab_is_available (void)
 
struct kmem_cachekmem_cache_create (const char *, size_t, size_t, unsigned long, void(*)(void *))
 
void kmem_cache_destroy (struct kmem_cache *)
 
int kmem_cache_shrink (struct kmem_cache *)
 
void kmem_cache_free (struct kmem_cache *, void *)
 
unsigned int kmem_cache_size (struct kmem_cache *)
 
void *__must_check __krealloc (const void *, size_t, gfp_t)
 
void *__must_check krealloc (const void *, size_t, gfp_t)
 
void kfree (const void *)
 
void kzfree (const void *)
 
size_t ksize (const void *)
 
voidkmem_cache_alloc (struct kmem_cache *, gfp_t)
 
void __init kmem_cache_init_late (void)
 

Macro Definition Documentation

#define ARCH_KMALLOC_MINALIGN   __alignof__(unsigned long long)

Definition at line 168 of file slab.h.

#define ARCH_SLAB_MINALIGN   __alignof__(unsigned long long)

Definition at line 177 of file slab.h.

#define KMALLOC_MAX_ORDER   (KMALLOC_SHIFT_HIGH - PAGE_SHIFT)

Definition at line 158 of file slab.h.

#define KMALLOC_MAX_SIZE   (1UL << KMALLOC_SHIFT_HIGH)

Definition at line 157 of file slab.h.

#define kmalloc_node_track_caller (   size,
  flags,
  node 
)    kmalloc_track_caller(size, flags)

Definition at line 357 of file slab.h.

#define KMALLOC_SHIFT_HIGH
Value:
((MAX_ORDER + PAGE_SHIFT - 1) <= 25 ? \
(MAX_ORDER + PAGE_SHIFT - 1) : 25)

Definition at line 154 of file slab.h.

#define kmalloc_track_caller (   size,
  flags 
)    __kmalloc(size, flags)

Definition at line 330 of file slab.h.

#define KMEM_CACHE (   __struct,
  __flags 
)
Value:
kmem_cache_create(#__struct,\
sizeof(struct __struct), __alignof__(struct __struct),\
(__flags), NULL)

Definition at line 141 of file slab.h.

#define SLAB_CACHE_DMA   0x00004000UL /* Use GFP_DMA memory */

Definition at line 23 of file slab.h.

#define SLAB_DEBUG_FREE   0x00000100UL /* DEBUG: Perform (expensive) checks on free */

Definition at line 19 of file slab.h.

#define SLAB_DEBUG_OBJECTS   0x00000000UL

Definition at line 62 of file slab.h.

#define SLAB_DESTROY_BY_RCU   0x00080000UL /* Defer freeing slabs to RCU */

Definition at line 54 of file slab.h.

#define SLAB_FAILSLAB   0x00000000UL

Definition at line 76 of file slab.h.

#define SLAB_HWCACHE_ALIGN   0x00002000UL /* Align objs on cache lines */

Definition at line 22 of file slab.h.

#define SLAB_MEM_SPREAD   0x00100000UL /* Spread some memory over cpuset */

Definition at line 55 of file slab.h.

#define SLAB_NOLEAKTRACE   0x00800000UL /* Avoid kmemleak tracing */

Definition at line 65 of file slab.h.

#define SLAB_NOTRACK   0x00000000UL

Definition at line 71 of file slab.h.

#define SLAB_PANIC   0x00040000UL /* Panic if kmem_cache_create() fails */

Definition at line 25 of file slab.h.

#define SLAB_POISON   0x00000800UL /* DEBUG: Poison objects */

Definition at line 21 of file slab.h.

#define SLAB_RECLAIM_ACCOUNT   0x00020000UL /* Objects are reclaimable */

Definition at line 80 of file slab.h.

#define SLAB_RED_ZONE   0x00000400UL /* DEBUG: Red zone objs in a cache */

Definition at line 20 of file slab.h.

#define SLAB_STORE_USER   0x00010000UL /* DEBUG: Store the last owner for bug hunting */

Definition at line 24 of file slab.h.

#define SLAB_TEMPORARY   SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */

Definition at line 81 of file slab.h.

#define SLAB_TRACE   0x00200000UL /* Trace allocations and frees */

Definition at line 56 of file slab.h.

#define ZERO_OR_NULL_PTR (   x)
Value:
((unsigned long)(x) <= \
(unsigned long)ZERO_SIZE_PTR)

Definition at line 92 of file slab.h.

#define ZERO_SIZE_PTR   ((void *)16)

Definition at line 90 of file slab.h.

Function Documentation

void* __must_check __krealloc ( const void p,
size_t  new_size,
gfp_t  flags 
)

__krealloc - like krealloc() but don't free . : object to reallocate memory for. : how many bytes of memory are required. : the type of memory to allocate.

This function is like krealloc() except it never frees the originally allocated buffer. Use this if you don't want to free the buffer immediately like, for example, with RCU.

Definition at line 137 of file util.c.

void kfree ( const void x)

kfree - free previously allocated memory : pointer returned by kmalloc.

If is NULL, no operation is performed.

Don't free memory not originally allocated by kmalloc() or you will run into trouble.

Definition at line 3952 of file slab.c.

void* kmem_cache_alloc ( struct kmem_cache cachep,
gfp_t  flags 
)

kmem_cache_alloc - Allocate an object : The cache to allocate from. : See kmalloc().

Allocate an object from this cache. The flags are only relevant if the cache has no available objects.

Definition at line 3780 of file slab.c.

struct kmem_cache* kmem_cache_create ( const char ,
size_t  ,
size_t  ,
unsigned  long,
void(*)(void *)   
)
read

Definition at line 98 of file slab_common.c.

void kmem_cache_destroy ( struct kmem_cache )

Definition at line 162 of file slab_common.c.

void kmem_cache_free ( struct kmem_cache cachep,
void objp 
)

kmem_cache_free - Deallocate an object : The cache the allocation was from. : The previously allocated object.

Free an object which was previously allocated from this cache.

Definition at line 3928 of file slab.c.

void __init kmem_cache_init ( void  )

Definition at line 1583 of file slab.c.

void __init kmem_cache_init_late ( void  )

Definition at line 1774 of file slab.c.

int kmem_cache_shrink ( struct kmem_cache cachep)

kmem_cache_shrink - Shrink a cache. : The cache to shrink.

Releases as many slabs as possible for a cache. To help debugging, a zero exit status indicates all slabs were released.

Definition at line 2716 of file slab.c.

unsigned int kmem_cache_size ( struct kmem_cache )

Definition at line 3972 of file slab.c.

void* __must_check krealloc ( const void p,
size_t  new_size,
gfp_t  flags 
)

krealloc - reallocate memory. The contents will remain unchanged. : object to reallocate memory for. : how many bytes of memory are required. : the type of memory to allocate.

The contents of the object pointed to are preserved up to the lesser of the new and old sizes. If is NULL, krealloc() behaves exactly like kmalloc(). If is 0 and is not a NULL pointer, the object pointed to is freed.

Definition at line 158 of file util.c.

size_t ksize ( const void objp)

ksize - get the actual amount of memory allocated for a given object : Pointer to the object

kmalloc may internally round up allocations and return more memory than requested. ksize() can be used to determine the actual amount of memory allocated. The caller may use this additional memory, even though a smaller amount of memory was initially specified with the kmalloc call. The caller must guarantee that objp points to a valid object previously allocated with either kmalloc() or kmem_cache_alloc(). The object must not be freed during the duration of the call.

Definition at line 4689 of file slab.c.

void kzfree ( const void p)

kzfree - like kfree but zero memory : object to free memory of

The memory of the object points to is zeroed before freed. If is NULL, kzfree() does nothing.

Note: this function zeroes the whole allocated buffer which can be a good deal bigger than the requested buffer size passed to kmalloc(). So be careful when using this function in performance sensitive code.

Definition at line 186 of file util.c.

int slab_is_available ( void  )

Definition at line 191 of file slab_common.c.