From c943e9ff4f0fb1f3b55e88d709fa2ef9ca7b0456 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 21 Jul 2016 17:11:15 -0700 Subject: [PATCH] trace: hard-code lcore history array size Make sure the trace history that is exported via shared memory is always the same size, regardless of DPDK configuration. Also removes the necessity of including DPDK headers from spdk/trace.h (so we have to fix up other files to include what they use). Change-Id: I32f88921fd95c64a9d1f4ba768ae75e2ca5d91da Signed-off-by: Daniel Verkamp --- app/trace/trace.cpp | 10 +++++----- include/spdk/trace.h | 7 +++---- lib/event/app.c | 2 ++ lib/nvmf/rdma.c | 1 + lib/trace/trace.c | 10 ++++++++-- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/trace/trace.cpp b/app/trace/trace.cpp index 3c476a990..854e193eb 100644 --- a/app/trace/trace.cpp +++ b/app/trace/trace.cpp @@ -314,7 +314,7 @@ int main(int argc, char **argv) void *history_ptr; struct spdk_trace_history *history_entries, *history; int fd, i; - int lcore = RTE_MAX_LCORE; + int lcore = SPDK_TRACE_MAX_LCORE; uint64_t tsc_offset; const char *app_name = "ids"; int op; @@ -325,10 +325,10 @@ int main(int argc, char **argv) switch (op) { case 'c': lcore = atoi(optarg); - if (lcore > RTE_MAX_LCORE) { + if (lcore > SPDK_TRACE_MAX_LCORE) { fprintf(stderr, "Selected lcore: %d " "exceeds maximum %d\n", lcore, - RTE_MAX_LCORE); + SPDK_TRACE_MAX_LCORE); exit(1); } break; @@ -373,8 +373,8 @@ int main(int argc, char **argv) memcpy(history_entries, g_histories->per_lcore_history, sizeof(g_histories->per_lcore_history)); - if (lcore == RTE_MAX_LCORE) { - for (i = 0; i < RTE_MAX_LCORE; i++) { + if (lcore == SPDK_TRACE_MAX_LCORE) { + for (i = 0; i < SPDK_TRACE_MAX_LCORE; i++) { history = &history_entries[i]; if (history->entries[0].tsc == 0) { continue; diff --git a/include/spdk/trace.h b/include/spdk/trace.h index a96aec05b..c90e2228c 100644 --- a/include/spdk/trace.h +++ b/include/spdk/trace.h @@ -42,9 +42,6 @@ #include #include -#include -#include - #ifdef __cplusplus extern "C" { #endif @@ -116,10 +113,12 @@ struct spdk_trace_history { }; +#define SPDK_TRACE_MAX_LCORE 128 + struct spdk_trace_histories { uint64_t tsc_rate; uint64_t tpoint_mask[SPDK_TRACE_MAX_GROUP_ID]; - struct spdk_trace_history per_lcore_history[RTE_MAX_LCORE]; + struct spdk_trace_history per_lcore_history[SPDK_TRACE_MAX_LCORE]; struct spdk_trace_owner owner[UCHAR_MAX + 1]; struct spdk_trace_object object[UCHAR_MAX + 1]; struct spdk_trace_tpoint tpoint[SPDK_TRACE_MAX_TPOINT_ID]; diff --git a/lib/event/app.c b/lib/event/app.c index 6c3e05356..758f49a67 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -45,7 +45,9 @@ #include #include +#include #include +#include #include "spdk/log.h" #include "spdk/conf.h" diff --git a/lib/nvmf/rdma.c b/lib/nvmf/rdma.c index df211ae68..00b2c99a3 100644 --- a/lib/nvmf/rdma.c +++ b/lib/nvmf/rdma.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "nvmf_internal.h" diff --git a/lib/trace/trace.c b/lib/trace/trace.c index 0c136ec8a..0cb7a9959 100644 --- a/lib/trace/trace.c +++ b/lib/trace/trace.c @@ -61,6 +61,7 @@ spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size, struct spdk_trace_history *lcore_history; struct spdk_trace_entry *next_entry; uint64_t tsc; + unsigned lcore; /* * Tracepoint group ID is encoded in the tpoint_id. Lower 6 bits determine the tracepoint @@ -72,7 +73,12 @@ spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size, return; } - lcore_history = &g_trace_histories->per_lcore_history[rte_lcore_id()]; + lcore = rte_lcore_id(); + if (lcore >= SPDK_TRACE_MAX_LCORE) { + return; + } + + lcore_history = &g_trace_histories->per_lcore_history[lcore]; tsc = rte_get_timer_cycles(); lcore_history->tpoint_count[tpoint_id]++; @@ -182,7 +188,7 @@ spdk_trace_init(const char *shm_name) g_trace_histories->tsc_rate = rte_get_timer_hz(); - for (i = 0; i < RTE_MAX_LCORE; i++) { + for (i = 0; i < SPDK_TRACE_MAX_LCORE; i++) { g_trace_histories->per_lcore_history[i].lcore = i; }