kmem_cache.c File Reference

Go to the source code of this file.

Classes

struct  kmem_cache

Defines

#define DEBUG_SLAB   0
#define DEBUG_SLAB_ALLOC   0

Functions

unsigned int kmem_cache_size (struct kmem_cache *cache)
 Return size of objects in cache.
const char * kmem_cache_name (struct kmem_cache *cache)
 Return name of cache.
int kmem_cache_shrink (struct kmem_cache *cache)
 kmem_cache_shrink - Shrink a cache.
void kmem_cache_free (struct kmem_cache *cache, void *objp)
 kmem_cache_free - Deallocate an object : The cache the allocation was from.
void * kmem_cache_alloc (struct kmem_cache *cache, gfp_t flags)
 kmem_cache_alloc - Allocate an object : The cache to allocate from.
void kmem_cache_destroy (struct kmem_cache *cache)
 kmem_cache_destroy - delete a cache : the cache to destroy
must be valid until the cache is destroyed. This implies that
the module calling this has to destroy the cache before getting unloaded.

The flags are

SLAB_POISON - Poison the slab with a known test pattern (a5a5a5a5) to catch references to uninitialised memory.

SLAB_RED_ZONE - Insert `Red' zones around the allocated memory to check for buffer overruns.

SLAB_HWCACHE_ALIGN - Align the objects in this cache to a hardware cacheline. This can be beneficial if you're counting cycles as closely as davem.

struct kmem_cachekmem_cache_create (const char *name, size_t size, size_t align, unsigned long flags, void(*ctor)(void *))


Define Documentation

#define DEBUG_SLAB   0

Definition at line 26 of file kmem_cache.c.

#define DEBUG_SLAB_ALLOC   0

Definition at line 31 of file kmem_cache.c.


Function Documentation

void* kmem_cache_alloc ( struct kmem_cache cache,
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 106 of file kmem_cache.c.

struct kmem_cache* kmem_cache_create ( const char *  name,
size_t  size,
size_t  align,
unsigned long  flags,
void(*)(void *)  ctor 
) [read]

Definition at line 180 of file kmem_cache.c.

void kmem_cache_destroy ( struct kmem_cache cache  ) 

kmem_cache_destroy - delete a cache : the cache to destroy

Remove a struct kmem_cache object from the slab cache. Returns 0 on success.

It is expected this function will be called by a module when it is unloaded. This will remove the cache completely, and avoid a duplicate cache being allocated each time a module is loaded and unloaded, if the module doesn't have persistent in-kernel storage across loads and unloads.

The cache must be empty before calling this function.

The caller must guarantee that noone will allocate memory from the cache during the kmem_cache_destroy().

Definition at line 143 of file kmem_cache.c.

void kmem_cache_free ( struct kmem_cache cache,
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 88 of file kmem_cache.c.

const char* kmem_cache_name ( struct kmem_cache cache  ) 

Return name of cache.

Definition at line 60 of file kmem_cache.c.

int kmem_cache_shrink ( struct kmem_cache cache  ) 

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 73 of file kmem_cache.c.

unsigned int kmem_cache_size ( struct kmem_cache cache  ) 

Return size of objects in cache.

Definition at line 51 of file kmem_cache.c.


Generated on Wed Apr 11 06:39:15 2012 for DDE - The L4 Device Driver Environment by  doxygen 1.5.6