app/crypto-perf: fix display once detection
[dpdk.git] / app / test-crypto-perf / cperf_test_pmd_cyclecount.c
index f08a226..74371fa 100644 (file)
@@ -391,7 +391,7 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx)
        state.lcore = rte_lcore_id();
        state.linearize = 0;
 
-       static int only_once;
+       static rte_atomic16_t display_once = RTE_ATOMIC16_INIT(0);
        static bool warmup = true;
 
        /*
@@ -437,13 +437,12 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx)
                }
 
                if (!opts->csv) {
-                       if (!only_once)
+                       if (rte_atomic16_test_and_set(&display_once))
                                printf(PRETTY_HDR_FMT, "lcore id", "Buf Size",
                                                "Burst Size", "Enqueued",
                                                "Dequeued", "Enq Retries",
                                                "Deq Retries", "Cycles/Op",
                                                "Cycles/Enq", "Cycles/Deq");
-                       only_once = 1;
 
                        printf(PRETTY_LINE_FMT, state.ctx->lcore_id,
                                        opts->test_buffer_size, test_burst_size,
@@ -454,13 +453,12 @@ cperf_pmd_cyclecount_test_runner(void *test_ctx)
                                        state.cycles_per_enq,
                                        state.cycles_per_deq);
                } else {
-                       if (!only_once)
+                       if (rte_atomic16_test_and_set(&display_once))
                                printf(CSV_HDR_FMT, "# lcore id", "Buf Size",
                                                "Burst Size", "Enqueued",
                                                "Dequeued", "Enq Retries",
                                                "Deq Retries", "Cycles/Op",
                                                "Cycles/Enq", "Cycles/Deq");
-                       only_once = 1;
 
                        printf(CSV_LINE_FMT, state.ctx->lcore_id,
                                        opts->test_buffer_size, test_burst_size,