From cf0c9ee5ad7dc1079596ebee1e2bc83beb39bb42 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Wed, 1 Sep 2021 15:15:41 +0200 Subject: [PATCH] lib/trace_parser: update object statistics Object's statistics (its index and start timestamp) are now tracked and updated in the trace entry object. This is the final piece of code that had to be copied from the trace app. The following patch will remove that code from the application and replace it with functions from the trace_parse library. Signed-off-by: Konrad Sztyber Change-Id: I1acaefb5a516bbc59c0549b2f66a5c52368bcd2c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9435 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Krzysztof Karas Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- lib/trace_parser/trace.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/trace_parser/trace.cpp b/lib/trace_parser/trace.cpp index f165351ff..49098d50a 100644 --- a/lib/trace_parser/trace.cpp +++ b/lib/trace_parser/trace.cpp @@ -81,6 +81,14 @@ struct argument_context { } }; +struct object_stats { + std::map index; + std::map start; + uint64_t counter; + + object_stats() : counter(0) {} +}; + struct spdk_trace_parser { spdk_trace_parser(const spdk_trace_parser_opts *opts); ~spdk_trace_parser(); @@ -104,6 +112,7 @@ private: uint64_t _tsc_offset; entry_map _entries; entry_map::iterator _iter; + object_stats _stats[SPDK_TRACE_MAX_OBJECT]; }; uint64_t @@ -176,6 +185,7 @@ spdk_trace_parser::next_entry(spdk_trace_parser_entry *pe) { spdk_trace_tpoint *tpoint; spdk_trace_entry *entry; + object_stats *stats; if (_iter == _entries.end()) { return false; @@ -184,6 +194,22 @@ spdk_trace_parser::next_entry(spdk_trace_parser_entry *pe) pe->entry = entry = _iter->second; pe->lcore = _iter->first.lcore; tpoint = &_histories->flags.tpoint[entry->tpoint_id]; + stats = &_stats[tpoint->object_type]; + + if (tpoint->new_object) { + stats->index[entry->object_id] = stats->counter++; + stats->start[entry->object_id] = entry->tsc; + } + + if (tpoint->object_type != OBJECT_NONE) { + if (spdk_likely(stats->start.find(entry->object_id) != stats->start.end())) { + pe->object_index = stats->index[entry->object_id]; + pe->object_start = stats->start[entry->object_id]; + } else { + pe->object_index = UINT64_MAX; + pe->object_start = UINT64_MAX; + } + } argument_context argctx(entry, pe->lcore); for (uint8_t i = 0; i < tpoint->num_args; ++i) {