test/event_perf: remove DPDK dependency

Use the SPDK env layer functions to get the number of cores and iterate
over core numbers.

Change-Id: I77870ebcffc07db680bbb3783fbe5944cf88e2ea
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393188
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-12-28 10:15:04 -07:00 committed by Jim Harris
parent 543cb17248
commit ddfc063f90
2 changed files with 19 additions and 8 deletions

View File

@ -35,7 +35,6 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
CFLAGS += $(ENV_CFLAGS)
APP = event_perf APP = event_perf
C_SRCS := event_perf.c C_SRCS := event_perf.c

View File

@ -33,9 +33,6 @@
#include "spdk/stdinc.h" #include "spdk/stdinc.h"
#include <rte_config.h>
#include <rte_lcore.h>
#include "spdk/env.h" #include "spdk/env.h"
#include "spdk/event.h" #include "spdk/event.h"
#include "spdk_internal/event.h" #include "spdk_internal/event.h"
@ -47,7 +44,7 @@ static uint64_t g_tsc_end;
static int g_time_in_sec; static int g_time_in_sec;
static uint64_t call_count[RTE_MAX_LCORE]; static uint64_t *call_count;
static bool g_app_stopped = false; static bool g_app_stopped = false;
@ -55,7 +52,7 @@ static void
submit_new_event(void *arg1, void *arg2) submit_new_event(void *arg1, void *arg2)
{ {
struct spdk_event *event; struct spdk_event *event;
static __thread uint32_t next_lcore = RTE_MAX_LCORE; static __thread uint32_t next_lcore = UINT32_MAX;
if (spdk_get_ticks() > g_tsc_end) { if (spdk_get_ticks() > g_tsc_end) {
if (__sync_bool_compare_and_swap(&g_app_stopped, false, true)) { if (__sync_bool_compare_and_swap(&g_app_stopped, false, true)) {
@ -64,8 +61,11 @@ submit_new_event(void *arg1, void *arg2)
return; return;
} }
if (next_lcore == RTE_MAX_LCORE) { if (next_lcore == UINT32_MAX) {
next_lcore = rte_get_next_lcore(rte_lcore_id(), 0, 1); next_lcore = spdk_env_get_next_core(spdk_env_get_current_core());
if (next_lcore == UINT32_MAX) {
next_lcore = spdk_env_get_first_core();
}
} }
call_count[next_lcore]++; call_count[next_lcore]++;
@ -88,6 +88,13 @@ event_perf_start(void *arg1, void *arg2)
{ {
uint32_t i; uint32_t i;
call_count = calloc(spdk_env_get_last_core() + 1, sizeof(*call_count));
if (call_count == NULL) {
fprintf(stderr, "call_count allocation failed\n");
spdk_app_stop(1);
return;
}
g_tsc_rate = spdk_get_ticks_hz(); g_tsc_rate = spdk_get_ticks_hz();
g_tsc_us_rate = g_tsc_rate / (1000 * 1000); g_tsc_us_rate = g_tsc_rate / (1000 * 1000);
g_tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate; g_tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
@ -116,12 +123,17 @@ performance_dump(int io_time)
{ {
uint32_t i; uint32_t i;
if (call_count == NULL) {
return;
}
printf("\n"); printf("\n");
SPDK_ENV_FOREACH_CORE(i) { SPDK_ENV_FOREACH_CORE(i) {
printf("lcore %2d: %8ju\n", i, call_count[i] / g_time_in_sec); printf("lcore %2d: %8ju\n", i, call_count[i] / g_time_in_sec);
} }
fflush(stdout); fflush(stdout);
free(call_count);
} }
int int