FD.io VPP  v21.01-8-g9330de53e
Vector Packet Processing
elog.h File Reference

The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost. More...

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

Go to the source code of this file.

Data Structures

struct  elog_event_t
 
struct  elog_event_type_t
 
struct  elog_track_t
 
struct  elog_time_stamp_t
 
struct  elog_main_t
 

Macros

#define ELOG_TYPE_DECLARE(f)   static elog_event_type_t __ELOG_TYPE_VAR(f)
 
#define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt, func)   { .format = fmt, .function = func, }
 
#define ELOG_TYPE_INIT(fmt)   ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__)
 
#define ELOG_TYPE_DECLARE_HELPER(f, fmt, func)
 
#define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f, fmt)   ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__)
 
#define ELOG_TYPE_DECLARE_FORMAT(f, fmt)   ELOG_TYPE_DECLARE_HELPER (f, fmt, 0)
 
#define ELOG_TYPE(f, fmt)   ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt)
 
#define ELOG_TYPE_D(f)   ELOG_TYPE_DECLARE_FORMAT (f, #f " %d")
 
#define ELOG_TYPE_X(f)   ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x")
 
#define ELOG_TYPE_DF(f)   ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")
 
#define ELOG_TYPE_XF(f)   ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")
 
#define ELOG_TYPE_FD(f)   ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")
 
#define ELOG_TYPE_FX(f)   ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")
 
#define ELOG_TRACK_DECLARE(f)   static elog_track_t __ELOG_TRACK_VAR(f)
 
#define ELOG_TRACK(f)   ELOG_TRACK_DECLARE(f) = { .name = #f, }
 
#define ELOG(em, f, data)   elog ((em), &__ELOG_TYPE_VAR(f), data)
 
#define ELOG_INLINE(em, f, data)   elog_inline ((em), &__ELOG_TYPE_VAR(f), data)
 
#define ELOG_TRACK_DATA(em, f, track)   elog_data ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))
 
#define ELOG_TRACK_DATA_INLINE(em, f, track)   elog_data_inline ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))
 
#define ELOG_DATA(em, f)   elog_data ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)
 
#define ELOG_DATA_INLINE(em, f)   elog_data_inline ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)
 

Functions

static uword elog_n_events_in_buffer (elog_main_t *em)
 Return number of events in the event-log buffer. More...
 
static uword elog_buffer_capacity (elog_main_t *em)
 Return number of events which can fit in the event buffer. More...
 
static void elog_reset_buffer (elog_main_t *em)
 Reset the event buffer. More...
 
static void elog_enable_disable (elog_main_t *em, int is_enabled)
 Enable or disable event logging. More...
 
static void elog_disable_after_events (elog_main_t *em, uword n)
 disable logging after specified number of ievents have been logged. More...
 
static void elog_disable_trigger (elog_main_t *em)
 
word elog_event_type_register (elog_main_t *em, elog_event_type_t *t)
 register an event type More...
 
word elog_track_register (elog_main_t *em, elog_track_t *t)
 register an event track More...
 
static uword elog_is_enabled (elog_main_t *em)
 event logging enabled predicate More...
 
static void * elog_event_data_inline (elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
 Allocate an event to be filled in by the caller. More...
 
void * elog_event_data (elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
 
static void * elog_event_data_not_inline (elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u64 cpu_time)
 Allocate an event to be filled in by the caller, non-inline. More...
 
static void elog (elog_main_t *em, elog_event_type_t *type, u32 data)
 Log a single-datum event. More...
 
static void elog_inline (elog_main_t *em, elog_event_type_t *type, u32 data)
 Log a single-datum event, inline version. More...
 
static void elog_track (elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
 Log a single-datum event to a specific track, non-inline version. More...
 
static void elog_track_inline (elog_main_t *em, elog_event_type_t *type, elog_track_t *track, u32 data)
 Log a single-datum event to a specific track. More...
 
static void * elog_data (elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
 
static void * elog_data_inline (elog_main_t *em, elog_event_type_t *type, elog_track_t *track)
 
u32 elog_string (elog_main_t *em, char *format,...)
 add a string to the event-log string table More...
 
void elog_time_now (elog_time_stamp_t *et)
 
elog_event_telog_get_events (elog_main_t *em)
 convert event ring events to events, and return them as a vector. More...
 
elog_event_telog_peek_events (elog_main_t *em)
 convert event ring events to events, and return them as a vector. More...
 
void elog_merge (elog_main_t *dst, u8 *dst_tag, elog_main_t *src, u8 *src_tag, f64 align_tweak)
 
u8format_elog_event (u8 *s, va_list *va)
 
u8format_elog_track_name (u8 *s, va_list *va)
 
u8format_elog_track (u8 *s, va_list *args)
 
void serialize_elog_main (serialize_main_t *m, va_list *va)
 
void unserialize_elog_main (serialize_main_t *m, va_list *va)
 
void elog_init (elog_main_t *em, u32 n_events)
 
void elog_alloc (elog_main_t *em, u32 n_events)
 
void elog_resize (elog_main_t *em, u32 n_events)
 
static clib_error_telog_write_file (elog_main_t *em, char *clib_file, int flush_ring)
 
clib_error_telog_write_file_not_inline (elog_main_t *em, char *clib_file, int flush_ring)
 
static clib_error_telog_read_file (elog_main_t *em, char *clib_file)
 
clib_error_telog_read_file_not_inline (elog_main_t *em, char *clib_file)
 
char * format_one_elog_event (void *em_arg, void *ep_arg)
 

Detailed Description

The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost.

In typical operation, logging a single event costs around 80ns on x86_64. It's appropriate for at-least per-frame event-logging in vector packet processing.

See https://wiki.fd.io/view/VPP/elog for more information.

Definition in file elog.h.

Macro Definition Documentation

◆ ELOG

#define ELOG (   em,
  f,
  data 
)    elog ((em), &__ELOG_TYPE_VAR(f), data)

Definition at line 474 of file elog.h.

◆ ELOG_DATA

#define ELOG_DATA (   em,
 
)    elog_data ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)

Definition at line 484 of file elog.h.

◆ ELOG_DATA_INLINE

#define ELOG_DATA_INLINE (   em,
 
)    elog_data_inline ((em), &__ELOG_TYPE_VAR (f), &(em)->default_track)

Definition at line 485 of file elog.h.

◆ ELOG_INLINE

#define ELOG_INLINE (   em,
  f,
  data 
)    elog_inline ((em), &__ELOG_TYPE_VAR(f), data)

Definition at line 475 of file elog.h.

◆ ELOG_TRACK

#define ELOG_TRACK (   f)    ELOG_TRACK_DECLARE(f) = { .name = #f, }

Definition at line 471 of file elog.h.

◆ ELOG_TRACK_DATA

#define ELOG_TRACK_DATA (   em,
  f,
  track 
)    elog_data ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))

Definition at line 478 of file elog.h.

◆ ELOG_TRACK_DATA_INLINE

#define ELOG_TRACK_DATA_INLINE (   em,
  f,
  track 
)    elog_data_inline ((em), &__ELOG_TYPE_VAR(f), &__ELOG_TRACK_VAR(track))

Definition at line 480 of file elog.h.

◆ ELOG_TRACK_DECLARE

#define ELOG_TRACK_DECLARE (   f)    static elog_track_t __ELOG_TRACK_VAR(f)

Definition at line 470 of file elog.h.

◆ ELOG_TYPE

#define ELOG_TYPE (   f,
  fmt 
)    ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt)

Definition at line 462 of file elog.h.

◆ ELOG_TYPE_D

#define ELOG_TYPE_D (   f)    ELOG_TYPE_DECLARE_FORMAT (f, #f " %d")

Definition at line 463 of file elog.h.

◆ ELOG_TYPE_DECLARE

#define ELOG_TYPE_DECLARE (   f)    static elog_event_type_t __ELOG_TYPE_VAR(f)

Definition at line 442 of file elog.h.

◆ ELOG_TYPE_DECLARE_FORMAT

#define ELOG_TYPE_DECLARE_FORMAT (   f,
  fmt 
)    ELOG_TYPE_DECLARE_HELPER (f, fmt, 0)

Definition at line 457 of file elog.h.

◆ ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION

#define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (   f,
  fmt 
)    ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__)

Definition at line 454 of file elog.h.

◆ ELOG_TYPE_DECLARE_HELPER

#define ELOG_TYPE_DECLARE_HELPER (   f,
  fmt,
  func 
)
Value:
static elog_event_type_t __ELOG_TYPE_VAR(f) = \
ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, func)
int cJSON_bool fmt
Definition: cJSON.h:160

Definition at line 450 of file elog.h.

◆ ELOG_TYPE_DF

#define ELOG_TYPE_DF (   f)    ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")

Definition at line 465 of file elog.h.

◆ ELOG_TYPE_FD

#define ELOG_TYPE_FD (   f)    ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " %d")

Definition at line 467 of file elog.h.

◆ ELOG_TYPE_FX

#define ELOG_TYPE_FX (   f)    ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")

Definition at line 468 of file elog.h.

◆ ELOG_TYPE_INIT

#define ELOG_TYPE_INIT (   fmt)    ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__)

Definition at line 447 of file elog.h.

◆ ELOG_TYPE_INIT_FORMAT_AND_FUNCTION

#define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (   fmt,
  func 
)    { .format = fmt, .function = func, }

Definition at line 444 of file elog.h.

◆ ELOG_TYPE_X

#define ELOG_TYPE_X (   f)    ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x")

Definition at line 464 of file elog.h.

◆ ELOG_TYPE_XF

#define ELOG_TYPE_XF (   f)    ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION (f, #f " 0x%x")

Definition at line 466 of file elog.h.

Function Documentation

◆ elog()

static void elog ( elog_main_t em,
elog_event_type_t type,
u32  data 
)
inlinestatic

Log a single-datum event.

Parameters
emelog_main_t *
typeelog_event_type_t * type
datau32 single datum to capture

Definition at line 367 of file elog.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_alloc()

void elog_alloc ( elog_main_t em,
u32  n_events 
)

Definition at line 501 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_buffer_capacity()

static uword elog_buffer_capacity ( elog_main_t em)
inlinestatic

Return number of events which can fit in the event buffer.

Parameters
emelog_main_t *
Returns
number of events which can fit in the buffer

Definition at line 201 of file elog.h.

+ Here is the caller graph for this function:

◆ elog_data()

static void* elog_data ( elog_main_t em,
elog_event_type_t type,
elog_track_t track 
)
inlinestatic

Definition at line 426 of file elog.h.

+ Here is the call graph for this function:

◆ elog_data_inline()

static void* elog_data_inline ( elog_main_t em,
elog_event_type_t type,
elog_track_t track 
)
inlinestatic

Definition at line 432 of file elog.h.

+ Here is the call graph for this function:

◆ elog_disable_after_events()

static void elog_disable_after_events ( elog_main_t em,
uword  n 
)
inlinestatic

disable logging after specified number of ievents have been logged.

This is used as a "debug trigger" when a certain event has occurred. Events will be logged both before and after the "event" but the event will not be lost as long as N < RING_SIZE.

Parameters
emelog_main_t *
nuword number of events before disabling event logging

Definition at line 236 of file elog.h.

◆ elog_disable_trigger()

static void elog_disable_trigger ( elog_main_t em)
inlinestatic

Definition at line 248 of file elog.h.

+ Here is the call graph for this function:

◆ elog_enable_disable()

static void elog_enable_disable ( elog_main_t em,
int  is_enabled 
)
inlinestatic

Enable or disable event logging.

Parameters
emelog_main_t *

Definition at line 220 of file elog.h.

+ Here is the caller graph for this function:

◆ elog_event_data()

void* elog_event_data ( elog_main_t em,
elog_event_type_t type,
elog_track_t track,
u64  cpu_time 
)

Definition at line 65 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_event_data_inline()

static void* elog_event_data_inline ( elog_main_t em,
elog_event_type_t type,
elog_track_t track,
u64  cpu_time 
)
inlinestatic

Allocate an event to be filled in by the caller.

Not normally called directly; this function underlies the ELOG_DATA and ELOG_TRACK_DATA macros

Parameters
emelog_main_t *
typeelog_event_type_t * type
trackelog_track_t * track
cpu_timeu64 current cpu tick value
Returns
event to be filled in

Definition at line 293 of file elog.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_event_data_not_inline()

static void* elog_event_data_not_inline ( elog_main_t em,
elog_event_type_t type,
elog_track_t track,
u64  cpu_time 
)
inlinestatic

Allocate an event to be filled in by the caller, non-inline.

Not normally called directly; this function underlies the ELOG_DATA and ELOG_TRACK_DATA macros

Parameters
emelog_main_t *
typeelog_event_type_t * type
trackelog_track_t * track
cpu_timeu64 current cpu tick value
Returns
event to be filled in

Definition at line 351 of file elog.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_event_type_register()

word elog_event_type_register ( elog_main_t em,
elog_event_type_t t 
)

register an event type

Parameters
emelog_main_t *
telog_event_type_t * event to register
Returns
type index
Warning
Typically not called directly

Definition at line 104 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_get_events()

elog_event_t* elog_get_events ( elog_main_t em)

convert event ring events to events, and return them as a vector.

Parameters
emelog_main_t *
Returns
event vector with timestamps in f64 seconds
Note
sets em->events to resulting vector.

Definition at line 626 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_init()

void elog_init ( elog_main_t em,
u32  n_events 
)

Definition at line 513 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_inline()

static void elog_inline ( elog_main_t em,
elog_event_type_t type,
u32  data 
)
inlinestatic

Log a single-datum event, inline version.

Parameters
emelog_main_t *
typeelog_event_type_t * type
datau32 single datum to capture

Definition at line 382 of file elog.h.

+ Here is the call graph for this function:

◆ elog_is_enabled()

static uword elog_is_enabled ( elog_main_t em)
inlinestatic

event logging enabled predicate

Parameters
emelog_main_t *
Returns
1 if enabled, 0 if not enabled

Definition at line 276 of file elog.h.

+ Here is the caller graph for this function:

◆ elog_merge()

void elog_merge ( elog_main_t dst,
u8 dst_tag,
elog_main_t src,
u8 src_tag,
f64  align_tweak 
)

Definition at line 699 of file elog.c.

+ Here is the call graph for this function:

◆ elog_n_events_in_buffer()

static uword elog_n_events_in_buffer ( elog_main_t em)
inlinestatic

Return number of events in the event-log buffer.

Parameters
emelog_main_t *
Returns
number of events in the buffer

Definition at line 191 of file elog.h.

+ Here is the caller graph for this function:

◆ elog_peek_events()

elog_event_t* elog_peek_events ( elog_main_t em)

convert event ring events to events, and return them as a vector.

Parameters
emelog_main_t *
Returns
event vector with timestamps in f64 seconds
Note
no side effects

Definition at line 557 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_read_file()

static clib_error_t* elog_read_file ( elog_main_t em,
char *  clib_file 
)
inlinestatic

Definition at line 551 of file elog.h.

+ Here is the call graph for this function:

◆ elog_read_file_not_inline()

clib_error_t* elog_read_file_not_inline ( elog_main_t em,
char *  clib_file 
)

Definition at line 1199 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_reset_buffer()

static void elog_reset_buffer ( elog_main_t em)
inlinestatic

Reset the event buffer.

Parameters
emelog_main_t *

Definition at line 210 of file elog.h.

+ Here is the caller graph for this function:

◆ elog_resize()

void elog_resize ( elog_main_t em,
u32  n_events 
)

Definition at line 507 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_string()

u32 elog_string ( elog_main_t em,
char *  format,
  ... 
)

add a string to the event-log string table

Often combined with hashing and the T4 elog format specifier to display complex strings in offline tooling

Parameters
emelog_main_t *
formatchar *
VARARGS
Returns
u32 index to add to event log

Definition at line 582 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_time_now()

void elog_time_now ( elog_time_stamp_t et)

Definition at line 440 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_track()

static void elog_track ( elog_main_t em,
elog_event_type_t type,
elog_track_t track,
u32  data 
)
inlinestatic

Log a single-datum event to a specific track, non-inline version.

Parameters
emelog_main_t *
typeelog_event_type_t * type
typeelog_event_track_t * track
datau32 single datum to capture

Definition at line 398 of file elog.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_track_inline()

static void elog_track_inline ( elog_main_t em,
elog_event_type_t type,
elog_track_t track,
u32  data 
)
inlinestatic

Log a single-datum event to a specific track.

Parameters
emelog_main_t *
typeelog_event_type_t * type
typeelog_event_track_t * track
datau32 single datum to capture

Definition at line 415 of file elog.h.

+ Here is the call graph for this function:

◆ elog_track_register()

word elog_track_register ( elog_main_t em,
elog_track_t t 
)

register an event track

Parameters
emelog_main_t *
telog_track_t * track to register
Returns
track index
Note
this function is often called directly

Definition at line 198 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_write_file()

static clib_error_t* elog_write_file ( elog_main_t em,
char *  clib_file,
int  flush_ring 
)
inlinestatic

Definition at line 533 of file elog.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elog_write_file_not_inline()

clib_error_t* elog_write_file_not_inline ( elog_main_t em,
char *  clib_file,
int  flush_ring 
)

Definition at line 1184 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_elog_event()

u8* format_elog_event ( u8 s,
va_list *  va 
)

Definition at line 296 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_elog_track()

u8* format_elog_track ( u8 s,
va_list *  args 
)

Definition at line 408 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ format_elog_track_name()

u8* format_elog_track_name ( u8 s,
va_list *  va 
)

Definition at line 399 of file elog.c.

◆ format_one_elog_event()

char* format_one_elog_event ( void *  em_arg,
void *  ep_arg 
)

Definition at line 431 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize_elog_main()

void serialize_elog_main ( serialize_main_t m,
va_list *  va 
)

Definition at line 1113 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unserialize_elog_main()

void unserialize_elog_main ( serialize_main_t m,
va_list *  va 
)

Definition at line 1147 of file elog.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: