diff options
-rw-r--r-- | src/tools/g2/clib.c | 2 | ||||
-rw-r--r-- | src/tools/perftool/c2cpel.c | 20 | ||||
-rw-r--r-- | src/vppinfra/elog.c | 56 | ||||
-rw-r--r-- | src/vppinfra/elog.h | 9 | ||||
-rw-r--r-- | src/vppinfra/vec.c | 12 | ||||
-rw-r--r-- | src/vppinfra/vec.h | 2 | ||||
-rw-r--r-- | src/vppinfra/vec_bootstrap.h | 1 |
7 files changed, 78 insertions, 24 deletions
diff --git a/src/tools/g2/clib.c b/src/tools/g2/clib.c index da9fd52c2d0..3cfc2637673 100644 --- a/src/tools/g2/clib.c +++ b/src/tools/g2/clib.c @@ -141,7 +141,7 @@ int read_clib_file(char *clib_file) delta = ep->time - starttime; - add_clib_event (delta, ep->track, ep->type + 1, i); + add_clib_event (delta, ep->track, ep->event_type + 1, i); } cpel_event_finalize(); diff --git a/src/tools/perftool/c2cpel.c b/src/tools/perftool/c2cpel.c index 35885debef8..72049054ae1 100644 --- a/src/tools/perftool/c2cpel.c +++ b/src/tools/perftool/c2cpel.c @@ -1,4 +1,4 @@ -/* +/* *------------------------------------------------------------------ * Copyright (c) 2006-2016 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,7 +72,7 @@ void convert_clib_file(char *clib_file) /* Seconds since start of log */ delta = e->time - starttime; - + /* u64 nanoseconds since start of log */ timestamp = delta * 1e9; @@ -81,11 +81,11 @@ void convert_clib_file(char *clib_file) /* allocate an event instance */ vec_add2(the_events, ep, 1); ep->timestamp = timestamp; - + /* convert string event code to a real number */ - t = vec_elt_at_index (em->event_types, e->type); + t = vec_elt_at_index (em->event_types, e->event_type); - /* + /* * Construct a reasonable event name. * Truncate the format string at the first whitespace break * or printf format character. @@ -189,14 +189,14 @@ int main (int argc, char **argv) continue; usage: - fformat(stderr, + fformat(stderr, "c2cpel [--input-file] <filename> --output-file <filename>\n"); exit(1); } if (vec_len(inputfiles) == 0 || outputfile == 0) goto usage; - + if (vec_len(inputfiles) > 1) goto usage; @@ -211,12 +211,12 @@ int main (int argc, char **argv) clib_unix_warning ("couldn't create %s", outputfile); exit (1); } - + alpha_sort_tracks(); fixup_event_tracks(); /* - * Four sections: string-table, event definitions, track defs, events. + * Four sections: string-table, event definitions, track defs, events. */ if (!write_cpel_header(ofp, 4)) { clib_warning ("Error writing cpel header to %s...\n", outputfile); @@ -246,7 +246,7 @@ int main (int argc, char **argv) clib_warning ("Error writing events to %s...\n", outputfile); unlink(outputfile); exit(1); - + } fclose(ofp); exit (0); diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c index caddf6f3757..62bd9797acc 100644 --- a/src/vppinfra/elog.c +++ b/src/vppinfra/elog.c @@ -302,7 +302,7 @@ format_elog_event (u8 * s, va_list * va) void *d = (u8 *) e->data; char arg_format[64]; - t = vec_elt_at_index (em->event_types, e->type); + t = vec_elt_at_index (em->event_types, e->event_type); f = t->format; a = t->format_args; @@ -420,8 +420,8 @@ format_elog_track (u8 * s, va_list * args) { if (e->track != track_index) continue; - s = format (s, "%U%18.9f: %U\n", format_white_space, indent, e->time + dt, - format_elog_event, em, e); + s = format (s, "%U%18.9f: %U\n", format_white_space, indent, + e->time + dt, format_elog_event, em, e); } vec_free (es); return s; @@ -732,10 +732,11 @@ elog_merge (elog_main_t * dst, u8 * dst_tag, elog_main_t * src, u8 * src_tag, /* Across all (copied) src events... */ for (e = dst->events + l; e < vec_end (dst->events); e++) { - elog_event_type_t *t = vec_elt_at_index (src->event_types, e->type); + elog_event_type_t *t = + vec_elt_at_index (src->event_types, e->event_type); /* Remap type from src -> dst. */ - e->type = find_or_create_type (dst, t); + e->event_type = find_or_create_type (dst, t); /* Remap string table offsets for 'T' format args */ maybe_fix_string_table_offset (e, t, @@ -847,11 +848,11 @@ serialize_elog_event (serialize_main_t * m, va_list * va) { elog_main_t *em = va_arg (*va, elog_main_t *); elog_event_t *e = va_arg (*va, elog_event_t *); - elog_event_type_t *t = vec_elt_at_index (em->event_types, e->type); + elog_event_type_t *t = vec_elt_at_index (em->event_types, e->event_type); u8 *d = e->data; u8 *p = (u8 *) t->format_args; - serialize_integer (m, e->type, sizeof (e->type)); + serialize_integer (m, e->event_type, sizeof (e->event_type)); serialize_integer (m, e->track, sizeof (e->track)); serialize (m, serialize_f64, e->time); @@ -914,18 +915,18 @@ unserialize_elog_event (serialize_main_t * m, va_list * va) { u16 tmp[2]; - unserialize_integer (m, &tmp[0], sizeof (e->type)); + unserialize_integer (m, &tmp[0], sizeof (e->event_type)); unserialize_integer (m, &tmp[1], sizeof (e->track)); - e->type = tmp[0]; + e->event_type = tmp[0]; e->track = tmp[1]; /* Make sure it fits. */ - ASSERT (e->type == tmp[0]); + ASSERT (e->event_type == tmp[0]); ASSERT (e->track == tmp[1]); } - t = vec_elt_at_index (em->event_types, e->type); + t = vec_elt_at_index (em->event_types, e->event_type); unserialize (m, unserialize_f64, &e->time); @@ -1158,6 +1159,39 @@ unserialize_elog_main (serialize_main_t * m, va_list * va) } } +#ifdef CLIB_UNIX +clib_error_t * +elog_write_file_not_inline (elog_main_t * em, char *clib_file, int flush_ring) +{ + serialize_main_t m; + clib_error_t *error; + + error = serialize_open_clib_file (&m, clib_file); + if (error) + return error; + error = serialize (&m, serialize_elog_main, em, flush_ring); + if (!error) + serialize_close (&m); + return error; +} + +clib_error_t * +elog_read_file_not_inline (elog_main_t * em, char *clib_file) +{ + serialize_main_t m; + clib_error_t *error; + + error = unserialize_open_clib_file (&m, clib_file); + if (error) + return error; + error = unserialize (&m, unserialize_elog_main, em); + if (!error) + unserialize_close (&m); + return error; +} +#endif /* CLIB_UNIX */ + + /* * fd.io coding-style-patch-verification: ON * diff --git a/src/vppinfra/elog.h b/src/vppinfra/elog.h index 9f957e336d0..ee63d5b491b 100644 --- a/src/vppinfra/elog.h +++ b/src/vppinfra/elog.h @@ -68,7 +68,7 @@ typedef struct }; /** Event type index. */ - u16 type; + u16 event_type; /** Track for this event. Tracks allow events to be sorted and displayed by track. Think of 2 dimensional display with time and @@ -324,7 +324,7 @@ elog_event_data_inline (elog_main_t * em, e = vec_elt_at_index (em->event_ring, ei); e->time_cycles = cpu_time; - e->type = type_index; + e->event_type = type_index; e->track = track_index; /* Return user data for caller to fill in. */ @@ -543,6 +543,9 @@ elog_write_file (elog_main_t * em, char *clib_file, int flush_ring) return error; } +clib_error_t *elog_write_file_not_inline (elog_main_t * em, char *clib_file, + int flush_ring); + always_inline clib_error_t * elog_read_file (elog_main_t * em, char *clib_file) { @@ -558,6 +561,8 @@ elog_read_file (elog_main_t * em, char *clib_file) return error; } +clib_error_t *elog_read_file_not_inline (elog_main_t * em, char *clib_file); + #endif /* CLIB_UNIX */ #endif /* included_clib_elog_h */ diff --git a/src/vppinfra/vec.c b/src/vppinfra/vec.c index 05a557ebb54..441e1acc576 100644 --- a/src/vppinfra/vec.c +++ b/src/vppinfra/vec.c @@ -140,6 +140,18 @@ clib_mem_is_vec_h (void *v, uword header_bytes) return clib_mem_is_heap_object (vec_header (v, header_bytes)); } +u32 +vec_len_not_inline (void *v) +{ + return vec_len (v); +} + +void +vec_free_not_inline (void *v) +{ + vec_free (v); +} + /** \cond */ #ifdef TEST diff --git a/src/vppinfra/vec.h b/src/vppinfra/vec.h index d4063e64bdc..1fcb5f1a374 100644 --- a/src/vppinfra/vec.h +++ b/src/vppinfra/vec.h @@ -379,6 +379,8 @@ do { \ */ #define vec_free(V) vec_free_h(V,0) +void vec_free_not_inline (void *v); + /**\brief Free vector user header (syntactic sugar) @param h vector header @void diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h index 501db61c016..53968070c0e 100644 --- a/src/vppinfra/vec_bootstrap.h +++ b/src/vppinfra/vec_bootstrap.h @@ -140,6 +140,7 @@ vec_aligned_header_end (void *v, uword header_bytes, uword align) */ #define vec_len(v) ((v) ? _vec_len(v) : 0) +u32 vec_len_not_inline (void *v); /** \brief Vector's NUMA id (lvalue-capable) |