Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

gm_lookaside.c File Reference

#include "gm.h"
#include "gm_cache_line.h"
#include "gm_call_trace.h"
#include "gm_debug.h"
#include "gm_internal.h"
#include "gm_malloc_debug.h"
#include "gm_struct_lock.h"

Data Structures

struct  gm_lookaside_segment
struct  gm_lookaside
struct  gm_lookaside_segment_list

Functions

GM_ENTRY_POINT void * gm_lookaside_alloc (struct gm_lookaside *l)
GM_ENTRY_POINT void * gm_lookaside_zalloc (struct gm_lookaside *l)
GM_ENTRY_POINT void gm_lookaside_free (void *ptr)
GM_ENTRY_POINT struct gm_lookasidegm_create_lookaside (gm_size_t entry_len, gm_size_t min_entry_cnt)
GM_ENTRY_POINT void gm_destroy_lookaside (struct gm_lookaside *l)

Detailed Description

This file contains the GM API functions gm_create_lookaside(), gm_destroy_lookaside(), gm_lookaside_alloc(), gm_lookaside_zalloc(), and gm_lookaside_free().

This file implements a lookaside list. It is mainly intended to allow efficient memory allocation of small structures in kernels where the minimum memory allocation is a page, but is not kernel-specific.

GM implements a lookaside list, which may be used to manage small fixed-length blocks more efficiently than gm_malloc() and gm_free(). Lookaside lists can also be used to ensure that at least a minimum number of blocks are available for allocation at all times.

gm_lookaside_alloc() returns cache-line-aligned buffers, in an attempt to minimize the cost of accessing data stored in the buffers.


Function Documentation

GM_ENTRY_POINT void* gm_lookaside_alloc struct gm_lookaside   l
 

gm_lookaside_alloc() allocates an entry from the lookaside table, with debugging. It returns a buffer of size ENTRY_LEN specified when the entry list L was created, or `0' if the buffer could not be allocated.

Return values:
ptr  Buffer of size ENTRY_LEN.
Parameters:
l  (IN) Handle to the gm_lookaside list.
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void* gm_lookaside_zalloc struct gm_lookaside   l
 

gm_lookaside_zalloc() allocates and clear an entry from the lookaside table.

Return values:
ptr 
Parameters:
l  (IN) Handle to the gm_lookaside list.
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void gm_lookaside_free void *    ptr
 

gm_lookaside_free() schedules an allocated entry to be freed, and actually performs any scheduled free. It frees a block of memory previously allocated by a call to gm_lookaside_alloc(). The contents of the block of memory are guaranteed to be unchanged until the next operation is performed on the lookaside list.

Parameters:
ptr  (IN) Pointer to the entry to be freed.
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT struct gm_lookaside* gm_create_lookaside gm_size_t    entry_len,
gm_size_t    min_entry_cnt
 

gm_create_lookaside() returns a newly created lookaside list to be used to allocate blocks of ENTRY_LEN bytes. MIN_ENTRY_CNT entries are preallocated.

Return values:
gm_lookaside  Handle to the lookaside table.
Parameters:
entry_len  (IN)
min_entry_cnt  (IN)
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)

GM_ENTRY_POINT void gm_destroy_lookaside struct gm_lookaside   l
 

gm_destroy_lookaside() frees a lookaside list and all associated resources, including any buffers currently allocated from the lookaside list.

Parameters:
l  (IN) Handle to the lookaside table.
Author:
Glenn Brown
Version:
GM_API_VERSION (as defined in gm.h)


Generated on Mon Nov 3 15:39:26 2003 for GM by doxygen1.2.15