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 <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-07-21 17:11:15 -07:00
parent 89031c3e27
commit c943e9ff4f
5 changed files with 19 additions and 11 deletions

View File

@ -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;

View File

@ -42,9 +42,6 @@
#include <inttypes.h>
#include <limits.h>
#include <rte_config.h>
#include <rte_lcore.h>
#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];

View File

@ -45,7 +45,9 @@
#include <fcntl.h>
#include <signal.h>
#include <rte_config.h>
#include <rte_debug.h>
#include <rte_lcore.h>
#include "spdk/log.h"
#include "spdk/conf.h"

View File

@ -44,6 +44,7 @@
#include <rte_debug.h>
#include <rte_cycles.h>
#include <rte_timer.h>
#include <rte_lcore.h>
#include <rte_malloc.h>
#include "nvmf_internal.h"

View File

@ -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;
}