FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
maplog.h File Reference

mmap-based thread-safe fixed-size record double-buffered logging. More...

+ Include dependency graph for maplog.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  clib_maplog_header_t
 Maplog log file header segment. More...
 
struct  clib_maplog_main_t
 Process-private main data structure. More...
 
struct  clib_maplog_init_args_t
 log initialization structure More...
 

Macros

#define MAPLOG_MAJOR_VERSION   1
 
#define MAPLOG_MINOR_VERSION   1
 
#define MAPLOG_PATCH_VERSION   0
 
#define CLIB_MAPLOG_FLAG_INIT   (1<<0)
 
#define CLIB_MAPLOG_FLAG_CIRCULAR   (1<<1)
 
#define CLIB_MAPLOG_FLAG_WRAPPED   (1<<2)
 

Functions

int clib_maplog_init (clib_maplog_init_args_t *ap)
 Initialize a maplog object. More...
 
void clib_maplog_update_header (clib_maplog_main_t *mm)
 Update a mapped log header file. More...
 
void clib_maplog_close (clib_maplog_main_t *mm)
 Close a mapped log, and update the log header file. More...
 
int clib_maplog_process (char *file_basename, void *fp_arg)
 Process a complete maplog. More...
 
static void * clib_maplog_get_entry (clib_maplog_main_t *mm)
 Obtain a log entry pointer. More...
 

Variables

format_function_t format_maplog_header
 

Detailed Description

mmap-based thread-safe fixed-size record double-buffered logging.

This scheme should be about as fast as practicable. By fiat, log records are rounded to a multiple of CLIB_CACHE_LINE_BYTES. Consumer code calls clib_maplog_get_entry(...) to obtain a pointer to a log entry.

We use an atomic ticket-counter to dole out log entries. Whichever client thread crosses the double-buffer boundary is in charge of replacing the log segment which just filled.

Definition in file maplog.h.

Macro Definition Documentation

#define CLIB_MAPLOG_FLAG_CIRCULAR   (1<<1)

Definition at line 93 of file maplog.h.

#define CLIB_MAPLOG_FLAG_INIT   (1<<0)

Definition at line 92 of file maplog.h.

#define CLIB_MAPLOG_FLAG_WRAPPED   (1<<2)

Definition at line 94 of file maplog.h.

#define MAPLOG_MAJOR_VERSION   1

Definition at line 62 of file maplog.h.

#define MAPLOG_MINOR_VERSION   1

Definition at line 63 of file maplog.h.

#define MAPLOG_PATCH_VERSION   0

Definition at line 64 of file maplog.h.

Function Documentation

void clib_maplog_close ( clib_maplog_main_t mm)

Close a mapped log, and update the log header file.

Unmap the current log segments. Read the log header. Update the number of records, and number of files

Parameters

Definition at line 299 of file maplog.c.

+ Here is the call graph for this function:

static void* clib_maplog_get_entry ( clib_maplog_main_t mm)
inlinestatic

Obtain a log entry pointer.

Increments the atomic ticket counter, and returns a pointer to the newly-allocated log entry. The slowpath function replaces a full log segment with a new/fresh/empty log segment

Parameters
[in]mmmaplog object pointer
Returns
pointer to the allocated log entry

Definition at line 133 of file maplog.h.

int clib_maplog_init ( clib_maplog_init_args_t a)

Initialize a maplog object.

Compute record and file size parameters Create and map two log segments to seed the process

Parameters

Definition at line 28 of file maplog.c.

+ Here is the call graph for this function:

int clib_maplog_process ( char *  file_basename,
void *  fp_arg 
)

Process a complete maplog.

Reads the maplog header. Map and process all log segments in order. Calls the callback function once per file with a record count.

Note: if the file header isn't updated by calling clib_maplog_close(), it will appear to have an infinite number of records in an infinite number of files.

So long as the callback function understands that possibility

  • by simply ignoring NULL records - the scheme still works...
Parameters
[in]file_basenameSame basename supplied to clib_maplog_init
[in]fp_argCallback function pointer

Definition at line 384 of file maplog.c.

+ Here is the call graph for this function:

void clib_maplog_update_header ( clib_maplog_main_t mm)

Update a mapped log header file.

Read the log header. Update the number of records, and number of files

Parameters

Definition at line 246 of file maplog.c.

+ Here is the caller graph for this function:

Variable Documentation

format_function_t format_maplog_header

Definition at line 117 of file maplog.h.