app/crypto-perf: fix display once detection
[dpdk.git] / app / test-crypto-perf / cperf_test_latency.c
index 0fc3a66..62478a2 100644 (file)
@@ -129,7 +129,7 @@ cperf_latency_test_runner(void *arg)
        uint8_t burst_size_idx = 0;
        uint32_t imix_idx = 0;
 
-       static int only_once;
+       static rte_atomic16_t display_once = RTE_ATOMIC16_INIT(0);
 
        if (ctx == NULL)
                return 0;
@@ -311,7 +311,7 @@ cperf_latency_test_runner(void *arg)
                time_min = tunit*(double)(tsc_min) / tsc_hz;
 
                if (ctx->options->csv) {
-                       if (!only_once)
+                       if (rte_atomic16_test_and_set(&display_once))
                                printf("\n# lcore, Buffer Size, Burst Size, Pakt Seq #, "
                                                "Packet Size, cycles, time (us)");
 
@@ -326,7 +326,6 @@ cperf_latency_test_runner(void *arg)
                                                / tsc_hz);
 
                        }
-                       only_once = 1;
                } else {
                        printf("\n# Device %d on lcore %u\n", ctx->dev_id,
                                ctx->lcore_id);