FD.io VPP  v18.07.1-19-g511ce25
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 (u8 *s, va_list *va)
 
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)
 
static clib_error_telog_write_file (elog_main_t *em, char *clib_file, int flush_ring)
 
static clib_error_telog_read_file (elog_main_t *em, char *clib_file)
 

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

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

Definition at line 471 of file elog.h.

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

Definition at line 481 of file elog.h.

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

Definition at line 482 of file elog.h.

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

Definition at line 472 of file elog.h.

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

Definition at line 468 of file elog.h.

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

Definition at line 475 of file elog.h.

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

Definition at line 477 of file elog.h.

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

Definition at line 467 of file elog.h.

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

Definition at line 459 of file elog.h.

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

Definition at line 460 of file elog.h.

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

Definition at line 439 of file elog.h.

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

Definition at line 454 of file elog.h.

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

Definition at line 451 of file elog.h.

#define ELOG_TYPE_DECLARE_HELPER (   f,
  fmt,
  func 
)
Value:
static elog_event_type_t __ELOG_TYPE_VAR(f) = \
#define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt, func)
Definition: elog.h:441

Definition at line 447 of file elog.h.

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

Definition at line 462 of file elog.h.

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

Definition at line 464 of file elog.h.

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

Definition at line 465 of file elog.h.

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

Definition at line 444 of file elog.h.

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

Definition at line 441 of file elog.h.

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

Definition at line 461 of file elog.h.

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

Definition at line 463 of file elog.h.

Function Documentation

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 364 of file elog.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void elog_alloc ( elog_main_t em,
u32  n_events 
)

Definition at line 452 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 198 of file elog.h.

+ Here is the caller graph for this function:

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

Definition at line 423 of file elog.h.

+ Here is the call graph for this function:

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

Definition at line 429 of file elog.h.

+ Here is the call graph for this function:

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 233 of file elog.h.

static void elog_disable_trigger ( elog_main_t em)
inlinestatic

Definition at line 245 of file elog.h.

+ Here is the call graph for this function:

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 217 of file elog.h.

+ Here is the caller graph for this function:

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:

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 290 of file elog.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 348 of file elog.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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_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 552 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void elog_init ( elog_main_t em,
u32  n_events 
)

Definition at line 466 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 379 of file elog.h.

+ Here is the call graph for this function:

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 273 of file elog.h.

+ Here is the caller graph for this function:

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

Definition at line 625 of file elog.c.

+ Here is the call graph for this function:

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 188 of file elog.h.

+ Here is the caller graph for this function:

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 509 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 543 of file elog.h.

+ Here is the call graph for this function:

static void elog_reset_buffer ( elog_main_t em)
inlinestatic

Reset the event buffer.

Parameters
emelog_main_t *

Definition at line 207 of file elog.h.

+ Here is the caller graph for this function:

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 534 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void elog_time_now ( elog_time_stamp_t et)

Definition at line 408 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 395 of file elog.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 412 of file elog.h.

+ Here is the call graph for this function:

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:

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

Definition at line 528 of file elog.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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:

u8* format_elog_track ( u8 s,
va_list *  va 
)

Definition at line 399 of file elog.c.

+ Here is the call graph for this function:

void serialize_elog_main ( serialize_main_t m,
va_list *  va 
)

Definition at line 1038 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void unserialize_elog_main ( serialize_main_t m,
va_list *  va 
)

Definition at line 1072 of file elog.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function: