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 EE99DA04C0 for ; Sat, 26 Sep 2020 00:42:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBE031E9D5; Sat, 26 Sep 2020 00:42:23 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 660EF1D16C for ; Sat, 26 Sep 2020 00:42:19 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200925224217euoutp013cfbded831065c6908b1b38ab13f659d~4KBTf6pAl2546525465euoutp01Q for ; Fri, 25 Sep 2020 22:42:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200925224217euoutp013cfbded831065c6908b1b38ab13f659d~4KBTf6pAl2546525465euoutp01Q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601073737; bh=Aad7i1ZMUc3rAZvaKTVtYAaNPC1c1LFWoHAxNKuK8lU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vPyTTtTcn3tnoyW6mAlL/aGnxIyXBEhFQ1hfncXA+4i2mREUj6qasAeQWrDTI0vkx fof8Yf7ct6m4fqxppB/7Pd+nYnzxPqnWAFSlXdmKWiEY7Kac0gSdaH4yWgORdGyLVx TrWpw4qBCynNmPCqRpalWjTCJgG5IzVkK4oAMm7k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200925224217eucas1p2f2a56e24fd5dd1c024342f628f7757f9~4KBTJadH41305613056eucas1p2P; Fri, 25 Sep 2020 22:42:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id EA.6B.06456.9427E6F5; Fri, 25 Sep 2020 23:42:17 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200925224216eucas1p1e8e1d0ecab4bbbf6e43b117c1d210649~4KBSwUReQ0081500815eucas1p1E; Fri, 25 Sep 2020 22:42:16 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200925224216eusmtrp24d0828818d05e69fedc53ba13e750225~4KBSvw-sH0483804838eusmtrp2H; Fri, 25 Sep 2020 22:42:16 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-fa-5f6e7249976f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3F.BE.06017.8427E6F5; Fri, 25 Sep 2020 23:42:16 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200925224216eusmtip27a6d7379b5758d9faf3510bbba148a81~4KBSPjpXN1081510815eusmtip2y; Fri, 25 Sep 2020 22:42:16 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 26 Sep 2020 00:42:02 +0200 Message-Id: <20200925224209.12173-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87qeRXnxBqcv8lvcWGVv0TfpI5PF u0/bmSye9axjtPjX8YfdgdXj14KlrB6L97xk8jj4bg9TAHMUl01Kak5mWWqRvl0CV8ba9fvZ C+ZLVWx5fYi1gbFJtIuRk0NCwETi17yrjF2MXBxCAisYJbZfOMMC4Xxhl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EmEJtXwFVi5oaLTBDj 5SVWbzjADGJzCrhJfNs3lxliVSOjRM+bPtYJjHwLGBlWMYqklhbnpucWG+kVJ+YWl+al6yXn 525iBAbitmM/t+xg7HoXfIhRgINRiYdX4WluvBBrYllxZe4hRgkOZiURXqezp+OEeFMSK6tS i/Lji0pzUosPMZoCXTWRWUo0OR8YJXkl8YamhuYWlobmxubGZhZK4rwdAgdjhATSE0tSs1NT C1KLYPqYODilGhjnvI1lnbRHTcfVQFfzvvCBqn2OD5Kitpy3iLsTXcbU+6Ute94jtTdNimHW CV79Gu2x+Sums6UEL29mu1/c/VT+9yPr/q7Kl46u5n9PMHzo9Gk7+XD/zovXJ7zsvifd6/XN /Jfz8U7T7dLfNB/v5ZkgZ3tPRuF1ZbXf7d3+eXfWZ59VKNbcX6vEUpyRaKjFXFScCACjB2uO WgIAAA== X-CMS-MailID: 20200925224216eucas1p1e8e1d0ecab4bbbf6e43b117c1d210649 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200925224216eucas1p1e8e1d0ecab4bbbf6e43b117c1d210649 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200925224216eucas1p1e8e1d0ecab4bbbf6e43b117c1d210649 References: <20200923132541.21417-1-l.wojciechow@partner.samsung.com> <20200925224209.12173-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v4 1/8] test/distributor: fix deadlock with freezed worker 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