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 CBFE5A04BC for ; Thu, 8 Oct 2020 07:24:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9CA081B694; Thu, 8 Oct 2020 07:23:54 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 6210C1B68A for ; Thu, 8 Oct 2020 07:23:42 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052341euoutp0153f0414d06231a6c5364b7f5d6430ccf~77PMS4j0_2268722687euoutp01c for ; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052341euoutp0153f0414d06231a6c5364b7f5d6430ccf~77PMS4j0_2268722687euoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134621; bh=LemR1YjnE+c23RXwEQzxMBn4x6DVQHDmQWboTCBU/MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhKFkUzZLcwTAOE3CVMhSa50njrXFEq5XmWKpE8ZWtEksMFTym1hgSIa4SBzQj6hO K27kvANSNlthAiZzo9PfFqHK+fjTp6l/IrtRigqdC9ZjOZfvxm2OvgEwFm0s3JqVBe 5hB+OvX2krz2jwyQicRBjL1S3UJk3OanHjzY1H9k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052340eucas1p1dd62d069025c86113dfb0812bed029b6~77PMEJUCH0288802888eucas1p1s; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8F.83.06456.C52AE7F5; Thu, 8 Oct 2020 06:23:40 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052340eucas1p1451f2bf1b6475067491753274547b837~77PLvLFMN1294712947eucas1p1D; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052340eusmtrp14b8dcd0170bfc4c8909776b4b7dc609d~77PLumX8u2941629416eusmtrp1R; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-40-5f7ea25c6d01 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 66.89.06314.C52AE7F5; Thu, 8 Oct 2020 06:23:40 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052339eusmtip1f5ca171f586f79d7267b7643778b89c2~77PLAe7_H2786627866eusmtip1a; Thu, 8 Oct 2020 05:23:39 +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:13 +0200 Message-Id: <20201008052323.11547-6-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+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87oxi+riDS5uMLO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroynz46y FJyVqji0fhNjA+N20S5GTg4JAROJDxPWMXYxcnEICaxglFj+bRsLhPOFUeLtgVdQzmdGiX/t j9hgWr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ViVyOjxM3zM9kmMPItYGRYxSiSWlqcm55bbKhXnJhbXJqXrpec n7uJERiK24793LyD8dLG4EOMAhyMSjy8Bkdr44VYE8uKK3MPMUpwMCuJ8DqdPR0nxJuSWFmV WpQfX1Sak1p8iNEU6KqJzFKiyfnAOMkriTc0NTS3sDQ0NzY3NrNQEuftEDgYIySQnliSmp2a WpBaBNPHxMEp1cDoWlLk7Tf5ap+5+rbu9rYl9ecjUqO+ifrxLVv+89f9ezdjXdzXdenJLLJj WG+pKfXvb5ygqYnew4+vi5/p2Fvt8f9la925P/905dPizwZ7z3z32Ddxf09weP6ZT309bU+m nO6dbfyzdcf6Y9OOTPlUttmB2brzwEqnJ83zl9Qf+qL1a4KUOlezEktxRqKhFnNRcSIAbMNZ 7lsCAAA= X-CMS-MailID: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v5 05/15] test/distributor: fix shutdown of busy 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. The freezed core shuts down first by calling rte_distributor_return_pkt(). The test intention is to verify if packets assigned to the shut down lcore will be reassigned to another worker. However the shutdown core was not always the one, that was processing packets. 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 stores the id of worker that is processing the data in zero_idx global atomic variable. This way the freezed lcore is always the proper one. 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 | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 52230d250..6cd7a2edd 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; @@ -340,26 +341,43 @@ handle_work_for_shutdown_test(void *arg) unsigned int total = 0; unsigned int i; unsigned int returned = 0; + unsigned int zero_id = 0; + unsigned int zero_unset; const unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); + if (num > 0) { + zero_unset = RTE_MAX_LCORE; + __atomic_compare_exchange_n(&zero_idx, &zero_unset, id, + false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); + } + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + /* 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, NULL, 0); + + if (num > 0) { + zero_unset = RTE_MAX_LCORE; + __atomic_compare_exchange_n(&zero_idx, &zero_unset, id, + false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); + } + zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); + 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. */ @@ -578,6 +596,7 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) rte_eal_mp_wait_lcore(); quit = 0; worker_idx = 0; + zero_idx = RTE_MAX_LCORE; } static int -- 2.17.1