Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
genalloc.c File Reference
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/bitmap.h>
#include <linux/rculist.h>
#include <linux/interrupt.h>
#include <linux/genalloc.h>

Go to the source code of this file.

Functions

struct gen_poolgen_pool_create (int min_alloc_order, int nid)
 
 EXPORT_SYMBOL (gen_pool_create)
 
int gen_pool_add_virt (struct gen_pool *pool, unsigned long virt, phys_addr_t phys, size_t size, int nid)
 
 EXPORT_SYMBOL (gen_pool_add_virt)
 
phys_addr_t gen_pool_virt_to_phys (struct gen_pool *pool, unsigned long addr)
 
 EXPORT_SYMBOL (gen_pool_virt_to_phys)
 
void gen_pool_destroy (struct gen_pool *pool)
 
 EXPORT_SYMBOL (gen_pool_destroy)
 
unsigned long gen_pool_alloc (struct gen_pool *pool, size_t size)
 
 EXPORT_SYMBOL (gen_pool_alloc)
 
void gen_pool_free (struct gen_pool *pool, unsigned long addr, size_t size)
 
 EXPORT_SYMBOL (gen_pool_free)
 
void gen_pool_for_each_chunk (struct gen_pool *pool, void(*func)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data), void *data)
 
 EXPORT_SYMBOL (gen_pool_for_each_chunk)
 
size_t gen_pool_avail (struct gen_pool *pool)
 
 EXPORT_SYMBOL_GPL (gen_pool_avail)
 
size_t gen_pool_size (struct gen_pool *pool)
 
 EXPORT_SYMBOL_GPL (gen_pool_size)
 
void gen_pool_set_algo (struct gen_pool *pool, genpool_algo_t algo, void *data)
 
 EXPORT_SYMBOL (gen_pool_set_algo)
 
unsigned long gen_pool_first_fit (unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)
 
 EXPORT_SYMBOL (gen_pool_first_fit)
 
unsigned long gen_pool_best_fit (unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)
 
 EXPORT_SYMBOL (gen_pool_best_fit)
 

Function Documentation

EXPORT_SYMBOL ( gen_pool_create  )
EXPORT_SYMBOL ( gen_pool_add_virt  )
EXPORT_SYMBOL ( gen_pool_virt_to_phys  )
EXPORT_SYMBOL ( gen_pool_destroy  )
EXPORT_SYMBOL ( gen_pool_alloc  )
EXPORT_SYMBOL ( gen_pool_free  )
EXPORT_SYMBOL ( gen_pool_for_each_chunk  )
EXPORT_SYMBOL ( gen_pool_set_algo  )
EXPORT_SYMBOL ( gen_pool_first_fit  )
EXPORT_SYMBOL ( gen_pool_best_fit  )
EXPORT_SYMBOL_GPL ( gen_pool_avail  )
EXPORT_SYMBOL_GPL ( gen_pool_size  )
int gen_pool_add_virt ( struct gen_pool pool,
unsigned long  virt,
phys_addr_t  phys,
size_t  size,
int  nid 
)

gen_pool_add_virt - add a new chunk of special memory to the pool : pool to add new memory chunk to : virtual starting address of memory chunk to add to pool : physical starting address of memory chunk to add to pool : size in bytes of the memory chunk to add to pool : node id of the node the chunk structure and bitmap should be allocated on, or -1

Add a new chunk of special memory to the specified pool.

Returns 0 on success or a -ve errno on failure.

Definition at line 175 of file genalloc.c.

unsigned long gen_pool_alloc ( struct gen_pool pool,
size_t  size 
)

gen_pool_alloc - allocate special memory from the pool : pool to allocate from : number of bytes to allocate from the pool

Allocate the requested number of bytes from the specified pool. Uses the pool allocation function (with first-fit algorithm by default). Can not be used in NMI handler on architectures without NMI-safe cmpxchg implementation.

Definition at line 264 of file genalloc.c.

size_t gen_pool_avail ( struct gen_pool pool)

gen_pool_avail - get available free space of the pool : pool to get available free space

Return available free space of the specified pool.

Definition at line 375 of file genalloc.c.

unsigned long gen_pool_best_fit ( unsigned long map,
unsigned long  size,
unsigned long  start,
unsigned int  nr,
void data 
)

gen_pool_best_fit - find the best fitting region of memory macthing the size requirement (no alignment constraint) : The address to base the search on : The bitmap size in bits : The bitnumber to start searching at : The number of zeroed bits we're looking for : additional data - unused

Iterate over the bitmap to find the smallest free region which we can allocate the memory.

Definition at line 459 of file genalloc.c.

struct gen_pool* gen_pool_create ( int  min_alloc_order,
int  nid 
)
read

gen_pool_create - create a new special memory pool : log base 2 of number of bytes each bitmap bit represents : node id of the node the pool structure should be allocated on, or -1

Create a new special memory pool that can be used to manage special purpose memory not managed by the regular kmalloc/kfree interface.

Definition at line 146 of file genalloc.c.

void gen_pool_destroy ( struct gen_pool pool)

gen_pool_destroy - destroy a special memory pool : pool to destroy

Destroy the specified special memory pool. Verifies that there are no outstanding allocations.

Definition at line 232 of file genalloc.c.

unsigned long gen_pool_first_fit ( unsigned long map,
unsigned long  size,
unsigned long  start,
unsigned int  nr,
void data 
)

gen_pool_first_fit - find the first available region of memory matching the size requirement (no alignment constraint) : The address to base the search on : The bitmap size in bits : The bitnumber to start searching at : The number of zeroed bits we're looking for : additional data - unused

Definition at line 440 of file genalloc.c.

void gen_pool_for_each_chunk ( struct gen_pool pool,
void(*)(struct gen_pool *pool, struct gen_pool_chunk *chunk, void *data func,
void data 
)

gen_pool_for_each_chunk - call func for every chunk of generic memory pool : the generic memory pool : func to call : additional data used by

Call for every chunk of generic memory pool. The is called with rcu_read_lock held.

Definition at line 356 of file genalloc.c.

void gen_pool_free ( struct gen_pool pool,
unsigned long  addr,
size_t  size 
)

gen_pool_free - free allocated special memory back to the pool : pool to free to : starting address of memory to free back to pool : size in bytes of memory to free

Free previously allocated special memory back to the specified pool. Can not be used in NMI handler on architectures without NMI-safe cmpxchg implementation.

Definition at line 318 of file genalloc.c.

void gen_pool_set_algo ( struct gen_pool pool,
genpool_algo_t  algo,
void data 
)

gen_pool_set_algo - set the allocation algorithm : pool to change allocation algorithm : custom algorithm function : additional data used by

Call for each memory allocation in the pool. If is NULL use gen_pool_first_fit as default memory allocation function.

Definition at line 417 of file genalloc.c.

size_t gen_pool_size ( struct gen_pool pool)

gen_pool_size - get size in bytes of memory managed by the pool : pool to get size

Return size in bytes of memory managed by the pool.

Definition at line 394 of file genalloc.c.

phys_addr_t gen_pool_virt_to_phys ( struct gen_pool pool,
unsigned long  addr 
)

gen_pool_virt_to_phys - return the physical address of memory : pool to allocate from : starting address of memory

Returns the physical address on success, or -1 on error.

Definition at line 207 of file genalloc.c.