test/distributor: fix spurious failure
authorRuifeng Wang <ruifeng.wang@arm.com>
Tue, 15 Oct 2019 09:28:26 +0000 (17:28 +0800)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 25 Oct 2019 08:27:51 +0000 (10:27 +0200)
Sanity test could spuriously fail with reporting flush count error.
It was caused by worker stat coherent issue between distributor and
worker thread.
Fix this issue by using atomic operations to update worker stat.

Fixes: c3eabff124e6 ("distributor: add unit tests")
Cc: stable@dpdk.org
Signed-off-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
Acked-by: David Hunt <david.hunt@intel.com>
app/test/test_distributor.c

index 7090b55..ba1f81c 100644 (file)
@@ -70,12 +70,14 @@ handle_work(void *arg)
                buf[i] = NULL;
        num = rte_distributor_get_pkt(db, id, buf, buf, num);
        while (!quit) {
-               worker_stats[id].handled_packets += num;
+               __atomic_fetch_add(&worker_stats[id].handled_packets, num,
+                               __ATOMIC_RELAXED);
                count += num;
                num = rte_distributor_get_pkt(db, id,
                                buf, buf, num);
        }
-       worker_stats[id].handled_packets += num;
+       __atomic_fetch_add(&worker_stats[id].handled_packets, num,
+                       __ATOMIC_RELAXED);
        count += num;
        rte_distributor_return_pkt(db, id, buf, num);
        return 0;