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/elog.c | |
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/elog.c')
-rw-r--r-- | src/vppinfra/elog.c | 23 |
1 files changed, 17 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 |