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 6B1C1A04BC for ; Thu, 8 Oct 2020 07:24:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A32B1BB0C; Thu, 8 Oct 2020 07:24:06 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 5DE631B704 for ; Thu, 8 Oct 2020 07:23:46 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052346euoutp02c3fe86c6a66f59b9751592c4a7ba11c3~77PQ9JwoY0628706287euoutp02G for ; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052346euoutp02c3fe86c6a66f59b9751592c4a7ba11c3~77PQ9JwoY0628706287euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134626; bh=5tY3N01YS6Scl9JxLIYxnJAj3A+6+tzDlSAFmFn7+vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hpszh40U/JA68dyVZVAjPEASeNK+23WcxS+rFAGaWgB48i+qW1o3Mrgi50QpYgvDH 6AWW0ukaTn+FYD2nprzNeREIEiJb9T4nbLJ8WIEwZYSp20DUBxd+QKxQ5vCDnZ7h4F BVLB7S1WtQkHH0dSErhhbiZJ4o1uMkvLSpl5pljo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052346eucas1p291d3b26d2878550ab2002234ecf710a7~77PQy3hGa2348123481eucas1p2E; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F4.01.05997.162AE7F5; Thu, 8 Oct 2020 06:23:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18~77PP7f83G2348123481eucas1p2B; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052345eusmtrp165b59c8635194998bb554d1c4a16f551~77PP6pvcl2941529415eusmtrp1a; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-73-5f7ea2618a9a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 99.89.06314.162AE7F5; Thu, 8 Oct 2020 06:23:45 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052344eusmtip1df2afac6652a9fdb6d99c7ae780c5877~77PPU9EPT2784127841eusmtip1_; Thu, 8 Oct 2020 05:23:44 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:19 +0200 Message-Id: <20201008052323.11547-12-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7qJi+riDb7+t7a4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErown214w FtwVqdi9fxVrA2OLYBcjJ4eEgInEmvunmboYuTiEBFYwSpx71c0G4XxhlLiy7zsz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31/5j hJgvL7F6wwGwek6g+Nn/d1khdjUyStw8P5NtAiPfAkaGVYwiqaXFuem5xYZ6xYm5xaV56XrJ +bmbGIGhuO3Yz807GC9tDD7EKMDBqMTDa3C0Nl6INbGsuDL3EKMEB7OSCK/T2dNxQrwpiZVV qUX58UWlOanFhxhNga6ayCwlmpwPjJO8knhDU0NzC0tDc2NzYzMLJXHeDoGDMUIC6Yklqdmp qQWpRTB9TBycUg2MmeJS1+rPdhcd9qljOlBrl3+Ldff+9iNGH/Q2stV4Klm8YpOLCV579O+d iO6HCtYm1nL9VY87Nul3nbK4+WPl1CefI+0EYs7KzPwx12RVQnziinMnUmuiGrRkuCWf/N6x VHn3XrtZ23Ku5K55xblyVnVUyHODpUvOKp6syl/660FsqOv142o/lViKMxINtZiLihMBI80K XFsCAAA= X-CMS-MailID: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v5 11/15] test/distributor: replace delays with spin locks 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" Instead of making delays in test code and waiting for worker hopefully to reach proper states, synchronize worker shutdown test cases with spin lock on atomic variable. Fixes: c0de0eb82e40 ("distributor: switch over to new API") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski --- app/test/test_distributor.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 838a67515..1e0a079ff 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -27,6 +27,7 @@ struct worker_params worker_params; /* statics - all zero-initialized by default */ static volatile int quit; /**< general quit variable for all threads */ static volatile int zero_quit; /**< var for when we just want thr0 to quit*/ +static volatile int zero_sleep; /**< thr0 has quit basic loop and is sleeping*/ static volatile unsigned worker_idx; static volatile unsigned zero_idx; @@ -376,8 +377,10 @@ handle_work_for_shutdown_test(void *arg) /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. */ + __atomic_store_n(&zero_sleep, 1, __ATOMIC_RELEASE); while (zero_quit) usleep(100); + __atomic_store_n(&zero_sleep, 0, __ATOMIC_RELEASE); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -445,7 +448,12 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, /* flush the distributor */ rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); + + zero_quit = 0; + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, @@ -505,9 +513,14 @@ test_flush_with_worker_shutdown(struct worker_params *wp, /* flush the distributor */ rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); zero_quit = 0; + + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); + for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, __atomic_load_n(&worker_stats[i].handled_packets, @@ -615,6 +628,8 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) quit = 0; worker_idx = 0; zero_idx = RTE_MAX_LCORE; + zero_quit = 0; + zero_sleep = 0; } static int -- 2.17.1