From cbbac707c3928665f5a1e88497f91909a560b199 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 3 Nov 2017 10:41:07 -0700 Subject: [PATCH] test/event_perf: fix spdk_app_stop() condition Make sure the event_perf example calls spdk_app_stop() exactly once by using an atomic flag to track when it has been called. Previously, if the timing happens to be right, the current events at the point where spdk_get_ticks() > g_tsc_end becomes true may not be running on the master core, so none of the submit_new_event() calls that are currently running will call spdk_app_stop(), and no new events will be sent, so the test hangs. Also, since event_work_fn() sends multiple events, spdk_app_stop() could be called more than once, since all of the events would be executing on the master core. Change-Id: I384a3e0f56a3305bd4abfd5503325f0c10ca279e Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/385677 Reviewed-by: Ben Walker Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- test/lib/event/event_perf/event_perf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/lib/event/event_perf/event_perf.c b/test/lib/event/event_perf/event_perf.c index 5d5b6f2eb..d9738c6bf 100644 --- a/test/lib/event/event_perf/event_perf.c +++ b/test/lib/event/event_perf/event_perf.c @@ -49,6 +49,8 @@ static int g_time_in_sec; static uint64_t call_count[RTE_MAX_LCORE]; +static bool g_app_stopped = false; + static void submit_new_event(void *arg1, void *arg2) { @@ -56,7 +58,7 @@ submit_new_event(void *arg1, void *arg2) static __thread uint32_t next_lcore = RTE_MAX_LCORE; if (spdk_get_ticks() > g_tsc_end) { - if (rte_lcore_id() == rte_get_master_lcore()) { + if (__sync_bool_compare_and_swap(&g_app_stopped, false, true)) { spdk_app_stop(0); } return;