From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BE27A2EFC for ; Tue, 15 Oct 2019 11:29:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8DDB01EB35; Tue, 15 Oct 2019 11:29:16 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id ECC631EAB1; Tue, 15 Oct 2019 11:29:03 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F95D28; Tue, 15 Oct 2019 02:29:03 -0700 (PDT) Received: from net-arm-c2400-02.shanghai.arm.com (net-arm-c2400-02.shanghai.arm.com [10.169.40.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0A21D3F718; Tue, 15 Oct 2019 02:29:00 -0700 (PDT) From: Ruifeng Wang To: david.hunt@intel.com Cc: dev@dpdk.org, hkalra@marvell.com, gavin.hu@arm.com, honnappa.nagarahalli@arm.com, nd@arm.com, Ruifeng Wang , stable@dpdk.org Date: Tue, 15 Oct 2019 17:28:26 +0800 Message-Id: <20191015092826.13002-3-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015092826.13002-1-ruifeng.wang@arm.com> References: <20191008095524.1585-1-ruifeng.wang@arm.com> <20191015092826.13002-1-ruifeng.wang@arm.com> Subject: [dpdk-stable] [PATCH v3 2/2] test/distributor: fix false unit test failure X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 Reviewed-by: Gavin Hu --- app/test/test_distributor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; -- 2.17.1