diff options
author | Dave Barach <dave@barachs.net> | 2020-11-25 10:07:09 -0500 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-11-25 19:01:08 +0000 |
commit | bc867c3d2137dab4b1395196c1936233517980ab (patch) | |
tree | 2f0439bc2c6ba0bde5bd3cf3d87723454c74f3d7 /src/vppinfra | |
parent | 7483a7272d15354486371be7a20c4bf35ab2eb38 (diff) |
vlib: add elog events for vlib log entries
Pretty interesting to see how long plugins take to load.
Type: improvement
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: If496eb73b2e1fd9dd714142cd5195fa7ccd93ebd
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/elog.c | 23 | ||||
-rw-r--r-- | src/vppinfra/elog.h | 1 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c index 6fa44cb82f9..423d8d5ba15 100644 --- a/src/vppinfra/elog.c +++ b/src/vppinfra/elog.c @@ -484,18 +484,29 @@ elog_nsec_per_clock (elog_main_t * em) &em->init_time)); } -__clib_export void -elog_alloc (elog_main_t * em, u32 n_events) +static void +elog_alloc_internal (elog_main_t * em, u32 n_events, int free_ring) { - if (em->event_ring) + if (free_ring && em->event_ring) vec_free (em->event_ring); /* Ring size must be a power of 2. */ em->event_ring_size = n_events = max_pow2 (n_events); - /* Leave an empty ievent at end so we can always speculatively write - and event there (possibly a long form event). */ - vec_resize_aligned (em->event_ring, n_events, CLIB_CACHE_LINE_BYTES); + vec_validate_aligned (em->event_ring, n_events, CLIB_CACHE_LINE_BYTES); + _vec_len (em->event_ring) = n_events; +} + +__clib_export void +elog_alloc (elog_main_t * em, u32 n_events) +{ + elog_alloc_internal (em, n_events, 1 /* free ring */ ); +} + +__clib_export void +elog_resize (elog_main_t * em, u32 n_events) +{ + elog_alloc_internal (em, n_events, 0 /* do not free ring */ ); } __clib_export void diff --git a/src/vppinfra/elog.h b/src/vppinfra/elog.h index 93ba4f5e8cc..d0825bdd5b2 100644 --- a/src/vppinfra/elog.h +++ b/src/vppinfra/elog.h @@ -526,6 +526,7 @@ 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); #ifdef CLIB_UNIX always_inline clib_error_t * |