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 73566A3160 for ; Sat, 12 Oct 2019 04:45:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D6C61EB98; Sat, 12 Oct 2019 04:45:07 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by dpdk.org (Postfix) with ESMTP id 9F3E61EB91; Sat, 12 Oct 2019 04:45:05 +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 B324E142F; Fri, 11 Oct 2019 19:45:04 -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 8ED1D3F703; Fri, 11 Oct 2019 19:45:02 -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: Sat, 12 Oct 2019 10:43:52 +0800 Message-Id: <20191012024352.23545-3-ruifeng.wang@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191012024352.23545-1-ruifeng.wang@arm.com> References: <20191008095524.1585-1-ruifeng.wang@arm.com> <20191012024352.23545-1-ruifeng.wang@arm.com> Subject: [dpdk-dev] [PATCH v2 2/2] test/distributor: fix false unit test failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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