[v3,2/2] test/distributor: fix false unit test failure

Message ID 20191015092826.13002-3-ruifeng.wang@arm.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series fix distributor unit test |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ruifeng Wang Oct. 15, 2019, 9:28 a.m. UTC
  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>
---
 app/test/test_distributor.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Hunt, David Oct. 25, 2019, 8:13 a.m. UTC | #1
On 15/10/2019 10:28, Ruifeng Wang wrote:
> 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>
> ---
>   app/test/test_distributor.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 	return 0;


Acked-by: David Hunt <david.hunt@intel.com>
  

Patch

diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c
index 7090b55f8..ba1f81cf8 100644
--- a/app/test/test_distributor.c
+++ b/app/test/test_distributor.c
@@ -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;