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 50A55A04B1 for ; Wed, 23 Sep 2020 15:25:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9181A1DC6E; Wed, 23 Sep 2020 15:25:52 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 3B1E11DB53 for ; Wed, 23 Sep 2020 15:25:46 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200923132545euoutp026a154a19b2fb5cd8581613962b655ef0~3bI0hTAHO0994309943euoutp02I for ; Wed, 23 Sep 2020 13:25:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200923132545euoutp026a154a19b2fb5cd8581613962b655ef0~3bI0hTAHO0994309943euoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600867545; bh=Aad7i1ZMUc3rAZvaKTVtYAaNPC1c1LFWoHAxNKuK8lU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iMMDnW5jOpF0VjRofnvSLJ1zpe8wAwlaUVAz6u73s+tktmxFOvTuCQpFjC476KE8D SSRTYcMBvfNahVXGd2Oklw2Qo8IFPFb1wXwm8onEterBcafoRWJ/Kq2hv0beYKeN+D aTrAJstXnDaabdolZdh6Zbe6bLDyE4FhtzUowljs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200923132545eucas1p288b0aa3869a62a34105ee243dd46b318~3bI0XGX3p1223812238eucas1p26; Wed, 23 Sep 2020 13:25:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 8B.33.06318.9DC4B6F5; Wed, 23 Sep 2020 14:25:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200923132545eucas1p10db12d91121c9afdbab338bb60c8ed37~3bIz1kp622311923119eucas1p1V; Wed, 23 Sep 2020 13:25:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200923132545eusmtrp117a094952ebeb0ceebc5fa7d711c9990~3bIz01Rel3185331853eusmtrp1m; Wed, 23 Sep 2020 13:25:45 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-ff-5f6b4cd9312a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 53.FA.06017.9DC4B6F5; Wed, 23 Sep 2020 14:25:45 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200923132544eusmtip238b32e84fbde6d9e6feefe086059645f~3bIzOjJjD2716427164eusmtip2I; Wed, 23 Sep 2020 13:25:44 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Wed, 23 Sep 2020 15:25:34 +0200 Message-Id: <20200923132541.21417-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923132541.21417-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djPc7o3fbLjDW490bO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroy16/ez F8yXqtjy+hBrA2OTaBcjJ4eEgInEsZm7GbsYuTiEBFYwSlx4N5EZJCEk8IVR4vq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YzSvgKnH6N8RI CQF5idUbDoDVcwq4SXz48Z4R4pxGRomNb9sYJzDyLWBkWMUoklpanJueW2ykV5yYW1yal66X nJ+7iREYiNuO/dyyg7HrXfAhRgEORiUeXg7d7Hgh1sSy4srcQ4wSHMxKIrxOZ0/HCfGmJFZW pRblxxeV5qQWH2I0BbpqIrOUaHI+MErySuINTQ3NLSwNzY3Njc0slMR5OwQOxggJpCeWpGan phakFsH0MXFwSjUwbrhktIt/oYvQX4Fzu5hrl74MFAvTmCH6qewll2GX2vZNvNyK8d4nN8Qx nX58yskoM0NH8kpgT/yZJL3nBut1Zj7VfvfpkHGU3AMG9++3F1na3NbIyFu+5iHbrVvJszbP 4FYSe3o6l/OHoQpz/9TM57891vFsDQgP4F3xmOsboxv3tQOdiVJ/lViKMxINtZiLihMBiqvF cloCAAA= X-CMS-MailID: 20200923132545eucas1p10db12d91121c9afdbab338bb60c8ed37 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200923132545eucas1p10db12d91121c9afdbab338bb60c8ed37 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200923132545eucas1p10db12d91121c9afdbab338bb60c8ed37 References: <20200923014713.16932-1-l.wojciechow@partner.samsung.com> <20200923132541.21417-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v3 1/8] app/test: fix deadlock in distributor test 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" The sanity test with worker shutdown delegates all bufs to be processed by a single lcore worker, then it freezes one of the lcore workers and continues to send more bufs. Problem occurred if freezed lcore is the same as the one that is processing the mbufs. The lcore processing mbufs might be different every time test is launched. This is caused by keeping the value of wkr static variable in rte_distributor_process function between running test cases. Test freezed always lcore with 0 id. The patch changes avoids possible collision by freezing lcore with zero_idx. The lcore that receives the data updates the zero_idx, so it is not freezed itself. To reproduce the issue fixed by this patch, please run distributor_autotest command in test app several times in a row. Fixes: c3eabff124e6 ("distributor: add unit tests") Cc: bruce.richardson@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Tested-by: David Hunt --- app/test/test_distributor.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index ba1f81cf8..35b25463a 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -28,6 +28,7 @@ struct worker_params worker_params; 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 unsigned worker_idx; +static volatile unsigned zero_idx; struct worker_stats { volatile unsigned handled_packets; @@ -346,27 +347,43 @@ handle_work_for_shutdown_test(void *arg) unsigned int total = 0; unsigned int i; unsigned int returned = 0; + unsigned int zero_id = 0; const unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, buf, num); + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + if (id == zero_id && num > 0) { + zero_id = (zero_id + 1) % __atomic_load_n(&worker_idx, + __ATOMIC_ACQUIRE); + __atomic_store_n(&zero_idx, zero_id, __ATOMIC_RELEASE); + } + /* wait for quit single globally, or for worker zero, wait * for zero_quit */ - while (!quit && !(id == 0 && zero_quit)) { + while (!quit && !(id == zero_id && zero_quit)) { worker_stats[id].handled_packets += num; count += num; for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, buf, num); + + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + if (id == zero_id && num > 0) { + zero_id = (zero_id + 1) % __atomic_load_n(&worker_idx, + __ATOMIC_ACQUIRE); + __atomic_store_n(&zero_idx, zero_id, __ATOMIC_RELEASE); + } + total += num; } worker_stats[id].handled_packets += num; count += num; returned = rte_distributor_return_pkt(d, id, buf, num); - if (id == 0) { + if (id == zero_id) { /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. */ @@ -586,6 +603,7 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) rte_eal_mp_wait_lcore(); quit = 0; worker_idx = 0; + zero_idx = 0; } static int -- 2.17.1