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

Go to the source code of this file.

Data Structures

struct  mempool_s
 

Typedefs

typedef void *( mempool_alloc_t )(gfp_t gfp_mask, void *pool_data)
 
typedef voidmempool_free_t )(void *element, void *pool_data)
 
typedef struct mempool_s mempool_t
 

Functions

mempool_tmempool_create (int min_nr, mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, void *pool_data)
 
mempool_tmempool_create_node (int min_nr, mempool_alloc_t *alloc_fn, mempool_free_t *free_fn, void *pool_data, gfp_t gfp_mask, int nid)
 
int mempool_resize (mempool_t *pool, int new_min_nr, gfp_t gfp_mask)
 
void mempool_destroy (mempool_t *pool)
 
voidmempool_alloc (mempool_t *pool, gfp_t gfp_mask)
 
void mempool_free (void *element, mempool_t *pool)
 
voidmempool_alloc_slab (gfp_t gfp_mask, void *pool_data)
 
void mempool_free_slab (void *element, void *pool_data)
 
voidmempool_kmalloc (gfp_t gfp_mask, void *pool_data)
 
void mempool_kfree (void *element, void *pool_data)
 
voidmempool_alloc_pages (gfp_t gfp_mask, void *pool_data)
 
void mempool_free_pages (void *element, void *pool_data)
 

Typedef Documentation

typedef void*( mempool_alloc_t)(gfp_t gfp_mask, void *pool_data)

Definition at line 11 of file mempool.h.

typedef void( mempool_free_t)(void *element, void *pool_data)

Definition at line 12 of file mempool.h.

Function Documentation

void* mempool_alloc ( mempool_t pool,
gfp_t  gfp_mask 
)

mempool_alloc - allocate an element from a specific memory pool : pointer to the memory pool which was allocated via mempool_create(). : the usual allocation bitmask.

this function only sleeps if the alloc_fn() function sleeps or returns NULL. Note that due to preallocation, this function never fails when called from process contexts. (it might fail if called from an IRQ context.)

Definition at line 196 of file mempool.c.

void* mempool_alloc_pages ( gfp_t  gfp_mask,
void pool_data 
)

Definition at line 359 of file mempool.c.

void* mempool_alloc_slab ( gfp_t  gfp_mask,
void pool_data 
)

Definition at line 324 of file mempool.c.

mempool_t* mempool_create ( int  min_nr,
mempool_alloc_t alloc_fn,
mempool_free_t free_fn,
void pool_data 
)

mempool_create - create a memory pool : the minimum number of elements guaranteed to be allocated for this pool. : user-defined element-allocation function. : user-defined element-freeing function. : optional private data available to the user-defined functions.

this function creates and allocates a guaranteed size, preallocated memory pool. The pool can be used from the mempool_alloc() and mempool_free() functions. This function might sleep. Both the alloc_fn() and the free_fn() functions might sleep - as long as the mempool_alloc() function is not called from IRQ contexts.

Definition at line 63 of file mempool.c.

mempool_t* mempool_create_node ( int  min_nr,
mempool_alloc_t alloc_fn,
mempool_free_t free_fn,
void pool_data,
gfp_t  gfp_mask,
int  nid 
)

Definition at line 71 of file mempool.c.

void mempool_destroy ( mempool_t pool)

mempool_destroy - deallocate a memory pool : pointer to the memory pool which was allocated via mempool_create().

Free all reserved elements in and itself. This function only sleeps if the free_fn() function sleeps.

Definition at line 38 of file mempool.c.

void mempool_free ( void element,
mempool_t pool 
)

mempool_free - return an element to the pool. : pool element pointer. : pointer to the memory pool which was allocated via mempool_create().

this function only sleeps if the free_fn() function sleeps.

Definition at line 267 of file mempool.c.

void mempool_free_pages ( void element,
void pool_data 
)

Definition at line 366 of file mempool.c.

void mempool_free_slab ( void element,
void pool_data 
)

Definition at line 331 of file mempool.c.

void mempool_kfree ( void element,
void pool_data 
)

Definition at line 349 of file mempool.c.

void* mempool_kmalloc ( gfp_t  gfp_mask,
void pool_data 
)

Definition at line 342 of file mempool.c.

int mempool_resize ( mempool_t pool,
int  new_min_nr,
gfp_t  gfp_mask 
)

mempool_resize - resize an existing memory pool : pointer to the memory pool which was allocated via mempool_create(). : the new minimum number of elements guaranteed to be allocated for this pool. : the usual allocation bitmask.

This function shrinks/grows the pool. In the case of growing, it cannot be guaranteed that the pool will be grown to the new size immediately, but new mempool_free() calls will refill it.

Note, the caller must guarantee that no mempool_destroy is called while this function is running. mempool_alloc() & mempool_free() might be called (eg. from IRQ contexts) while this function executes.

Definition at line 125 of file mempool.c.