From patchwork Sat Oct 10 16:04:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80277 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73D97A04B1; Sat, 10 Oct 2020 18:06:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 20A981D908; Sat, 10 Oct 2020 18:05:36 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 31FEC1D8FF for ; Sat, 10 Oct 2020 18:05:32 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160520euoutp024083f9f8966d86bfcd51047d63ce1176~8rSAf6rq-2851128511euoutp02W for ; Sat, 10 Oct 2020 16:05:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160520euoutp024083f9f8966d86bfcd51047d63ce1176~8rSAf6rq-2851128511euoutp02W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345920; bh=yH3M1Cb4L5UauMPb4vqNmQJysLFgOKEd5bHi5VjtoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1NOX6M4WGBMhFcqBoXXzpZNdu5VtXL/BvluaEvSXw1TpG+IQvR2oQsxCss21q3PF ECTN10AxHlu3kInBjez7Zkm/YtGN2XMjc3kTM2/1iko8f1+/2mwNnz73d6JwLQk5hg jTGJbvrkCD4GzOkgZLJRGPe91miUz/X5IWYHUB1U= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160515eucas1p16f8030651ba8374cfa3e557883c24a26~8rR7p3dM42439624396eucas1p1t; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 35.58.05997.BBBD18F5; Sat, 10 Oct 2020 17:05:15 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f~8rR7Sc-Jz2236022360eucas1p1y; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160515eusmtrp24ce18be0a8cf1f1d39afb7d13ba57b91~8rR7R7fcZ1692616926eusmtrp2D; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-57-5f81dbbb2278 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 19.A6.06017.BBBD18F5; Sat, 10 Oct 2020 17:05:15 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160514eusmtip145dcd21efe3dc7aada781fab8a901583~8rR6iKivg2442224422eusmtip1v; Sat, 10 Oct 2020 16:05:14 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:52 +0200 Message-Id: <20201010160508.19709-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP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+nYJehkdD84xFpwWrXjwaRNzA+N6oS5GDg4J AROJjzPiuxi5OIQEljJK9D7sY4aIy0h8uCTQxcgJZApL/LnWxQZR84FR4sPK6awgCTYBW4kj M7+ygtSLCIRJnFjpDxJmFnCX2LJ4KjOILSzgI7G//zxYOYuAqsTNJY8ZQWxeAVeJVVteMUHM l5dYveEAWD2ngJvE2a6DULsaGSVO3L7JNoGRbwEjwypGkdTS4tz03GIjveLE3OLSvHS95Pzc TYzAQNx27OeWHYxd74IPMQpwMCrx8EqcaowXYk0sK67MPcQowcGsJMLrdPZ0nBBvSmJlVWpR fnxRaU5q8SFGU6CrJjJLiSbnA6MkryTe0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2ampB ahFMHxMHp1QDY9jNxDuXeKyNtnLc5vAWisv6xv0lTPG3ccuT+/k/y039vNOuap36xN9mZzqT t0F58XmL5vwl328fE15WnMVpInhqT9UNed68x+UmCyew7Hh0bVHvVw7elKNfjwgciHLR+HbR 6UmkVaBO08tvAYLrNz+csH+rUe9pv/8HD/BGLD4d9WmyyIwyKSWW4oxEQy3mouJEABe24ERa AgAA X-CMS-MailID: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f X-Msg-Generator: CA X-RootMTR: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 01/16] distributor: fix missing handshake synchronization 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" rte_distributor_return_pkt function which is run on worker cores must wait for distributor core to clear handshake on retptr64 before using those buffers. While the handshake is set distributor core controls buffers and any operations on worker side might overwrite buffers which are unread yet. Same situation appears in the legacy single distributor. Function rte_distributor_return_pkt_single shouldn't modify the bufptr64 until handshake on it is cleared by distributor lcore. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 14 ++++++++++++++ lib/librte_distributor/rte_distributor_single.c | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 1c047f065..89493c331 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -160,6 +160,7 @@ rte_distributor_return_pkt(struct rte_distributor *d, { struct rte_distributor_buffer *buf = &d->bufs[worker_id]; unsigned int i; + volatile int64_t *retptr64; if (unlikely(d->alg_type == RTE_DIST_ALG_SINGLE)) { if (num == 1) @@ -169,6 +170,19 @@ rte_distributor_return_pkt(struct rte_distributor *d, return -EINVAL; } + retptr64 = &(buf->retptr64[0]); + /* Spin while handshake bits are set (scheduler clears it). + * Sync with worker on GET_BUF flag. + */ + while (unlikely(__atomic_load_n(retptr64, __ATOMIC_ACQUIRE) + & RTE_DISTRIB_GET_BUF)) { + rte_pause(); + uint64_t t = rte_rdtsc()+100; + + while (rte_rdtsc() < t) + rte_pause(); + } + /* Sync with distributor to acquire retptrs */ __atomic_thread_fence(__ATOMIC_ACQUIRE); for (i = 0; i < RTE_DIST_BURST_SIZE; i++) diff --git a/lib/librte_distributor/rte_distributor_single.c b/lib/librte_distributor/rte_distributor_single.c index abaf7730c..f4725b1d0 100644 --- a/lib/librte_distributor/rte_distributor_single.c +++ b/lib/librte_distributor/rte_distributor_single.c @@ -74,6 +74,10 @@ rte_distributor_return_pkt_single(struct rte_distributor_single *d, union rte_distributor_buffer_single *buf = &d->bufs[worker_id]; uint64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_RETURN_BUF; + while (unlikely(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED) + & RTE_DISTRIB_FLAGS_MASK)) + rte_pause(); + /* Sync with distributor on RETURN_BUF flag. */ __atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE); return 0; From patchwork Sat Oct 10 16:04:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80278 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BD96DA04B1; Sat, 10 Oct 2020 18:06:25 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CABD81D911; Sat, 10 Oct 2020 18:05:37 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 17B8D1D907 for ; Sat, 10 Oct 2020 18:05:34 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160522euoutp01c78bed341cd048480d70d9e385c25af1~8rSCPFIAT0101401014euoutp01p for ; Sat, 10 Oct 2020 16:05:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160522euoutp01c78bed341cd048480d70d9e385c25af1~8rSCPFIAT0101401014euoutp01p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345922; bh=vuwpOk5DYAg8nrtQAkN6Jx3ymyd0V4eE98pnCakaiTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9ia6w0YCsFVAPCYbCX9qCHEXPfz8Cvh6cA1jQQi4/VtkOT2ET1P5mLtklQqEqjc7 SEU9j+X8esYXFsQNLOrJRBbYhotr9LTYDrZGfE8Syyf5D+r7Rl3uU7jH08irEbF4K9 u9ZXb4nbxsreZa5aKCD3T04swsM0BHelaOBQ/Hjs= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160517eucas1p24fbc84b691935dacc6c41042010c114e~8rR9bI0zU1129911299eucas1p2w; Sat, 10 Oct 2020 16:05:17 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D5.58.05997.DBBD18F5; Sat, 10 Oct 2020 17:05:17 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160517eucas1p2141c0bb6097a05aa99ed8efdf5fb7512~8rR8_j_R10268502685eucas1p2s; Sat, 10 Oct 2020 16:05:17 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160517eusmtrp266af92c0cdffc3cf9044a79bb4a3be8f~8rR898gth1692616926eusmtrp2E; Sat, 10 Oct 2020 16:05:17 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-5c-5f81dbbd6a74 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B3.5A.06314.DBBD18F5; Sat, 10 Oct 2020 17:05:17 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160516eusmtip1cb0687b01d5520dc1ee11806883d87fa~8rR8NKl_G2442224422eusmtip1w; Sat, 10 Oct 2020 16:05: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, 10 Oct 2020 18:04:53 +0200 Message-Id: <20201010160508.19709-3-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7p7bzfGG+x/q2RxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBl7p8xl LDgiWHH55VHGBsZDfF2MnBwSAiYSd4/+Z+9i5OIQEljBKDG9+yobhPOFUeLJqgvMEM5nRokX VxqYYVp+PtrBCJFYzijx7ME3FgjnE6PEsuOrmECq2ARsJY7M/MoKYosIhEk0N+8FKuLgYBZw lnjylQ0kLAxU0tHwC8xmEVCVWNF3khHE5hVwlZh95A/UMnmJ1RsOgNmcAm4SZ7sOgp0nIXCd TeL2w7ssEEUuEofuTGWFsIUlXh3fwg5hy0j83zmfCaJhG6PE1d8/GSGc/YwS13tXQFVZSxz+ 95sN4jpNifW79EFMCQFHiVvz/SBMPokbbwVBipmBzEnbpjNDhHklOtqEIGboSTztmcoIs/XP 2idQl3lIbDh/jQkSPFcZJRbtvsw2gVF+FsKuBYyMqxjFU0uLc9NTi43yUsv1ihNzi0vz0vWS 83M3MQKj//S/4192MO76k3SIUYCDUYmHV+JUY7wQa2JZcWXuIUYJDmYlEV6ns6fjhHhTEiur Uovy44tKc1KLDzFKc7AoifMaL3oZKySQnliSmp2aWpBaBJNl4uCUamAs4lj3/8oZ3vuxF1aU yiiun24TtStjm2H06R7xmqszzHabX5hgI8c27U5fcVqhv9/2W66+Qn0z/+4NX/PN89Tyx292 LEmZ2PDTMN5vu1++3tyPwr9V1hu+PRQ8Qz+kJjVVuSY0OjYqQNNzSe32PxWWG8I0Aj6bnW9f sNFt5eplztPaEyrVXx9UYinOSDTUYi4qTgQAx48Ui/oCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBLMWRmVeSWpSXmKPExsVy+t/xu7p7bzfGG/yczmJxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRejZF+aUlqQoZ+cUltkrRhhZG eoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF+nYJehl7p8xlLDgiWHH55VHGBsZDfF2MnBwS AiYSPx/tYOxi5OIQEljKKPH060umLkYOoISMxIdLAhA1whJ/rnWxQdR8YJTYtPoMO0iCTcBW 4sjMr6wg9SICYRInVvqDhJkF3CW2LJ7KDGILA5V0NPxiA7FZBFQlVvSdZASxeQVcJWYf+cMM MV9eYvWGA2A2p4CbxNmug1C7GhklTty+yTaBkW8BI8MqRpHU0uLc9NxiQ73ixNzi0rx0veT8 3E2MwFDcduzn5h2MlzYGH2IU4GBU4uGVONUYL8SaWFZcmXuIUYKDWUmE1+ns6Tgh3pTEyqrU ovz4otKc1OJDjKZAV01klhJNzgfGSV5JvKGpobmFpaG5sbmxmYWSOG+HwMEYIYH0xJLU7NTU gtQimD4mDk6pBsb0qq6KDQv7214ctvmS3xDWUJiZVCPmKuR9SbvQ/o/t/6m/ZS5NF+Z4fHuS d+AZC1vdC2Ixfj4LrRJuB06ttZDrada5zqao//tJ+NcvChwpr+4uDl8tzDPloeihyy+2G670 fPd4xyaRx9VmFvpi/knzFy5btcbhBp+b+iKpXcFbEs/PVlWeJaPEUpyRaKjFXFScCACugGUP WwIAAA== X-CMS-MailID: 20201010160517eucas1p2141c0bb6097a05aa99ed8efdf5fb7512 X-Msg-Generator: CA X-RootMTR: 20201010160517eucas1p2141c0bb6097a05aa99ed8efdf5fb7512 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160517eucas1p2141c0bb6097a05aa99ed8efdf5fb7512 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 02/16] distributor: fix handshake deadlock 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" Synchronization of data exchange between distributor and worker cores is based on 2 handshakes: retptr64 for returning mbufs from workers to distributor and bufptr64 for passing mbufs to workers. Without proper order of verifying those 2 handshakes a deadlock may occur. This can happen when worker core wants to return back mbufs and waits for retptr handshake to be cleared while distributor core waits for bufptr to send mbufs to worker. This can happen as worker core first returns mbufs to distributor and later gets new mbufs, while distributor first releases mbufs to worker and later handle returning packets. This patch fixes possibility of the deadlock by always taking care of returning packets first on the distributor side and handling packets while waiting to release new. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 89493c331..12b3db33c 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -321,12 +321,14 @@ release(struct rte_distributor *d, unsigned int wkr) struct rte_distributor_buffer *buf = &(d->bufs[wkr]); unsigned int i; + handle_returns(d, wkr); + /* Sync with worker on GET_BUF flag */ while (!(__atomic_load_n(&(d->bufs[wkr].bufptr64[0]), __ATOMIC_ACQUIRE) - & RTE_DISTRIB_GET_BUF)) + & RTE_DISTRIB_GET_BUF)) { + handle_returns(d, wkr); rte_pause(); - - handle_returns(d, wkr); + } buf->count = 0; @@ -376,6 +378,7 @@ rte_distributor_process(struct rte_distributor *d, /* Flush out all non-full cache-lines to workers. */ for (wid = 0 ; wid < d->num_workers; wid++) { /* Sync with worker on GET_BUF flag. */ + handle_returns(d, wid); if (__atomic_load_n(&(d->bufs[wid].bufptr64[0]), __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF) { release(d, wid); From patchwork Sat Oct 10 16:04:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80279 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3D18EA04B1; Sat, 10 Oct 2020 18:06:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 940A41D91C; Sat, 10 Oct 2020 18:05:42 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 7E0551D904 for ; Sat, 10 Oct 2020 18:05:40 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160530euoutp02c58cbbb4a2b62b6f7bd91d5acd128c5d~8rSJRWj1L2851128511euoutp02X for ; Sat, 10 Oct 2020 16:05:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160530euoutp02c58cbbb4a2b62b6f7bd91d5acd128c5d~8rSJRWj1L2851128511euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345930; bh=NXpLZiftAddfs3hsi2CLAhUURHCIw4Q+iTczB/vGCL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3E0yUFNBGlCCPv2WWPtptbhy+Hr1Fv2Xk9NbgjiR7ozw6bhI+yr/bhFNu64w+CGv LNdnTyMSqUk60pOdK2vXbHTYT5gns5Nilx5aJ3ImqCnY1leH9+kKnwFkZ6ji2B3/FC ZoKxiOFyp/JsT1HSI5azSJGpYVDibtw7Uzrexi2o= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160524eucas1p11de25cb48960dda28ee84cb1e9242808~8rSDqiPtv2437224372eucas1p1r; Sat, 10 Oct 2020 16:05:24 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 76.58.05997.4CBD18F5; Sat, 10 Oct 2020 17:05:24 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160523eucas1p19287c5bf3b7e2818c730ae23f514853f~8rSCjaH3v2245522455eucas1p1w; Sat, 10 Oct 2020 16:05:23 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160523eusmtrp1c6326f9577c4fff3e03567fd2c37afff~8rSCi57lf2920229202eusmtrp1s; Sat, 10 Oct 2020 16:05:23 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-65-5f81dbc44b8c Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 79.A6.06017.2CBD18F5; Sat, 10 Oct 2020 17:05:23 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160518eusmtip12c2d05d73653f15cd55f216ce91c597e~8rR95mBMz2442224422eusmtip1x; Sat, 10 Oct 2020 16:05:18 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:54 +0200 Message-Id: <20201010160508.19709-4-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+Ng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5TUnMyy1CJ9uwS9jB1rgwseqFR8+rCQsYHxnGwXIyeHhICJ xJ5/qxm7GLk4hASWMkqcPHSYtYuRAyghI/HhkgBEjbDEn2tdbBA1Hxgl/p78zQ6SYBOwlTgy 8ytYvYhAmMSJlf4gYWYBd4kti6cyg9jCAh4SR5svM4HYLAKqElc7/jKClPMKuErcPiwJMV5e YvWGA2DlnAJuEme7DkKtamSUOHH7JtsERr4FjAyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcx AoNw27GfW3Ywdr0LPsQowMGoxMMrcaoxXog1say4MvcQowQHs5IIr9PZ03FCvCmJlVWpRfnx RaU5qcWHGE2BjprILCWanA+MkLySeENTQ3MLS0NzY3NjMwslcd4OgYMxQgLpiSWp2ampBalF MH1MHJxSDYwtRkqq23xnbpVkdPjz+oM/h+6/X6IfpzCFJZ0PqtI4eudGdzUbx55JE9NOce+7 pJn2est7FWb+VxInQ/yLIs/9y/2mWPab6+WvlDUzIv91ljC2Sa7nO3LvmvSK+Y+WvTtaPfFN 1bxOL9mGigLLI3ncilV+u8JXy7z9Ylv1rNMpYtszVp2/1h+UWIozEg21mIuKEwFdZJmQWAIA AA== X-CMS-MailID: 20201010160523eucas1p19287c5bf3b7e2818c730ae23f514853f X-Msg-Generator: CA X-RootMTR: 20201010160523eucas1p19287c5bf3b7e2818c730ae23f514853f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160523eucas1p19287c5bf3b7e2818c730ae23f514853f References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 03/16] distributor: do not use oldpkt when not needed 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" rte_distributor_request_pkt and rte_distributor_get_pkt dereferenced oldpkt parameter when in RTE_DIST_ALG_SINGLE even if number of returned buffers from worker to distributor was 0. This patch passes NULL to the legacy API when number of returned buffers is 0. This allows passing NULL as oldpkt parameter. Distributor tests are also updated passing NULL as oldpkt and 0 as number of returned packets, where packets are not returned. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 28 +++++++++--------------- lib/librte_distributor/rte_distributor.c | 4 ++-- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index ba1f81cf8..52230d250 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -62,13 +62,10 @@ handle_work(void *arg) struct rte_mbuf *buf[8] __rte_cache_aligned; struct worker_params *wp = arg; struct rte_distributor *db = wp->dist; - unsigned int count = 0, num = 0; + unsigned int count = 0, num; unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); - int i; - for (i = 0; i < 8; i++) - buf[i] = NULL; - num = rte_distributor_get_pkt(db, id, buf, buf, num); + num = rte_distributor_get_pkt(db, id, buf, NULL, 0); while (!quit) { __atomic_fetch_add(&worker_stats[id].handled_packets, num, __ATOMIC_RELAXED); @@ -272,19 +269,16 @@ handle_work_with_free_mbufs(void *arg) struct rte_distributor *d = wp->dist; unsigned int count = 0; unsigned int i; - unsigned int num = 0; + unsigned int num; unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); - for (i = 0; i < 8; i++) - buf[i] = NULL; - num = rte_distributor_get_pkt(d, id, buf, buf, num); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!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); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } worker_stats[id].handled_packets += num; count += num; @@ -342,14 +336,14 @@ handle_work_for_shutdown_test(void *arg) struct worker_params *wp = arg; struct rte_distributor *d = wp->dist; unsigned int count = 0; - unsigned int num = 0; + unsigned int num; unsigned int total = 0; unsigned int i; unsigned int returned = 0; const unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); - num = rte_distributor_get_pkt(d, id, buf, buf, num); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); /* wait for quit single globally, or for worker zero, wait * for zero_quit */ @@ -358,8 +352,7 @@ handle_work_for_shutdown_test(void *arg) count += num; for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); - num = rte_distributor_get_pkt(d, - id, buf, buf, num); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); total += num; } worker_stats[id].handled_packets += num; @@ -373,14 +366,13 @@ handle_work_for_shutdown_test(void *arg) while (zero_quit) usleep(100); - num = rte_distributor_get_pkt(d, - id, buf, buf, num); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!quit) { worker_stats[id].handled_packets += num; count += num; rte_pktmbuf_free(pkt); - num = rte_distributor_get_pkt(d, id, buf, buf, num); + num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } returned = rte_distributor_return_pkt(d, id, buf, num); diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 12b3db33c..b720abe03 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -42,7 +42,7 @@ rte_distributor_request_pkt(struct rte_distributor *d, if (unlikely(d->alg_type == RTE_DIST_ALG_SINGLE)) { rte_distributor_request_pkt_single(d->d_single, - worker_id, oldpkt[0]); + worker_id, count ? oldpkt[0] : NULL); return; } @@ -134,7 +134,7 @@ rte_distributor_get_pkt(struct rte_distributor *d, if (unlikely(d->alg_type == RTE_DIST_ALG_SINGLE)) { if (return_count <= 1) { pkts[0] = rte_distributor_get_pkt_single(d->d_single, - worker_id, oldpkt[0]); + worker_id, return_count ? oldpkt[0] : NULL); return (pkts[0]) ? 1 : 0; } else return -EINVAL; From patchwork Sat Oct 10 16:04:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80280 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83FFAA04B1; Sat, 10 Oct 2020 18:07:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E49D1D921; Sat, 10 Oct 2020 18:05:45 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D599B1D922 for ; Sat, 10 Oct 2020 18:05:42 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160532euoutp02c9ad25de2dbcb19a63cdd0e8ea78f7e9~8rSLdbFpx2851128511euoutp02Y for ; Sat, 10 Oct 2020 16:05:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160532euoutp02c9ad25de2dbcb19a63cdd0e8ea78f7e9~8rSLdbFpx2851128511euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345932; bh=AqUBlf8gPTXwJQZGL7gAA/vvwSQFfIKWCLO6QqixeJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hpbVie7E6x8naI4E9L7mW+N64XPF6ATnRwEYGQiGqJqaGtAxS901ymuXLI2fNfvAI oXQ13g32AZlo2a34iaWEL4mFeaCK0QbyW06k3ePQIpLgLaqlKqv9HntcaviGEEVn+4 pxvMxsRozeYcj6zSlPiIMIodWBo1G/Td6qolweP4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160526eucas1p194aaecc2b432130cfb1389b54d40f2fd~8rSF0FFJx2308623086eucas1p1s; Sat, 10 Oct 2020 16:05:26 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 77.B2.06318.6CBD18F5; Sat, 10 Oct 2020 17:05:26 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160525eucas1p2314810086b9dd1c8cddf90eabe800363~8rSEv3gzk2506025060eucas1p2C; Sat, 10 Oct 2020 16:05:25 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160525eusmtrp1e304425242021b964b23230dc9c6a31e~8rSEvUqs32920229202eusmtrp1u; Sat, 10 Oct 2020 16:05:25 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-bb-5f81dbc65162 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D9.A6.06017.5CBD18F5; Sat, 10 Oct 2020 17:05:25 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160524eusmtip11452dfb0b47f29c1721b632531e7f9fa~8rSD8yTtQ2442224422eusmtip1y; Sat, 10 Oct 2020 16:05:24 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:55 +0200 Message-Id: <20201010160508.19709-5-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgF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qTmZZalF+nYJehnX16cXnMivuPr9KFsD482ILkZODgkB E4mlS+YydzFycQgJLGWUWPDyC3sXIwdQQkbiwyUBiBphiT/XuthAbCGBD4wS+w5UgthsArYS R2Z+ZQUpFxEIkzix0h8kzCzgLrFl8VRmEFtYwFvi3bUrjCA2i4CqxM4Nr9hBbF4BV4mjVy+z QIyXl1i94QBYPaeAm8TZroNsEOc0MkqcuH2TbQIj3wJGhlWMIqmlxbnpucVGesWJucWleel6 yfm5mxiBYbjt2M8tOxi73gUfYhTgYFTi4ZU41RgvxJpYVlyZe4hRgoNZSYTX6ezpOCHelMTK qtSi/Pii0pzU4kOMpkBXTWSWEk3OB8ZIXkm8oamhuYWlobmxubGZhZI4b4fAwRghgfTEktTs 1NSC1CKYPiYOTqkGxjPRP8ymagS9YJVTOs+2xvJplBLDuci9Sf5znpW0aWSoNW9N2v/m9iEu n8y5BXnr+XQ5vRn3T9f/svOjakvN62Nn5ZPZOkXLGF9/2ex+syd9d2Tg4pLdvZldnwSjXp2U tSrPn3fP19TfalnR4/xSu5bS63ONqyJry1mVOBqe20zPOrbxRtofJZbijERDLeai4kQAOsvU f1kCAAA= X-CMS-MailID: 20201010160525eucas1p2314810086b9dd1c8cddf90eabe800363 X-Msg-Generator: CA X-RootMTR: 20201010160525eucas1p2314810086b9dd1c8cddf90eabe800363 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160525eucas1p2314810086b9dd1c8cddf90eabe800363 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 04/16] distributor: handle worker shutdown in burst mode 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" The burst version of distributor implementation was missing proper handling of worker shutdown. A worker processing packets received from distributor can call rte_distributor_return_pkt() function informing distributor that it want no more packets. Further calls to rte_distributor_request_pkt() or rte_distributor_get_pkt() however should inform distributor that new packets are requested again. Lack of the proper implementation has caused that even after worker informed about returning last packets, new packets were still sent from distributor causing deadlocks as no one could get them on worker side. This patch adds handling shutdown of the worker in following way: 1) It fixes usage of RTE_DISTRIB_VALID_BUF handshake flag. This flag was formerly unused in burst implementation and now it is used for marking valid packets in retptr64 replacing invalid use of RTE_DISTRIB_RETURN_BUF flag. 2) Uses RTE_DISTRIB_RETURN_BUF as a worker to distributor handshake in retptr64 to indicate that worker has shutdown. 3) Worker that shuts down blocks also bufptr for itself with RTE_DISTRIB_RETURN_BUF flag allowing distributor to retrieve any in flight packets. 4) When distributor receives information about shutdown of a worker, it: marks worker as not active; retrieves any in flight and backlog packets and process them to different workers; unlocks bufptr64 by clearing RTE_DISTRIB_RETURN_BUF flag and allowing use in the future if worker requests any new packages. 5) Do not allow to: send or add to backlog any packets for not active workers. Such workers are also ignored if matched. 6) Adjust calls to handle_returns() and tags matching procedure to react for possible activation deactivation of workers. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/distributor_private.h | 3 + lib/librte_distributor/rte_distributor.c | 175 +++++++++++++++---- 2 files changed, 146 insertions(+), 32 deletions(-) diff --git a/lib/librte_distributor/distributor_private.h b/lib/librte_distributor/distributor_private.h index 489aef2ac..689fe3e18 100644 --- a/lib/librte_distributor/distributor_private.h +++ b/lib/librte_distributor/distributor_private.h @@ -155,6 +155,9 @@ struct rte_distributor { enum rte_distributor_match_function dist_match_fn; struct rte_distributor_single *d_single; + + uint8_t active[RTE_DISTRIB_MAX_WORKERS]; + uint8_t activesum; }; void diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index b720abe03..115443fc0 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -51,7 +51,7 @@ rte_distributor_request_pkt(struct rte_distributor *d, * Sync with worker on GET_BUF flag. */ while (unlikely(__atomic_load_n(retptr64, __ATOMIC_ACQUIRE) - & RTE_DISTRIB_GET_BUF)) { + & (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF))) { rte_pause(); uint64_t t = rte_rdtsc()+100; @@ -67,11 +67,11 @@ rte_distributor_request_pkt(struct rte_distributor *d, for (i = count; i < RTE_DIST_BURST_SIZE; i++) buf->retptr64[i] = 0; - /* Set Return bit for each packet returned */ + /* Set VALID_BUF bit for each packet returned */ for (i = count; i-- > 0; ) buf->retptr64[i] = (((int64_t)(uintptr_t)(oldpkt[i])) << - RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_RETURN_BUF; + RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_VALID_BUF; /* * Finally, set the GET_BUF to signal to distributor that cache @@ -97,11 +97,13 @@ rte_distributor_poll_pkt(struct rte_distributor *d, return (pkts[0]) ? 1 : 0; } - /* If bit is set, return + /* If any of below bits is set, return. + * GET_BUF is set when distributor hasn't sent any packets yet + * RETURN_BUF is set when distributor must retrieve in-flight packets * Sync with distributor to acquire bufptrs */ if (__atomic_load_n(&(buf->bufptr64[0]), __ATOMIC_ACQUIRE) - & RTE_DISTRIB_GET_BUF) + & (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF)) return -1; /* since bufptr64 is signed, this should be an arithmetic shift */ @@ -113,7 +115,7 @@ rte_distributor_poll_pkt(struct rte_distributor *d, } /* - * so now we've got the contents of the cacheline into an array of + * so now we've got the contents of the cacheline into an array of * mbuf pointers, so toggle the bit so scheduler can start working * on the next cacheline while we're working. * Sync with distributor on GET_BUF flag. Release bufptrs. @@ -175,7 +177,7 @@ rte_distributor_return_pkt(struct rte_distributor *d, * Sync with worker on GET_BUF flag. */ while (unlikely(__atomic_load_n(retptr64, __ATOMIC_ACQUIRE) - & RTE_DISTRIB_GET_BUF)) { + & (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF))) { rte_pause(); uint64_t t = rte_rdtsc()+100; @@ -187,17 +189,25 @@ rte_distributor_return_pkt(struct rte_distributor *d, __atomic_thread_fence(__ATOMIC_ACQUIRE); for (i = 0; i < RTE_DIST_BURST_SIZE; i++) /* Switch off the return bit first */ - buf->retptr64[i] &= ~RTE_DISTRIB_RETURN_BUF; + buf->retptr64[i] = 0; for (i = num; i-- > 0; ) buf->retptr64[i] = (((int64_t)(uintptr_t)oldpkt[i]) << - RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_RETURN_BUF; + RTE_DISTRIB_FLAG_BITS) | RTE_DISTRIB_VALID_BUF; + + /* Use RETURN_BUF on bufptr64 to notify distributor that + * we won't read any mbufs from there even if GET_BUF is set. + * This allows distributor to retrieve in-flight already sent packets. + */ + __atomic_or_fetch(&(buf->bufptr64[0]), RTE_DISTRIB_RETURN_BUF, + __ATOMIC_ACQ_REL); - /* set the GET_BUF but even if we got no returns. - * Sync with distributor on GET_BUF flag. Release retptrs. + /* set the RETURN_BUF on retptr64 even if we got no returns. + * Sync with distributor on RETURN_BUF flag. Release retptrs. + * Notify distributor that we don't request more packets any more. */ __atomic_store_n(&(buf->retptr64[0]), - buf->retptr64[0] | RTE_DISTRIB_GET_BUF, __ATOMIC_RELEASE); + buf->retptr64[0] | RTE_DISTRIB_RETURN_BUF, __ATOMIC_RELEASE); return 0; } @@ -267,6 +277,59 @@ find_match_scalar(struct rte_distributor *d, */ } +/* + * When worker called rte_distributor_return_pkt() + * and passed RTE_DISTRIB_RETURN_BUF handshake through retptr64, + * distributor must retrieve both inflight and backlog packets assigned + * to the worker and reprocess them to another worker. + */ +static void +handle_worker_shutdown(struct rte_distributor *d, unsigned int wkr) +{ + struct rte_distributor_buffer *buf = &(d->bufs[wkr]); + /* double BURST size for storing both inflights and backlog */ + struct rte_mbuf *pkts[RTE_DIST_BURST_SIZE * 2]; + unsigned int pkts_count = 0; + unsigned int i; + + /* If GET_BUF is cleared there are in-flight packets sent + * to worker which does not require new packets. + * They must be retrieved and assigned to another worker. + */ + if (!(__atomic_load_n(&(buf->bufptr64[0]), __ATOMIC_ACQUIRE) + & RTE_DISTRIB_GET_BUF)) + for (i = 0; i < RTE_DIST_BURST_SIZE; i++) + if (buf->bufptr64[i] & RTE_DISTRIB_VALID_BUF) + pkts[pkts_count++] = (void *)((uintptr_t) + (buf->bufptr64[i] + >> RTE_DISTRIB_FLAG_BITS)); + + /* Make following operations on handshake flags on bufptr64: + * - set GET_BUF to indicate that distributor can overwrite buffer + * with new packets if worker will make a new request. + * - clear RETURN_BUF to unlock reads on worker side. + */ + __atomic_store_n(&(buf->bufptr64[0]), RTE_DISTRIB_GET_BUF, + __ATOMIC_RELEASE); + + /* Collect backlog packets from worker */ + for (i = 0; i < d->backlog[wkr].count; i++) + pkts[pkts_count++] = (void *)((uintptr_t) + (d->backlog[wkr].pkts[i] >> RTE_DISTRIB_FLAG_BITS)); + + d->backlog[wkr].count = 0; + + /* Clear both inflight and backlog tags */ + for (i = 0; i < RTE_DIST_BURST_SIZE; i++) { + d->in_flight_tags[wkr][i] = 0; + d->backlog[wkr].tags[i] = 0; + } + + /* Recursive call */ + if (pkts_count > 0) + rte_distributor_process(d, pkts, pkts_count); +} + /* * When the handshake bits indicate that there are packets coming @@ -285,19 +348,33 @@ handle_returns(struct rte_distributor *d, unsigned int wkr) /* Sync on GET_BUF flag. Acquire retptrs. */ if (__atomic_load_n(&(buf->retptr64[0]), __ATOMIC_ACQUIRE) - & RTE_DISTRIB_GET_BUF) { + & (RTE_DISTRIB_GET_BUF | RTE_DISTRIB_RETURN_BUF)) { for (i = 0; i < RTE_DIST_BURST_SIZE; i++) { - if (buf->retptr64[i] & RTE_DISTRIB_RETURN_BUF) { + if (buf->retptr64[i] & RTE_DISTRIB_VALID_BUF) { oldbuf = ((uintptr_t)(buf->retptr64[i] >> RTE_DISTRIB_FLAG_BITS)); /* store returns in a circular buffer */ store_return(oldbuf, d, &ret_start, &ret_count); count++; - buf->retptr64[i] &= ~RTE_DISTRIB_RETURN_BUF; + buf->retptr64[i] &= ~RTE_DISTRIB_VALID_BUF; } } d->returns.start = ret_start; d->returns.count = ret_count; + + /* If worker requested packets with GET_BUF, set it to active + * otherwise (RETURN_BUF), set it to not active. + */ + d->activesum -= d->active[wkr]; + d->active[wkr] = !!(buf->retptr64[0] & RTE_DISTRIB_GET_BUF); + d->activesum += d->active[wkr]; + + /* If worker returned packets without requesting new ones, + * handle all in-flights and backlog packets assigned to it. + */ + if (unlikely(buf->retptr64[0] & RTE_DISTRIB_RETURN_BUF)) + handle_worker_shutdown(d, wkr); + /* Clear for the worker to populate with more returns. * Sync with distributor on GET_BUF flag. Release retptrs. */ @@ -322,11 +399,15 @@ release(struct rte_distributor *d, unsigned int wkr) unsigned int i; handle_returns(d, wkr); + if (unlikely(!d->active[wkr])) + return 0; /* Sync with worker on GET_BUF flag */ while (!(__atomic_load_n(&(d->bufs[wkr].bufptr64[0]), __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF)) { handle_returns(d, wkr); + if (unlikely(!d->active[wkr])) + return 0; rte_pause(); } @@ -366,7 +447,7 @@ rte_distributor_process(struct rte_distributor *d, int64_t next_value = 0; uint16_t new_tag = 0; uint16_t flows[RTE_DIST_BURST_SIZE] __rte_cache_aligned; - unsigned int i, j, w, wid; + unsigned int i, j, w, wid, matching_required; if (d->alg_type == RTE_DIST_ALG_SINGLE) { /* Call the old API */ @@ -374,11 +455,13 @@ rte_distributor_process(struct rte_distributor *d, mbufs, num_mbufs); } + for (wid = 0 ; wid < d->num_workers; wid++) + handle_returns(d, wid); + if (unlikely(num_mbufs == 0)) { /* Flush out all non-full cache-lines to workers. */ for (wid = 0 ; wid < d->num_workers; wid++) { /* Sync with worker on GET_BUF flag. */ - handle_returns(d, wid); if (__atomic_load_n(&(d->bufs[wid].bufptr64[0]), __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF) { release(d, wid); @@ -388,6 +471,9 @@ rte_distributor_process(struct rte_distributor *d, return 0; } + if (unlikely(!d->activesum)) + return 0; + while (next_idx < num_mbufs) { uint16_t matches[RTE_DIST_BURST_SIZE]; unsigned int pkts; @@ -412,22 +498,30 @@ rte_distributor_process(struct rte_distributor *d, for (; i < RTE_DIST_BURST_SIZE; i++) flows[i] = 0; - switch (d->dist_match_fn) { - case RTE_DIST_MATCH_VECTOR: - find_match_vec(d, &flows[0], &matches[0]); - break; - default: - find_match_scalar(d, &flows[0], &matches[0]); - } + matching_required = 1; + for (j = 0; j < pkts; j++) { + if (unlikely(!d->activesum)) + return next_idx; + + if (unlikely(matching_required)) { + switch (d->dist_match_fn) { + case RTE_DIST_MATCH_VECTOR: + find_match_vec(d, &flows[0], + &matches[0]); + break; + default: + find_match_scalar(d, &flows[0], + &matches[0]); + } + matching_required = 0; + } /* * Matches array now contain the intended worker ID (+1) of * the incoming packets. Any zeroes need to be assigned * workers. */ - for (j = 0; j < pkts; j++) { - next_mb = mbufs[next_idx++]; next_value = (((int64_t)(uintptr_t)next_mb) << RTE_DISTRIB_FLAG_BITS); @@ -447,12 +541,18 @@ rte_distributor_process(struct rte_distributor *d, */ /* matches[j] = 0; */ - if (matches[j]) { + if (matches[j] && d->active[matches[j]-1]) { struct rte_distributor_backlog *bl = &d->backlog[matches[j]-1]; if (unlikely(bl->count == RTE_DIST_BURST_SIZE)) { release(d, matches[j]-1); + if (!d->active[matches[j]-1]) { + j--; + next_idx--; + matching_required = 1; + continue; + } } /* Add to worker that already has flow */ @@ -462,11 +562,21 @@ rte_distributor_process(struct rte_distributor *d, bl->pkts[idx] = next_value; } else { - struct rte_distributor_backlog *bl = - &d->backlog[wkr]; + struct rte_distributor_backlog *bl; + + while (unlikely(!d->active[wkr])) + wkr = (wkr + 1) % d->num_workers; + bl = &d->backlog[wkr]; + if (unlikely(bl->count == RTE_DIST_BURST_SIZE)) { release(d, wkr); + if (!d->active[wkr]) { + j--; + next_idx--; + matching_required = 1; + continue; + } } /* Add to current worker worker */ @@ -485,9 +595,7 @@ rte_distributor_process(struct rte_distributor *d, matches[w] = wkr+1; } } - wkr++; - if (wkr >= d->num_workers) - wkr = 0; + wkr = (wkr + 1) % d->num_workers; } /* Flush out all non-full cache-lines to workers. */ @@ -663,6 +771,9 @@ rte_distributor_create(const char *name, for (i = 0 ; i < num_workers ; i++) d->backlog[i].tags = &d->in_flight_tags[i][RTE_DIST_BURST_SIZE]; + memset(d->active, 0, sizeof(d->active)); + d->activesum = 0; + dist_burst_list = RTE_TAILQ_CAST(rte_dist_burst_tailq.head, rte_dist_burst_list); From patchwork Sat Oct 10 16:04:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80281 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 38DD2A04B1; Sat, 10 Oct 2020 18:07:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AA4D21D927; Sat, 10 Oct 2020 18:05:46 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D33601D921 for ; Sat, 10 Oct 2020 18:05:42 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160532euoutp02515c29b9ed173ef60d88a2c9588e38d1~8rSLdotYh2850728507euoutp02a for ; Sat, 10 Oct 2020 16:05:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160532euoutp02515c29b9ed173ef60d88a2c9588e38d1~8rSLdotYh2850728507euoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345932; bh=LemR1YjnE+c23RXwEQzxMBn4x6DVQHDmQWboTCBU/MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tO/HaCrMQIuMloPaWnpJgqDngHnbt3Pp0ZH8l6nhmwfBcrrnRmcDkrGJpGAe9r21C 4TG+1e5wM55IDlHM/7U4l2vhiavtb4IQ7DvVxoz91O7Uwd8oyA62j3gLe7wmuREUFU uZYnEVqs3lsafyayxE42N+OJumC5mSqu5GyzNbkE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160527eucas1p2f9e48b635abf1537e9ed0ca181f23bc6~8rSGdTjFp1925919259eucas1p2k; Sat, 10 Oct 2020 16:05:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id D6.58.05997.7CBD18F5; Sat, 10 Oct 2020 17:05:27 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160527eucas1p2f55cb0fc45bf3647234cdfa251e542fc~8rSGMsFuj0179501795eucas1p2s; Sat, 10 Oct 2020 16:05:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160527eusmtrp1832ee305a2cd8ca583181821339d4de0~8rSGMFNMA2920229202eusmtrp1v; Sat, 10 Oct 2020 16:05:27 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-69-5f81dbc7372e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 94.5A.06314.6CBD18F5; Sat, 10 Oct 2020 17:05:27 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160526eusmtip1f1743b61930a421b73c47ec3a9abbc3f~8rSFiTXqR2442224422eusmtip1z; Sat, 10 Oct 2020 16:05:26 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:56 +0200 Message-Id: <20201010160508.19709-6-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djP87rHbzfGG6w7L2BxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBlPnx1l KTgrVXFo/SbGBsbtol2MHBwSAiYSbZ8Suxi5OIQEVjBK3O79zQjhfGGUeL71FxOE85lRom3+ ReYuRk6wjiMHf0FVLWeUWN7/gQUkISTwiVFi5Rw9EJtNwFbiyMyvrCC2iECYRHPzXhaQdcwC zhJPvrKBhIUF3CVe/psB1soioCrRtKKZEcTmFXCV+P1rChPELnmJ1RsOgO3lFHCTONt1kA1k r4TAZTaJ34uvMUK84CKxoVkCol5Y4tXxLewQtozE6ck9LBD12xglrv7+yQjh7GeUuN67AqrK WuLwv99sEMdpSqzfpQ8RdpTobrwMNZ9P4sZbQZAwM5A5adt0Zogwr0RHmxBEtZ7E056pjDBr /6x9wgJhe0j82nWMDRI6VxklJuxym8AoPwth1wJGxlWM4qmlxbnpqcVGeanlesWJucWleel6 yfm5mxiBcX/63/EvOxh3/Uk6xCjAwajEwytxqjFeiDWxrLgy9xCjBAezkgiv09nTcUK8KYmV ValF+fFFpTmpxYcYpTlYlMR5jRe9jBUSSE8sSc1OTS1ILYLJMnFwSjUwrn3/QLOF3Wmh4M8Z YheeKj6Iqs97eEjnRdjm0ArDBkepINF3l1PO7g/VuxVcfMJLNU7m+sd75wz05hwRDcgu/tw/ ZY7an9XR6ROCjNKeNRlf2fL1hjdrdZHLJw3tfouEhxYfb0WcNds3U/+16wJx19VV3/Wdprjm s7A//rWg0dQz+s0bb3c+JZbijERDLeai4kQApw40rvcCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsVy+t/xu7rHbzfGG7wNsrixyt6ib9JHJot3 n7YzWTzrWcdo8a/jD7sDq8evBUtZPRbvecnkcfDdHqYA5ig9m6L80pJUhYz84hJbpWhDCyM9 Q0sLPSMTSz1DY/NYKyNTJX07m5TUnMyy1CJ9uwS9jKfPjrIUnJWqOLR+E2MD43bRLkZODgkB E4kjB38xdjFycQgJLGWU+HFkC1sXIwdQQkbiwyUBiBphiT/Xutggaj4wSkz5c4wRJMEmYCtx ZOZXVpB6EYEwiRMr/UHCzALuElsWT2UGsYWB7Jf/ZrCA2CwCqhJNK5rBWnkFXCV+/5rCBDFf XmL1hgNg9ZwCbhJnuw5C7WpklDhx+ybbBEa+BYwMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3 MQIDcduxn5t3MF7aGHyIUYCDUYmHV+JUY7wQa2JZcWXuIUYJDmYlEV6ns6fjhHhTEiurUovy 44tKc1KLDzGaAl01kVlKNDkfGCV5JfGGpobmFpaG5sbmxmYWSuK8HQIHY4QE0hNLUrNTUwtS i2D6mDg4pRoY21ZvNBU7w5zfqemb6sj2YlJioM9KyfW+p++9151x7nNs/eEJF53mLp/4JZi7 zNOFrXCrleyH/62GTNpRPRr8F+56Gtd9Osi2uWLTBeme9EfHjPsf7y2KK0mxmsR1w/5f8Ykm ht/cJ03uqX46Ucr35/6LyMnJZyep+YvJmDeXshwQiplluVJciaU4I9FQi7moOBEA4MhIU1oC AAA= X-CMS-MailID: 20201010160527eucas1p2f55cb0fc45bf3647234cdfa251e542fc X-Msg-Generator: CA X-RootMTR: 20201010160527eucas1p2f55cb0fc45bf3647234cdfa251e542fc X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160527eucas1p2f55cb0fc45bf3647234cdfa251e542fc References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 05/16] test/distributor: fix shutdown of busy worker 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" 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 From patchwork Sat Oct 10 16:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80282 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 88F13A04B1; Sat, 10 Oct 2020 18:08:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C30561D93C; Sat, 10 Oct 2020 18:05:50 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 083A31D931 for ; Sat, 10 Oct 2020 18:05:49 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160537euoutp01a923e890c7727364a50740fa06385cca~8rSQNLFDr0381003810euoutp01d for ; Sat, 10 Oct 2020 16:05:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160537euoutp01a923e890c7727364a50740fa06385cca~8rSQNLFDr0381003810euoutp01d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345937; bh=Ac7zUxbaUtkPUHeaPly+rcwUzr6TKwAmXEJAVMzD+lE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzYFL9STJa8jHI7DNa9q0Ct2msvSHKqWYbG2Ijud6FVKd2WZ7CYcKfmfUpwsSVUcD iWcBZJeh2GSVgMqPLv5hzi1AWpPjKkXByXN92nd4m7mjPmvxI+jFekvjBBdo3o3Bmx VEb/oN35j5mM7Jyt3pCh7Yj9cT4l9W6ryKUJyMo0= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160529eucas1p15f13911de33cd87b46d546803a869e77~8rSIU8Pv02439624396eucas1p1w; Sat, 10 Oct 2020 16:05:29 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 11.E6.06456.9CBD18F5; Sat, 10 Oct 2020 17:05:29 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160528eucas1p2b9b8189aef51c18d116f97ccebf5719c~8rSHrQtaR1129911299eucas1p2y; Sat, 10 Oct 2020 16:05:28 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160528eusmtrp12676966b6f9c1b93a586a671e47e8de9~8rSHqs6qm2920229202eusmtrp1w; Sat, 10 Oct 2020 16:05:28 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-1c-5f81dbc9660a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3A.A6.06017.8CBD18F5; Sat, 10 Oct 2020 17:05:28 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160527eusmtip12d50cfd036f29206d8e5c3f0695d0d23~8rSG-F62m2442224422eusmtip10; Sat, 10 Oct 2020 16:05:27 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:57 +0200 Message-Id: <20201010160508.19709-7-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djP87onbzfGG2x+ymtxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBmXO88y FjzUrejdtZOxgXGSahcjJ4eEgInEoouTGbsYuTiEBFYwSmxdvosJJCEk8IVRYv5xd4jEZ0aJ U51PgKo4wDouN5hBxJczSjxpf88O0fCJUeLPcjsQm03AVuLIzK+sILaIQJhEc/NeFpBeZgFn iSdf2UDCwgKeElc//AbbxSKgKrGr7zLYeF4BV4mZZ9QgbpOXWL3hADOIzSngJnG26yAbyFoJ gctsEq2PDrNDFLlIHN95nQXCFpZ4dXwLVFxG4vTkHhaIhm2MEld//2SEcPYzSlzvXQFVZS1x +N9vNojjNCXW79KHCDtK9PReYoL4l0/ixltBkDAzkDlp23RmiDCvRE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5B4CJzg8KB49+b dinXnTK3qrl3oIvhx89O33dT38y/E9q5qOnS/ACZhokRV+atfcWzcs+arniv3DlGpyTLK24I de39zNbfKvXc4rHEMttt8gwxLdyXGBSfRQdPq/bx/Hktda1yuBJLcUaioRZzUXEiAMgK5PtZ AgAA X-CMS-MailID: 20201010160528eucas1p2b9b8189aef51c18d116f97ccebf5719c X-Msg-Generator: CA X-RootMTR: 20201010160528eucas1p2b9b8189aef51c18d116f97ccebf5719c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160528eucas1p2b9b8189aef51c18d116f97ccebf5719c References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 06/16] test/distributor: synchronize lcores statistics 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" Statistics of handled packets are cleared and read on main lcore, while they are increased in workers handlers on different lcores. Without synchronization occasionally showed invalid values. This patch uses atomic acquire/release mechanisms to synchronize. Fixes: c3eabff124e6 ("distributor: add unit tests") Cc: bruce.richardson@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 43 +++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 6cd7a2edd..838459392 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -43,7 +43,8 @@ total_packet_count(void) { unsigned i, count = 0; for (i = 0; i < worker_idx; i++) - count += worker_stats[i].handled_packets; + count += __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE); return count; } @@ -51,7 +52,10 @@ total_packet_count(void) static inline void clear_packet_count(void) { - memset(&worker_stats, 0, sizeof(worker_stats)); + unsigned int i; + for (i = 0; i < RTE_MAX_LCORE; i++) + __atomic_store_n(&worker_stats[i].handled_packets, 0, + __ATOMIC_RELEASE); } /* this is the basic worker function for sanity test @@ -69,13 +73,13 @@ handle_work(void *arg) num = rte_distributor_get_pkt(db, id, buf, NULL, 0); while (!quit) { __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_RELAXED); + __ATOMIC_ACQ_REL); count += num; num = rte_distributor_get_pkt(db, id, buf, buf, num); } __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_RELAXED); + __ATOMIC_ACQ_REL); count += num; rte_distributor_return_pkt(db, id, buf, num); return 0; @@ -131,7 +135,8 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); printf("Sanity test with all zero hashes done.\n"); /* pick two flows and check they go correctly */ @@ -156,7 +161,9 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n( + &worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); printf("Sanity test with two hash values done\n"); } @@ -182,7 +189,8 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); printf("Sanity test with non-zero hashes done\n"); rte_mempool_put_bulk(p, (void *)bufs, BURST); @@ -275,14 +283,16 @@ handle_work_with_free_mbufs(void *arg) num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!quit) { - worker_stats[id].handled_packets += num; count += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } - worker_stats[id].handled_packets += num; count += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); rte_distributor_return_pkt(d, id, buf, num); return 0; } @@ -358,8 +368,9 @@ handle_work_for_shutdown_test(void *arg) /* wait for quit single globally, or for worker zero, wait * for zero_quit */ while (!quit && !(id == zero_id && zero_quit)) { - worker_stats[id].handled_packets += num; count += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -373,10 +384,11 @@ handle_work_for_shutdown_test(void *arg) total += num; } - worker_stats[id].handled_packets += num; count += num; returned = rte_distributor_return_pkt(d, id, buf, num); + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_ACQ_REL); if (id == zero_id) { /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. @@ -387,7 +399,8 @@ handle_work_for_shutdown_test(void *arg) num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!quit) { - worker_stats[id].handled_packets += num; + __atomic_fetch_add(&worker_stats[id].handled_packets, + num, __ATOMIC_ACQ_REL); count += num; rte_pktmbuf_free(pkt); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -454,7 +467,8 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); if (total_packet_count() != BURST * 2) { printf("Line %d: Error, not all packets flushed. " @@ -507,7 +521,8 @@ test_flush_with_worker_shutdown(struct worker_params *wp, zero_quit = 0; for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, - worker_stats[i].handled_packets); + __atomic_load_n(&worker_stats[i].handled_packets, + __ATOMIC_ACQUIRE)); if (total_packet_count() != BURST) { printf("Line %d: Error, not all packets flushed. " From patchwork Sat Oct 10 16:04:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80283 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EB2C5A04B1; Sat, 10 Oct 2020 18:08:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 641821D945; Sat, 10 Oct 2020 18:05:52 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 285A61D932 for ; Sat, 10 Oct 2020 18:05:49 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160537euoutp02ccf046ca6818d9ecd2fd7143629ba977~8rSQYtIQF2851128511euoutp02a for ; Sat, 10 Oct 2020 16:05:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160537euoutp02ccf046ca6818d9ecd2fd7143629ba977~8rSQYtIQF2851128511euoutp02a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345938; bh=Ijucr6xPwukpZ96boOK/+8uaapTvTE3KxkYfXLm/HJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vg5hJ9GXP2Jlz/WeqVolrGZnIhOD/6Xayiwmgj6GfPO0glN0M3CJp8kyCTFR2nCej 6VCZ6OQz9IV4K/7SXr299LeRl6pPYofxtPylR1eMWxjxcaUhQ7xHo/2ajaqp8R3d/u skEhJ2TWnM063EiTulO4Q1iM8vfmTRyrvPND3oxk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160531eucas1p1af14b9af332ca0768510a13b5073d9eb~8rSKqAZZs2236122361eucas1p11; Sat, 10 Oct 2020 16:05:31 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 71.E6.06456.BCBD18F5; Sat, 10 Oct 2020 17:05:31 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160530eucas1p15baba6fba44a7caee8b4b0ff778a961d~8rSJdLNQY2308623086eucas1p1u; Sat, 10 Oct 2020 16:05:30 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160530eusmtrp1cad744914f12d64bee41c69af06fec47~8rSJcp5SC2920229202eusmtrp1x; Sat, 10 Oct 2020 16:05:30 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-20-5f81dbcbb6a0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F4.5A.06314.ACBD18F5; Sat, 10 Oct 2020 17:05:30 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160529eusmtip1170ef6cde66621f199933ec543f2e2f3~8rSIqCH3B2442224422eusmtip11; Sat, 10 Oct 2020 16:05:29 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:58 +0200 Message-Id: <20201010160508.19709-8-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung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RhhZG eoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF+nYJehkXl+xlLZjEXXH+zBy2BsbNnF2MnBwS AiYSl+48Z+1i5OIQEljKKHH1+Rq2LkYOoISMxIdLAhA1whJ/rnWxQdR8YJRY+P0HE0iCTcBW 4sjMr6wg9SICYRInVvqDhJkF3CW2LJ7KDGILC3hJrNp2B6ycRUBV4vGKr4wgNq+Aq0T3kceM EPPlJVZvOABWzyngJnG26yDUrkZGiRO3b7JNYORbwMiwilEktbQ4Nz232FCvODG3uDQvXS85 P3cTIzAUtx37uXkH46WNwYcYBTgYlXh4JU41xguxJpYVV+YeYpTgYFYS4XU6ezpOiDclsbIq tSg/vqg0J7X4EKMp0FUTmaVEk/OBcZJXEm9oamhuYWlobmxubGahJM7bIXAwRkggPbEkNTs1 tSC1CKaPiYNTqoGRfVK9Z+PxB73e8v+nv72z9/RWfeHn6YKHl83g/zmT/YBL4KW4uN4sg96z R18tCTmY/kVwSbyG/XGZ73XrEk79fZ2fK95We/vbk0X7XDUKHa1+XHB+5lDUzKLotn7tvSS9 E25KRWnmx0/ozs+I+hD22t7O1F1kS62AmkJLE0eIa1vY+lustmeVWIozEg21mIuKEwGbX32f WwIAAA== X-CMS-MailID: 20201010160530eucas1p15baba6fba44a7caee8b4b0ff778a961d X-Msg-Generator: CA X-RootMTR: 20201010160530eucas1p15baba6fba44a7caee8b4b0ff778a961d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160530eucas1p15baba6fba44a7caee8b4b0ff778a961d References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 07/16] distributor: fix return pkt calls in single mode 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" In the single legacy version of the distributor synchronization requires continues exchange of buffers between distributor and workers. Empty buffers are sent if only handshake synchronization is required. However calls to the rte_distributor_return_pkt() with 0 buffers in single mode were ignored and not passed to the legacy algorithm implementation causing lack of synchronization. This patch fixes this issue by passing NULL as buffer which is a valid way of sending just synchronization handshakes in single mode. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 115443fc0..9fd7dcab7 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -168,6 +168,9 @@ rte_distributor_return_pkt(struct rte_distributor *d, if (num == 1) return rte_distributor_return_pkt_single(d->d_single, worker_id, oldpkt[0]); + else if (num == 0) + return rte_distributor_return_pkt_single(d->d_single, + worker_id, NULL); else return -EINVAL; } From patchwork Sat Oct 10 16:04:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80284 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C322A04B1; Sat, 10 Oct 2020 18:08:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DC2921D94A; Sat, 10 Oct 2020 18:05:55 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 3C62E1D949 for ; Sat, 10 Oct 2020 18:05:53 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160542euoutp015cb3f17547b22533b35560e13f484a4d~8rSVCnC8l0390103901euoutp01Y for ; Sat, 10 Oct 2020 16:05:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160542euoutp015cb3f17547b22533b35560e13f484a4d~8rSVCnC8l0390103901euoutp01Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345943; bh=XHBRFJdpy0VQOXDZHZktkwJ397h3dgSUtlAUFqe+eH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRjRTgDjw+VNJ0tGO3vYH8ihl7oDyYzl3rif9wvBikPl8s2uLXI/MuSC4geiAXbjW nlX2pA8RVz6EwxFL/aQAGkAMAvJIp8L8SvjIULukzUXoAyIOkmSXu97+QGU+DiqtWB zt6qyLUPz+rM0cyBMBTN3vDXFFPIv/0+OZ/Q4ksw= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160537eucas1p2f572ce782fcbee7d811f9b422ce4d842~8rSQJU4k30101201012eucas1p2p; Sat, 10 Oct 2020 16:05:37 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 38.58.05997.1DBD18F5; Sat, 10 Oct 2020 17:05:37 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160536eucas1p2b20e729b90d66eddd03618e98d38c179~8rSPCPY_N0269602696eucas1p2o; Sat, 10 Oct 2020 16:05:36 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160536eusmtrp2ae0a91d05b2d78cb5eaf0d73ee215bd0~8rSPBq-zW1692616926eusmtrp2F; Sat, 10 Oct 2020 16:05:36 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-76-5f81dbd18b7b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 9A.A6.06017.0DBD18F5; Sat, 10 Oct 2020 17:05:36 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160533eusmtip15d15f329759683dabdc2e02273b0df71~8rSMRIxaL2442224422eusmtip12; Sat, 10 Oct 2020 16:05:31 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:04:59 +0200 Message-Id: <20201010160508.19709-9-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djP87oXbzfGG2w7oW5xY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBmndj5k LZgbVLH56Vb2BsaXjl2MnBwSAiYSP7f9ZOxi5OIQEljBKHFxym1mCOcLo8TBj+eYIJzPjBKf Vk5ghmnpmHiOHcQWEljOKLHxozlE0SdGiQtN39lAEmwCthJHZn5lBbFFBMIkmpv3snQxcnAw CzhLPPkKViIMVLLwyDOwMIuAqsSeZyogYV4BV4kLmx9DrZKXWL3hAJjNKeAmcbbrIBvIKgmB y2wSp5/NAuuVEHCReHnEFKJeWOLV8S3sELaMxP+d85kg6rcxSlz9DfGmhMB+RonrvSugqqwl Dv/7zQZxm6bE+l36EDMdJY6/y4Yw+SRuvBUEKWYGMidtm84MEeaV6GgTgpihJ/G0ZyojzNY/ a5+wQNgeEr8X/YaG4FVGia6lR9kmMMrPQti1gJFxFaN4amlxbnpqsVFearlecWJucWleul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3 b28u479FYddPazru4VpRc+Gt+QzeCt76z5I73ReLP09XXinpo8RSnJFoqMVcVJwIAAt/zedZ AgAA X-CMS-MailID: 20201010160536eucas1p2b20e729b90d66eddd03618e98d38c179 X-Msg-Generator: CA X-RootMTR: 20201010160536eucas1p2b20e729b90d66eddd03618e98d38c179 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160536eucas1p2b20e729b90d66eddd03618e98d38c179 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 08/16] test/distributor: fix freeing mbufs 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 tests with mbuf alloc and shutdown tests assume that mbufs passed to worker cores are freed in handlers. Such packets should not be returned to the distributor's main core. The only packets that should be returned are the packets send after completion of the tests in quit_workers function. This patch stops returning mbufs to distributor's core. In case of shutdown tests it is impossible to determine how worker and distributor threads would synchronize. Packets used by tests should be freed and packets used during quit_workers() shouldn't. That's why returning mbufs to mempool is moved to test procedure run on distributor thread from worker threads. Additionally this patch cleans up unused variables. Fixes: c0de0eb82e40 ("distributor: switch over to new API") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 96 ++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 838459392..06e01ff9d 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -44,7 +44,7 @@ total_packet_count(void) unsigned i, count = 0; for (i = 0; i < worker_idx; i++) count += __atomic_load_n(&worker_stats[i].handled_packets, - __ATOMIC_ACQUIRE); + __ATOMIC_RELAXED); return count; } @@ -55,7 +55,7 @@ clear_packet_count(void) unsigned int i; for (i = 0; i < RTE_MAX_LCORE; i++) __atomic_store_n(&worker_stats[i].handled_packets, 0, - __ATOMIC_RELEASE); + __ATOMIC_RELAXED); } /* this is the basic worker function for sanity test @@ -67,20 +67,18 @@ handle_work(void *arg) struct rte_mbuf *buf[8] __rte_cache_aligned; struct worker_params *wp = arg; struct rte_distributor *db = wp->dist; - unsigned int count = 0, num; + unsigned int num; unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(db, id, buf, NULL, 0); while (!quit) { __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); - count += num; + __ATOMIC_RELAXED); num = rte_distributor_get_pkt(db, id, buf, buf, num); } __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); - count += num; + __ATOMIC_RELAXED); rte_distributor_return_pkt(db, id, buf, num); return 0; } @@ -136,7 +134,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) 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, - __ATOMIC_ACQUIRE)); + __ATOMIC_RELAXED)); printf("Sanity test with all zero hashes done.\n"); /* pick two flows and check they go correctly */ @@ -163,7 +161,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) printf("Worker %u handled %u packets\n", i, __atomic_load_n( &worker_stats[i].handled_packets, - __ATOMIC_ACQUIRE)); + __ATOMIC_RELAXED)); printf("Sanity test with two hash values done\n"); } @@ -190,7 +188,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) 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, - __ATOMIC_ACQUIRE)); + __ATOMIC_RELAXED)); printf("Sanity test with non-zero hashes done\n"); rte_mempool_put_bulk(p, (void *)bufs, BURST); @@ -276,23 +274,20 @@ handle_work_with_free_mbufs(void *arg) struct rte_mbuf *buf[8] __rte_cache_aligned; struct worker_params *wp = arg; struct rte_distributor *d = wp->dist; - unsigned int count = 0; unsigned int i; unsigned int num; unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); while (!quit) { - count += num; __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); + __ATOMIC_RELAXED); for (i = 0; i < num; i++) rte_pktmbuf_free(buf[i]); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } - count += num; __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); + __ATOMIC_RELAXED); rte_distributor_return_pkt(d, id, buf, num); return 0; } @@ -318,7 +313,6 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) rte_distributor_process(d, NULL, 0); for (j = 0; j < BURST; j++) { bufs[j]->hash.usr = (i+j) << 1; - rte_mbuf_refcnt_set(bufs[j], 1); } rte_distributor_process(d, bufs, BURST); @@ -342,15 +336,10 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) static int handle_work_for_shutdown_test(void *arg) { - struct rte_mbuf *pkt = NULL; struct rte_mbuf *buf[8] __rte_cache_aligned; struct worker_params *wp = arg; struct rte_distributor *d = wp->dist; - unsigned int count = 0; unsigned int num; - 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, @@ -368,11 +357,8 @@ handle_work_for_shutdown_test(void *arg) /* wait for quit single globally, or for worker zero, wait * for zero_quit */ while (!quit && !(id == zero_id && zero_quit)) { - count += num; __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); - for (i = 0; i < num; i++) - rte_pktmbuf_free(buf[i]); + __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); if (num > 0) { @@ -381,15 +367,12 @@ handle_work_for_shutdown_test(void *arg) false, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); } zero_id = __atomic_load_n(&zero_idx, __ATOMIC_ACQUIRE); - - total += num; } - count += num; - returned = rte_distributor_return_pkt(d, id, buf, num); - __atomic_fetch_add(&worker_stats[id].handled_packets, num, - __ATOMIC_ACQ_REL); + __ATOMIC_RELAXED); if (id == zero_id) { + rte_distributor_return_pkt(d, id, NULL, 0); + /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. */ @@ -400,15 +383,11 @@ handle_work_for_shutdown_test(void *arg) while (!quit) { __atomic_fetch_add(&worker_stats[id].handled_packets, - num, __ATOMIC_ACQ_REL); - count += num; - rte_pktmbuf_free(pkt); + num, __ATOMIC_RELAXED); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); } - returned = rte_distributor_return_pkt(d, - id, buf, num); - printf("Num returned = %d\n", returned); } + rte_distributor_return_pkt(d, id, buf, num); return 0; } @@ -424,7 +403,9 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, { struct rte_distributor *d = wp->dist; struct rte_mbuf *bufs[BURST]; - unsigned i; + struct rte_mbuf *bufs2[BURST]; + unsigned int i; + unsigned int failed = 0; printf("=== Sanity test of worker shutdown ===\n"); @@ -450,16 +431,17 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, */ /* get more buffers to queue up, again setting them to the same flow */ - if (rte_mempool_get_bulk(p, (void *)bufs, BURST) != 0) { + if (rte_mempool_get_bulk(p, (void *)bufs2, BURST) != 0) { printf("line %d: Error getting mbufs from pool\n", __LINE__); + rte_mempool_put_bulk(p, (void *)bufs, BURST); return -1; } for (i = 0; i < BURST; i++) - bufs[i]->hash.usr = 1; + bufs2[i]->hash.usr = 1; /* get worker zero to quit */ zero_quit = 1; - rte_distributor_process(d, bufs, BURST); + rte_distributor_process(d, bufs2, BURST); /* flush the distributor */ rte_distributor_flush(d); @@ -468,15 +450,21 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, 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, - __ATOMIC_ACQUIRE)); + __ATOMIC_RELAXED)); if (total_packet_count() != BURST * 2) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n", __LINE__, BURST * 2, total_packet_count()); - return -1; + failed = 1; } + rte_mempool_put_bulk(p, (void *)bufs, BURST); + rte_mempool_put_bulk(p, (void *)bufs2, BURST); + + if (failed) + return -1; + printf("Sanity test with worker shutdown passed\n\n"); return 0; } @@ -490,7 +478,8 @@ test_flush_with_worker_shutdown(struct worker_params *wp, { struct rte_distributor *d = wp->dist; struct rte_mbuf *bufs[BURST]; - unsigned i; + unsigned int i; + unsigned int failed = 0; printf("=== Test flush fn with worker shutdown (%s) ===\n", wp->name); @@ -522,15 +511,20 @@ test_flush_with_worker_shutdown(struct worker_params *wp, 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, - __ATOMIC_ACQUIRE)); + __ATOMIC_RELAXED)); if (total_packet_count() != BURST) { printf("Line %d: Error, not all packets flushed. " "Expected %u, got %u\n", __LINE__, BURST, total_packet_count()); - return -1; + failed = 1; } + rte_mempool_put_bulk(p, (void *)bufs, BURST); + + if (failed) + return -1; + printf("Flush test with worker shutdown passed\n\n"); return 0; } @@ -596,7 +590,10 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) const unsigned num_workers = rte_lcore_count() - 1; unsigned i; struct rte_mbuf *bufs[RTE_MAX_LCORE]; - rte_mempool_get_bulk(p, (void *)bufs, num_workers); + if (rte_mempool_get_bulk(p, (void *)bufs, num_workers) != 0) { + printf("line %d: Error getting mbufs from pool\n", __LINE__); + return; + } zero_quit = 0; quit = 1; @@ -604,11 +601,12 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) bufs[i]->hash.usr = i << 1; rte_distributor_process(d, bufs, num_workers); - rte_mempool_put_bulk(p, (void *)bufs, num_workers); - rte_distributor_process(d, NULL, 0); rte_distributor_flush(d); rte_eal_mp_wait_lcore(); + + rte_mempool_put_bulk(p, (void *)bufs, num_workers); + quit = 0; worker_idx = 0; zero_idx = RTE_MAX_LCORE; From patchwork Sat Oct 10 16:05:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80286 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B5BCA04B1; Sat, 10 Oct 2020 18:09:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ACB871D960; Sat, 10 Oct 2020 18:06:00 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 489B01D94F for ; Sat, 10 Oct 2020 18:05:58 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160548euoutp010f9ac802c6306b1df52aa91d5080fa8b~8rSZycn4Q0101401014euoutp01u for ; Sat, 10 Oct 2020 16:05:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160548euoutp010f9ac802c6306b1df52aa91d5080fa8b~8rSZycn4Q0101401014euoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345948; bh=faTZS3uOROPHkE9n9BxhsWOgeJZpgrOtfleCwr1/fg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6cTNrEK58ZU3KEpM4VfIH5p3WuS3MBh+FEOUq7ONVZZW+oFMPRuscF1SRApzhcjI G23clIShnd85104E72y64ouCfLcQ8fEzSPvHczm/+g1u3r8yi4aolZqYd2aifGESg3 CsBULehjACBYF0iHKNRg+rUKX/B7zB0mSqdFRuXY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160539eucas1p2f8973a2196b1de2edab58cd0f37e7c26~8rSR5qrbz0179501795eucas1p2t; Sat, 10 Oct 2020 16:05:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id FE.B2.06318.3DBD18F5; Sat, 10 Oct 2020 17:05:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160538eucas1p19298667f236209cfeaa4745f9bb3aae6~8rSQuNB8P2235322353eucas1p1G; Sat, 10 Oct 2020 16:05:38 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160538eusmtrp25c3e7337650d92e3e8f28bce568dfc72~8rSQtsAUp1692616926eusmtrp2G; Sat, 10 Oct 2020 16:05:38 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-cc-5f81dbd3872a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 55.5A.06314.2DBD18F5; Sat, 10 Oct 2020 17:05:38 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160537eusmtip1f95b3e3ada6ed1b790c89bc925c32530~8rSP6H0YZ2442224422eusmtip13; Sat, 10 Oct 2020 16:05:37 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:00 +0200 Message-Id: <20201010160508.19709-10-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djPc7qXbzfGGzT9kbW4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErowvt5uY Cl7wVLw7fJ6pgfEVVxcjJ4eEgIlEe+9C5i5GLg4hgRWMElMnnmSEcL4wShxZ08sE4XxmlJj1 6gUTTMvm0xPAbCGB5YwSu1blQBR9YpRYd/AOO0iCTcBW4sjMr6wgtohAmERz816WLkYODmYB Z4knX9lATGEBB4nra2NBKlgEVCWWv/wCNpJXwE1i8uPnUKvkJVZvOMAMYnMCxc92HWQDWSUh cJ1NYuvEdqgiF4mWDVtZIWxhiVfHt7BD2DIS/3fOZ4Jo2MYocfX3T0YIZz+jxPXeFVBV1hKH //1mgzhOU2L9Ln2IsKPEqo8XGUHCEgJ8EjfeCoKEmYHMSdumM0OEeSU62oQgqvUknvZMZYRZ +2ftExYI20Pi8Olp0DC8yiixoLOXcQKj/CyEZQsYGVcxiqeWFuempxYb56WW6xUn5haX5qXr JefnbmIExv7pf8e/7mDc9yfpEKMAB6MSD++B443xQqyJZcWVuYcYJTiYlUR4nc6ejhPiTUms rEotyo8vKs1JLT7EKM3BoiTOa7zoZayQQHpiSWp2ampBahFMlomDU6qBcf2XUz/bVVedOPX2 4aOQr0FlwQkb53pxhoccajq2MKO5UVvLNOl6ac6upzfKgu2/vDSPWZR4hCnz5jvflhM7s9Nm 820O06lav+bz9OofW5etDmP+VSty+uhFXZ11wv16T6deLkpTvc3Q+/TQiwsVHdM2ut28YmF5 eMXxPZHPtflXtDoJrHxy6LASS3FGoqEWc1FxIgAuAqoA+QIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsVy+t/xu7qXbjfGG7y+KGxxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRejZF+aUlqQoZ+cUltkrRhhZG eoaWFnpGJpZ6hsbmsVZGpkr6djYpqTmZZalF+nYJehlfbjcxFbzgqXh3+DxTA+Mrri5GTg4J AROJzacnMHUxcnEICSxllFhzvJOti5EDKCEj8eGSAESNsMSfa11sEDUfGCVWLtvABpJgE7CV ODLzKytIvYhAmMSJlf4gYWYBd4kti6cyg4SFBRwkrq+NBQmzCKhKLH/5hQnE5hVwk5j8+DkT xHh5idUbDjCD2JxA8bNdB6FWNTJKnLh9k20CI98CRoZVjCKppcW56bnFhnrFibnFpXnpesn5 uZsYgYG47djPzTsYL20MPsQowMGoxMMrcaoxXog1say4MvcQowQHs5IIr9PZ03FCvCmJlVWp RfnxRaU5qcWHGE2BrprILCWanA+MkrySeENTQ3MLS0NzY3NjMwslcd4OgYMxQgLpiSWp2amp BalFMH1MHJxSDYxs2bs6zrq+vXyobJrd13Ph+5KnvlgT6zn763+vuN51VbG7q1lflh1WnMCm oPy4/hPzeq0o5aVbf5dPDjoSebzKrKX+XkriWssJbgENnkUPVm7NTy9xWGoY+PvnBdGl7x9M 1bt3hP1drubHtLRJ/CtXuSephb3x/rvo/S69d44CGaevBvWmBrxVYinOSDTUYi4qTgQAD7Vj HVoCAAA= X-CMS-MailID: 20201010160538eucas1p19298667f236209cfeaa4745f9bb3aae6 X-Msg-Generator: CA X-RootMTR: 20201010160538eucas1p19298667f236209cfeaa4745f9bb3aae6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160538eucas1p19298667f236209cfeaa4745f9bb3aae6 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 09/16] test/distributor: collect return mbufs 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" During quit_workers function distributor's main core processes some packets to wake up pending worker cores so they can quit. As quit_workers acts also as a cleanup procedure for next test case it should also collect these packages returned by workers' handlers, so the cyclic buffer with returned packets in distributor remains empty. Fixes: c3eabff124e6 ("distributor: add unit tests") Cc: bruce.richardson@intel.com Fixes: c0de0eb82e40 ("distributor: switch over to new API") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 06e01ff9d..ed03040d1 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -590,6 +590,7 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) const unsigned num_workers = rte_lcore_count() - 1; unsigned i; struct rte_mbuf *bufs[RTE_MAX_LCORE]; + struct rte_mbuf *returns[RTE_MAX_LCORE]; if (rte_mempool_get_bulk(p, (void *)bufs, num_workers) != 0) { printf("line %d: Error getting mbufs from pool\n", __LINE__); return; @@ -605,6 +606,10 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) rte_distributor_flush(d); rte_eal_mp_wait_lcore(); + while (rte_distributor_returned_pkts(d, returns, RTE_MAX_LCORE)) + ; + + rte_distributor_clear_returns(d); rte_mempool_put_bulk(p, (void *)bufs, num_workers); quit = 0; From patchwork Sat Oct 10 16:05:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80285 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 60867A04B1; Sat, 10 Oct 2020 18:09:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18E5C1D95C; Sat, 10 Oct 2020 18:05:59 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 426A41D94F for ; Sat, 10 Oct 2020 18:05:56 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160546euoutp014a06e78ac9eb2b7198f037142c94feb3~8rSX8DcM90390103901euoutp01Z for ; Sat, 10 Oct 2020 16:05:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160546euoutp014a06e78ac9eb2b7198f037142c94feb3~8rSX8DcM90390103901euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345946; bh=fynvMAAU6OLk1/+zR+LOvZdNO64pUieNLjkvDKcsip8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NMpkx5c/iK/ySVDAkEi5i5ciNyvO9UWFg3mUZpwe4C5hOTmon9MN5BhHRlwHsYfKY b4PGMHgfn6gbqyx7oTU8gf82MpHTm5uAE1YjcKXMprVk77t8OxgThIBPXQ6yueP6nw yGB5RZASET4VNlzLftbuzg9NFOKVnQ/rj8SKgtb8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160540eucas1p2b31ea850d1def1a96a9f0ee8bcfdac07~8rSTBLQl70054800548eucas1p2_; Sat, 10 Oct 2020 16:05:40 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5F.B2.06318.4DBD18F5; Sat, 10 Oct 2020 17:05:40 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160540eucas1p2d942834b4749672c433a37a8fe520bd1~8rSSZbPve0101201012eucas1p2r; Sat, 10 Oct 2020 16:05:40 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160540eusmtrp250d08ed983f789ee5f2920c3860bed02~8rSSY5-YO1692616926eusmtrp2I; Sat, 10 Oct 2020 16:05:40 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-ce-5f81dbd45cdb Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B5.5A.06314.4DBD18F5; Sat, 10 Oct 2020 17:05:40 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160539eusmtip12c16ab15579d9afeaa4848e4d87e1705~8rSRneMrF2442224422eusmtip14; Sat, 10 Oct 2020 16:05:39 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:01 +0200 Message-Id: <20201010160508.19709-11-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djPc7pXbjfGG8z5qmVxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBm3LpUU fJCquPisibmB8Z5oFyMHh4SAicSDruIuRi4OIYEVjBLLf19hhHC+MErs2T2BuYuRE8j5zCix 4IQiiA3ScPTuAjaI+HJGieP7ZCAaPjFKbDh4lwUkwSZgK3Fk5ldWEFtEIEyiuXkvC8g2ZgFn iSdfwXqFBTwknj59zQRiswioSty8c40RxOYVcJM4ueUiI8QueYnVGw6A3cAJFD/bdZAN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X58 UWlOavEhRlOgqyYyS4km5wOjJK8k3tDU0NzC0tDc2NzYzEJJnLdD4GCMkEB6YklqdmpqQWoR TB8TB6dUA2O97BueJaJZvJyu6iuTK6t2yOeJvgrP3L751RFBobPnH81u9emdn3ihrizvEees o6V3nplxTn77wvrv7rPPFvHqcpnXbRT3Ncmz+vzx7YHIr69ufE7YJLwpNVFoaljyIoPtTRuW Sa5zc+40SFj7rDlE48DlZE+7n3dOGpZ82qp+rTYna7Hp+nglluKMREMt5qLiRAAF/HbRWgIA AA== X-CMS-MailID: 20201010160540eucas1p2d942834b4749672c433a37a8fe520bd1 X-Msg-Generator: CA X-RootMTR: 20201010160540eucas1p2d942834b4749672c433a37a8fe520bd1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160540eucas1p2d942834b4749672c433a37a8fe520bd1 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 10/16] distributor: align API documentation with code 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" After introducing burst API there were some artefacts in the API documentation from legacy single API. Also the rte_distributor_poll_pkt() function return values mismatched the implementation. Fixes: c0de0eb82e40 ("distributor: switch over to new API") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.h | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/librte_distributor/rte_distributor.h b/lib/librte_distributor/rte_distributor.h index 327c0c4ab..a073e6461 100644 --- a/lib/librte_distributor/rte_distributor.h +++ b/lib/librte_distributor/rte_distributor.h @@ -155,7 +155,7 @@ rte_distributor_clear_returns(struct rte_distributor *d); * @param pkts * The mbufs pointer array to be filled in (up to 8 packets) * @param oldpkt - * The previous packet, if any, being processed by the worker + * The previous packets, if any, being processed by the worker * @param retcount * The number of packets being returned * @@ -187,15 +187,15 @@ rte_distributor_return_pkt(struct rte_distributor *d, /** * API called by a worker to request a new packet to process. - * Any previous packet given to the worker is assumed to have completed + * Any previous packets given to the worker are assumed to have completed * processing, and may be optionally returned to the distributor via * the oldpkt parameter. - * Unlike rte_distributor_get_pkt_burst(), this function does not wait for a - * new packet to be provided by the distributor. + * Unlike rte_distributor_get_pkt(), this function does not wait for + * new packets to be provided by the distributor. * - * NOTE: after calling this function, rte_distributor_poll_pkt_burst() should - * be used to poll for the packet requested. The rte_distributor_get_pkt_burst() - * API should *not* be used to try and retrieve the new packet. + * NOTE: after calling this function, rte_distributor_poll_pkt() should + * be used to poll for the packets requested. The rte_distributor_get_pkt() + * API should *not* be used to try and retrieve the new packets. * * @param d * The distributor instance to be used @@ -213,9 +213,9 @@ rte_distributor_request_pkt(struct rte_distributor *d, unsigned int count); /** - * API called by a worker to check for a new packet that was previously + * API called by a worker to check for new packets that were previously * requested by a call to rte_distributor_request_pkt(). It does not wait - * for the new packet to be available, but returns NULL if the request has + * for the new packets to be available, but returns if the request has * not yet been fulfilled by the distributor. * * @param d @@ -227,8 +227,9 @@ rte_distributor_request_pkt(struct rte_distributor *d, * The array of mbufs being given to the worker * * @return - * The number of packets being given to the worker thread, zero if no - * packet is yet available. + * The number of packets being given to the worker thread, + * -1 if no packets are yet available (burst API - RTE_DIST_ALG_BURST) + * 0 if no packets are yet available (legacy single API - RTE_DIST_ALG_SINGLE) */ int rte_distributor_poll_pkt(struct rte_distributor *d, From patchwork Sat Oct 10 16:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80287 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63016A04B1; Sat, 10 Oct 2020 18:10:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 902E51D974; Sat, 10 Oct 2020 18:06:02 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 465991D95F for ; Sat, 10 Oct 2020 18:05:59 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160549euoutp02682685773821aecac61d2f5e81cef11b~8rSaxZnn-1807318073euoutp02c for ; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160549euoutp02682685773821aecac61d2f5e81cef11b~8rSaxZnn-1807318073euoutp02c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345949; bh=9P4E0B5kieQ8/tBzQ8nyDsGgZm6tUvk7hTzdKz8POqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V5siXtX0970R2CEgJrRJSLNMlQFTNF/kyI9Gq+g3NLqBax3sX7wHr3gh50nm1XL+p rYyfEEvxN49BaJu0WAPfLD58eS2Sywvckh1letuxGoKa+z2X6sVkrIc1+uaFBoALQp PFLp/ZYFhCinTa317SPWc7KJLobaMr2aPtWy2Iqw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160543eucas1p2c6c7e89a21659cf16efcbed3d60b27b5~8rSVEWFWb0083200832eucas1p2t; Sat, 10 Oct 2020 16:05:43 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BF.B2.06318.6DBD18F5; Sat, 10 Oct 2020 17:05:42 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160541eucas1p11d079bad2b7500f9ab927463e1eeac04~8rSUD_XnE2236122361eucas1p13; Sat, 10 Oct 2020 16:05:41 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160541eusmtrp2da7990605f67bcc7dbf003d604f70fdd~8rSUDd2_N1692616926eusmtrp2J; Sat, 10 Oct 2020 16:05:41 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-d1-5f81dbd63cc1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1B.A6.06017.5DBD18F5; Sat, 10 Oct 2020 17:05:41 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160541eusmtip108e5bc475dd9393beb671ed0c77eae70~8rSTWfho52442224422eusmtip15; Sat, 10 Oct 2020 16:05:41 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:02 +0200 Message-Id: <20201010160508.19709-12-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87rXbjfGG6xfbGlxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBnvN69g LOgSrTh28iBzA+MawS5GTg4JAROJjbP3MXUxcnEICaxglPi+dwsrhPOFUeLUpY3sEM5nRomJ p+YwwbQ09r6ASixnlNhxagKU84lRYv+2o2wgVWwCthJHZ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XFuem6xkV5xYm5xaV66XnJ+ 7iZGYChuO/Zzyw7GrnfBhxgFOBiVeHglTjXGC7EmlhVX5h5ilOBgVhLhdTp7Ok6INyWxsiq1 KD++qDQntfgQoynQVROZpUST84FxklcSb2hqaG5haWhubG5sZqEkztshcDBGSCA9sSQ1OzW1 ILUIpo+Jg1OqgTH8fuX8HSvWLr/06vKWZxfYP9+e6loa4/Ftk0JCrNGFAnY2oYpAt0lOZ3VT zfUTV7VmP/KojGcRFFBmays6IuYi/HTTGcVNS4L2xHf6ZL8L2ZNePWlPzpMpuz/YcGybI384 9L4Sk//FE05hnB99bGSKFvbO3HJ89YHFq1YXLl68L2SxSVm3oZgSS3FGoqEWc1FxIgAC992p WwIAAA== X-CMS-MailID: 20201010160541eucas1p11d079bad2b7500f9ab927463e1eeac04 X-Msg-Generator: CA X-RootMTR: 20201010160541eucas1p11d079bad2b7500f9ab927463e1eeac04 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160541eucas1p11d079bad2b7500f9ab927463e1eeac04 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 11/16] test/distributor: replace delays with spin locks 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" 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 Acked-by: David Hunt --- 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 ed03040d1..e8dd75078 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 From patchwork Sat Oct 10 16:05:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80288 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0B7AAA04B1; Sat, 10 Oct 2020 18:10:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 45B5B1D981; Sat, 10 Oct 2020 18:06:07 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id D00F81D978 for ; Sat, 10 Oct 2020 18:06:05 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160554euoutp02352e90175932fadc3fd80dd77f1517f4~8rSf7zsg82851128511euoutp02d for ; Sat, 10 Oct 2020 16:05:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201010160554euoutp02352e90175932fadc3fd80dd77f1517f4~8rSf7zsg82851128511euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345954; bh=1Px3vlBp24aI4tqkdpolnyQ52wyBpb+Nn7D22MHq1OM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IiILemNr8Clr1RGh2X9RkpsZKcOj4rzTvPLWXlawqBullonAgLzFXlML8NL5g6y9N M0GyhCLYSjD+h74lIf1SY9EFghMk+tiMWktht3Udly64im8on09y5ZMJ66I80u82ip z0L1MuoihJhX259XV/2c500p6sUNJtgobeqyQJk4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160549eucas1p15a1e63cdb2be4b8244f292771a2aa95b~8rSa9GhZ62245522455eucas1p1z; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 09.58.05997.DDBD18F5; Sat, 10 Oct 2020 17:05:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160548eucas1p193e4f234da1005b91f22a8e7cb1d3226~8rSZ2Uys82447124471eucas1p1w; Sat, 10 Oct 2020 16:05:48 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160548eusmtrp259b02094948d8c231ed32cbafee7532b~8rSZ11IyE1692616926eusmtrp2K; Sat, 10 Oct 2020 16:05:48 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-85-5f81dbddbca4 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 16.5A.06314.CDBD18F5; Sat, 10 Oct 2020 17:05:48 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160543eusmtip15ff2281e22eca8b72926e1d9f4832f8d~8rSVvhZG72442224422eusmtip16; Sat, 10 Oct 2020 16:05:42 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:03 +0200 Message-Id: <20201010160508.19709-13-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87p3bzfGG7yby2dxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBnbV89g LFjBVbHl7nm2BsZVHF2Mn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awkXj/+zAZiswioSpxZsResnFfATWLtMQ+I 8fISqzccACvnBAqf7ToItaqRUeLE7ZtsExj5FjAyrGIUSS0tzk3PLTbUK07MLS7NS9dLzs/d xAgMxG3Hfm7ewXhpY/AhRgEORiUeXolTjfFCrIllxZW5hxglOJiVRHidzp6OE+JNSaysSi3K jy8qzUktPsRoCnTURGYp0eR8YJTklcQbmhqaW1gamhubG5tZKInzdggcjBESSE8sSc1OTS1I LYLpY+LglGpgNPJv+XS0TfBxwYnyuJd+XNLy1/Zz99w3cWhdJZi+RnvG26/c6wyuPV63cNG2 eRd2Tmb/GfRjRs+u3j8h8T+Xa903DDC7HBDtdnHmF9a9K6Y1Kv9rnaRVIrIpTu9s2WHjWfFi UxO9+pbOlZKQ+ffvQ3iGzCfFyraZRfaxQku2NvNM2LmOY4GksRJLcUaioRZzUXEiAOyty1Ja AgAA X-CMS-MailID: 20201010160548eucas1p193e4f234da1005b91f22a8e7cb1d3226 X-Msg-Generator: CA X-RootMTR: 20201010160548eucas1p193e4f234da1005b91f22a8e7cb1d3226 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160548eucas1p193e4f234da1005b91f22a8e7cb1d3226 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 12/16] distributor: fix scalar matching 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" Fix improper indexes while comparing tags. In the find_match_scalar() function: * j iterates over flow tags of following packets; * w iterates over backlog or in flight tags positions. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 9fd7dcab7..4bd23a990 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -261,13 +261,13 @@ find_match_scalar(struct rte_distributor *d, for (j = 0; j < RTE_DIST_BURST_SIZE ; j++) for (w = 0; w < RTE_DIST_BURST_SIZE; w++) - if (d->in_flight_tags[i][j] == data_ptr[w]) { + if (d->in_flight_tags[i][w] == data_ptr[j]) { output_ptr[j] = i+1; break; } for (j = 0; j < RTE_DIST_BURST_SIZE; j++) for (w = 0; w < RTE_DIST_BURST_SIZE; w++) - if (bl->tags[j] == data_ptr[w]) { + if (bl->tags[w] == data_ptr[j]) { output_ptr[j] = i+1; break; } From patchwork Sat Oct 10 16:05:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80289 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4525BA04B1; Sat, 10 Oct 2020 18:11:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 677E11D98C; Sat, 10 Oct 2020 18:06:10 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 78B821D985 for ; Sat, 10 Oct 2020 18:06:07 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160556euoutp01c9669eb2bcfa8446f2257d47187551dc~8rShdquNL0390103901euoutp01b for ; Sat, 10 Oct 2020 16:05:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160556euoutp01c9669eb2bcfa8446f2257d47187551dc~8rShdquNL0390103901euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345956; bh=H0SESRE59ofq6tEaPxg1A+VKjAU63AAfipdXXlkRUGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frqCnbWB6465RhP6Z30BN4evTnSPQhntNGJtmDeGgUHmmR4QPC64tiJTARpum6MyX QD1Q/B2eXxmClXV/msUH5c7U2bG+wVc9gWAArW39cmFVOW10bExYcfy/p6Jr2XFsN1 /ZZ2dR1ztdI+naf9rSDVHsCmEw3Xc71/1pee1EJA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160550eucas1p24c6ed170991c97970e51a34227f92229~8rScSSU9T1926019260eucas1p2M; Sat, 10 Oct 2020 16:05:50 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B7.E6.06456.EDBD18F5; Sat, 10 Oct 2020 17:05:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3~8rSbO-ncA2440724407eucas1p1w; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160549eusmtrp2e4e0502a459c5f5a86ce225266a34606~8rSbOg3W31692616926eusmtrp2L; Sat, 10 Oct 2020 16:05:49 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-36-5f81dbde7634 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 7B.A6.06017.DDBD18F5; Sat, 10 Oct 2020 17:05:49 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160549eusmtip10b863759f74b3e670f318c9a8f7e98d3~8rSavPer92972929729eusmtip1C; Sat, 10 Oct 2020 16:05:48 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Sat, 10 Oct 2020 18:05:04 +0200 Message-Id: <20201010160508.19709-14-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrAIsWRmVeSWpSXmKPExsWy7djPc7r3bjfGGyycoWvRN+kjk8W7T9uZ LJ71rGN0YPb4tWApq8fiPS+ZPA6+28MUwBzFZZOSmpNZllqkb5fAlfHuxSG2gsNaFau2nGZr YNyq2MXIySEhYCJx7uQhpi5GLg4hgRWMEnPv9DFCOF8YJXb+38oC4XxmlHh66z0LTEvrkxPs EInljBInDk9mhXA+MUrsWzYbrIpNwFbiyMyvrCC2iICqxL/9n5hAbGYBI4mX3ROZQWxhAU+J W3uOg9ksQDV/Zy5jBLF5Bdwk3ryfxAqxTV5i9YYDYDWcQPGzXQfZQJZJCBxhkzh+aB8TRJGL xJxt66FsYYlXx7ewQ9gyEv93zmeCaNjGKHH1909GCGc/o8T13hVQVdYSh//9BhrLAXSepsT6 XfoQYUeJlT97GUHCEgJ8EjfeCkI8wCcxadt0Zogwr0RHmxBEtZ7E056pjDBr/6x9Ag0tD4l3 XxeyQQLoKqPE8Yt9rBMY5WchLFvAyLiKUTy1tDg3PbXYMC+1XK84Mbe4NC9dLzk/dxMjMN5P /zv+aQfj10tJhxgFOBiVeHgPHG+MF2JNLCuuzD3EKMHBrCTC63T2dJwQb0piZVVqUX58UWlO avEhRmkOFiVxXuNFL2OFBNITS1KzU1MLUotgskwcnFINjPw/N3Xo3K4W5P7QHR5Q+CpPzv3r lftzv9xO49lvftMyKUb2mfAMX6tn7cVFzLzXoxUP7n/1IuD6upQD5feYylt/8f+yZ3kUdy09 +PwqY4UZaflTfm5SL7s2h0lKZlJztNvpV8uDP7/ZbRa2R/DCm81rP8Y/kiio/hFfmMlya+VZ 0Z2tvxVWTFFiKc5INNRiLipOBABQF03j8wIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrALMWRmVeSWpSXmKPExsVy+t/xu7p3bzfGGxxZrWzRN+kjk8W7T9uZ LJ71rGN0YPb4tWApq8fiPS+ZPA6+28MUwBylZ1OUX1qSqpCRX1xiqxRtaGGkZ2hpoWdkYqln aGwea2VkqqRvZ5OSmpNZllqkb5egl/HuxSG2gsNaFau2nGZrYNyq2MXIySEhYCLR+uQEexcj F4eQwFJGicaDX4AcDqCEjMSHSwIQNcISf651sUHUfGCU+LtvPitIgk3AVuLIzK9gtoiAqsS/ /Z+YQGxmoKG35zWxgdjCAp4St/YcZwaxWYBq/s5cxghi8wq4Sbx5P4kVYoG8xOoNB8BqOIHi Z7sOQi1rZJQ4cfsm2wRGvgWMDKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzECQ2/bsZ9bdjB2 vQs+xCjAwajEwytxqjFeiDWxrLgy9xCjBAezkgiv09nTcUK8KYmVValF+fFFpTmpxYcYTYGu msgsJZqcD4yLvJJ4Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjLpJ W/7/uX4yPM1h4ZrG2PxpTss/7LGb76Ij59kV8CsqQOxi/f/H9yMf3/u54tkO1+j36vfnVE6V FKmTUt8y88S3n8mNgRwTBTv+shs8YSudaMTHema61kqHZx0yWtKHHZd4b5xQKs/12e9j8a62 8kN1GWuPvlxY9OiXyJ5X1w9WvDLX/HTv3x0lluKMREMt5qLiRAAyyoLSUwIAAA== X-CMS-MailID: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 X-Msg-Generator: CA X-RootMTR: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160549eucas1p1eba7cb8e4e9ba9200e9cd498137848c3 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 13/16] test/distributor: add test with packets marking 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" All of the former tests analyzed only statistics of packets processed by all workers. The new test verifies also if packets are processed on workers as expected. Every packets processed by the worker is marked and analyzed after it is returned to distributor. This test allows finding issues in matching algorithms. Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 141 ++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index e8dd75078..4fc10b3cc 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -542,6 +542,141 @@ test_flush_with_worker_shutdown(struct worker_params *wp, return 0; } +static int +handle_and_mark_work(void *arg) +{ + struct rte_mbuf *buf[8] __rte_cache_aligned; + struct worker_params *wp = arg; + struct rte_distributor *db = wp->dist; + unsigned int num, i; + unsigned int id = __atomic_fetch_add(&worker_idx, 1, __ATOMIC_RELAXED); + num = rte_distributor_get_pkt(db, id, buf, NULL, 0); + while (!quit) { + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); + for (i = 0; i < num; i++) + buf[i]->udata64 += id + 1; + num = rte_distributor_get_pkt(db, id, + buf, buf, num); + } + __atomic_fetch_add(&worker_stats[id].handled_packets, num, + __ATOMIC_RELAXED); + rte_distributor_return_pkt(db, id, buf, num); + return 0; +} + +/* sanity_mark_test sends packets to workers which mark them. + * Every packet has also encoded sequence number. + * The returned packets are sorted and verified if they were handled + * by proper workers. + */ +static int +sanity_mark_test(struct worker_params *wp, struct rte_mempool *p) +{ + const unsigned int buf_count = 24; + const unsigned int burst = 8; + const unsigned int shift = 12; + const unsigned int seq_shift = 10; + + struct rte_distributor *db = wp->dist; + struct rte_mbuf *bufs[buf_count]; + struct rte_mbuf *returns[buf_count]; + unsigned int i, count, id; + unsigned int sorted[buf_count], seq; + unsigned int failed = 0; + + printf("=== Marked packets test ===\n"); + clear_packet_count(); + if (rte_mempool_get_bulk(p, (void *)bufs, buf_count) != 0) { + printf("line %d: Error getting mbufs from pool\n", __LINE__); + return -1; + } + + /* bufs' hashes will be like these below, but shifted left. + * The shifting is for avoiding collisions with backlogs + * and in-flight tags left by previous tests. + * [1, 1, 1, 1, 1, 1, 1, 1 + * 1, 1, 1, 1, 2, 2, 2, 2 + * 2, 2, 2, 2, 1, 1, 1, 1] + */ + for (i = 0; i < burst; i++) { + bufs[0 * burst + i]->hash.usr = 1 << shift; + bufs[1 * burst + i]->hash.usr = ((i < burst / 2) ? 1 : 2) + << shift; + bufs[2 * burst + i]->hash.usr = ((i < burst / 2) ? 2 : 1) + << shift; + } + /* Assign a sequence number to each packet. The sequence is shifted, + * so that lower bits of the udate64 will hold mark from worker. + */ + for (i = 0; i < buf_count; i++) + bufs[i]->udata64 = i << seq_shift; + + count = 0; + for (i = 0; i < buf_count/burst; i++) { + rte_distributor_process(db, &bufs[i * burst], burst); + count += rte_distributor_returned_pkts(db, &returns[count], + buf_count - count); + } + + do { + rte_distributor_flush(db); + count += rte_distributor_returned_pkts(db, &returns[count], + buf_count - count); + } while (count < buf_count); + + 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, + __ATOMIC_RELAXED)); + + /* Sort returned packets by sent order (sequence numbers). */ + for (i = 0; i < buf_count; i++) { + seq = returns[i]->udata64 >> seq_shift; + id = returns[i]->udata64 - (seq << seq_shift); + sorted[seq] = id; + } + + /* Verify that packets [0-11] and [20-23] were processed + * by the same worker + */ + for (i = 1; i < 12; i++) { + if (sorted[i] != sorted[0]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[0]); + failed = 1; + } + } + for (i = 20; i < 24; i++) { + if (sorted[i] != sorted[0]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[0]); + failed = 1; + } + } + /* And verify that packets [12-19] were processed + * by the another worker + */ + for (i = 13; i < 20; i++) { + if (sorted[i] != sorted[12]) { + printf("Packet number %u processed by worker %u," + " but should be processes by worker %u\n", + i, sorted[i], sorted[12]); + failed = 1; + } + } + + rte_mempool_put_bulk(p, (void *)bufs, buf_count); + + if (failed) + return -1; + + printf("Marked packets test passed\n"); + return 0; +} + static int test_error_distributor_create_name(void) { @@ -726,6 +861,12 @@ test_distributor(void) goto err; quit_workers(&worker_params, p); + rte_eal_mp_remote_launch(handle_and_mark_work, + &worker_params, SKIP_MASTER); + if (sanity_mark_test(&worker_params, p) < 0) + goto err; + quit_workers(&worker_params, p); + } else { printf("Too few cores to run worker shutdown test\n"); } From patchwork Sat Oct 10 16:05:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80290 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D4B6A04B1; Sat, 10 Oct 2020 18:11:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E0CEA1D991; Sat, 10 Oct 2020 18:06:11 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id E5CE91D98C for ; Sat, 10 Oct 2020 18:06:07 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160557euoutp012ab5c517d1e142686510370294965047~8rSi1aF520392303923euoutp01U for ; Sat, 10 Oct 2020 16:05:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160557euoutp012ab5c517d1e142686510370294965047~8rSi1aF520392303923euoutp01U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345957; bh=v4SHqhfr0CgQSyQySuuoqmQz3Fqbg8VL6UkTHS7IUM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SHQ2LCl9mtBXgiTDFsFwcSjThEXjMTpDXP8O6/+i2k4BsN3ST1ZRg1/SxSvMgk7nF ZFJmi8li1eT2rPOQHFUMJHTsiKxbKL6FfO3DtKNMO52/GqJr40zikQkTda9SUwAcrF uNSh7ZTwpaaDiJTRrLTbr3DCPoCvRr3ViiWukqQw= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160552eucas1p25c6bf7f21941fa98606d9cfdf780ad11~8rSd0qC4L0269602696eucas1p2p; Sat, 10 Oct 2020 16:05:52 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 10.C2.06318.0EBD18F5; Sat, 10 Oct 2020 17:05:52 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160551eucas1p171642aa2d451e501287915824bfe7c24~8rScvNAaP2418924189eucas1p12; Sat, 10 Oct 2020 16:05:51 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160551eusmtrp22154b66bac14e4df879548d3fe68ca77~8rScujhNj1692616926eusmtrp2M; Sat, 10 Oct 2020 16:05:51 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-dc-5f81dbe0ed3e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 76.5A.06314.FDBD18F5; Sat, 10 Oct 2020 17:05:51 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160550eusmtip18b17ec1327e97c5c3dd6d499ae70e3c2~8rSb8Y5n-2442224422eusmtip17; Sat, 10 Oct 2020 16:05:50 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:05 +0200 Message-Id: <20201010160508.19709-15-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djPc7oPbjfGG2xsE7O4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroxpT3qY Cm4JVZy94NnAuJ2/i5GTQ0LARGLZhX6mLkYuDiGBFYwSx39uZIZwvjBKNOzfzwRSJSTwmVFi /9IKmI57nZfZIIqWM0rMPbwFquMTo8TVyw/ZQarYBGwljsz8ygpiiwiESTQ372XpYuTgYBZw lnjylQ0kLCzgKnH58ROwchYBVYnrL8+D2bwCbhLTJrSzQiyTl1i94QAziM0JFD/bdZANIn6G TeLNrFQI20XiyIuFLBC2sMSr41vYIWwZif8754O9JiGwDei23z8ZIZz9jBLXe1dAVVlLHP73 mw3iOE2J9bv0IcKOEt/arrOChCUE+CRuvBUECTMDmZO2TWeGCPNKdLQJQVTrSTztmcoIs/bP 2idQ53hIdP+/xw4JnquMEqu+tzJOYJSfhbBsASPjK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TKiraf69o7tKxiYhLrTjJK8PjxW +v9L5vK1bKucekGNCeZCB3+nrD5krNlYv/Ja5qwc/dtiSizFGYmGWsxFxYkA8Ccf+VoCAAA= X-CMS-MailID: 20201010160551eucas1p171642aa2d451e501287915824bfe7c24 X-Msg-Generator: CA X-RootMTR: 20201010160551eucas1p171642aa2d451e501287915824bfe7c24 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160551eucas1p171642aa2d451e501287915824bfe7c24 References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 14/16] distributor: fix flushing in flight packets 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" rte_distributor_flush() is using total_outstanding() function to calculate if it should still wait for processing packets. However in burst mode only backlog packets were counted. This patch fixes that issue by counting also in flight packets. There are also sum fixes to properly keep count of in flight packets for each worker in bufs[].count. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 4bd23a990..2478de3b7 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -467,6 +467,7 @@ rte_distributor_process(struct rte_distributor *d, /* Sync with worker on GET_BUF flag. */ if (__atomic_load_n(&(d->bufs[wid].bufptr64[0]), __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF) { + d->bufs[wid].count = 0; release(d, wid); handle_returns(d, wid); } @@ -481,11 +482,6 @@ rte_distributor_process(struct rte_distributor *d, uint16_t matches[RTE_DIST_BURST_SIZE]; unsigned int pkts; - /* Sync with worker on GET_BUF flag. */ - if (__atomic_load_n(&(d->bufs[wkr].bufptr64[0]), - __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF) - d->bufs[wkr].count = 0; - if ((num_mbufs - next_idx) < RTE_DIST_BURST_SIZE) pkts = num_mbufs - next_idx; else @@ -605,8 +601,10 @@ rte_distributor_process(struct rte_distributor *d, for (wid = 0 ; wid < d->num_workers; wid++) /* Sync with worker on GET_BUF flag. */ if ((__atomic_load_n(&(d->bufs[wid].bufptr64[0]), - __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF)) + __ATOMIC_ACQUIRE) & RTE_DISTRIB_GET_BUF)) { + d->bufs[wid].count = 0; release(d, wid); + } return num_mbufs; } @@ -649,7 +647,7 @@ total_outstanding(const struct rte_distributor *d) unsigned int wkr, total_outstanding = 0; for (wkr = 0; wkr < d->num_workers; wkr++) - total_outstanding += d->backlog[wkr].count; + total_outstanding += d->backlog[wkr].count + d->bufs[wkr].count; return total_outstanding; } From patchwork Sat Oct 10 16:05:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80291 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7D05CA04B1; Sat, 10 Oct 2020 18:11:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D677C1D999; Sat, 10 Oct 2020 18:06:15 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 9128D1D995 for ; Sat, 10 Oct 2020 18:06:12 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160601euoutp01a38eee3e9bd0898b040cb71a550169fe~8rSmNUZ910392303923euoutp01V for ; Sat, 10 Oct 2020 16:06:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160601euoutp01a38eee3e9bd0898b040cb71a550169fe~8rSmNUZ910392303923euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345961; bh=OZZGi7agIbDWlz1FwjrRd3zGTVW3Tz6nh33nggujM50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZ+vHdPX04epD3JGhohmZhU4E7gknAPcTQhefLO6/zmeJWN9fitQaTwO92/LneJTJ KLRvGGoI7lMi3/BTSCSVDqmsPGLw01RUcLyHZ+v4WlnbrLpBBPA1hTTHMW+UtP/T9P 9Ln+XO17WyARw8DabBTydbHXfKmXEB3n622yd/hY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160554eucas1p18625275e71e5af4798b6b79832ce659e~8rSfXAM7f2308623086eucas1p1x; Sat, 10 Oct 2020 16:05:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F7.E6.06456.1EBD18F5; Sat, 10 Oct 2020 17:05:54 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201010160552eucas1p2efdec872c4aea2b63af29c84e9a5b52d~8rSeUbayO1129911299eucas1p21; Sat, 10 Oct 2020 16:05:52 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160552eusmtrp2864e3e9bfc65218b991b16e219633416~8rSeT4xCS1692616926eusmtrp2P; Sat, 10 Oct 2020 16:05:52 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-3a-5f81dbe1e736 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D6.5A.06314.0EBD18F5; Sat, 10 Oct 2020 17:05:52 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160551eusmtip1b95b513675558ef6ff5e25b1fdae482b~8rSdY0cb72972929729eusmtip1D; Sat, 10 Oct 2020 16:05:51 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 18:05:06 +0200 Message-Id: <20201010160508.19709-16-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7qPbjfGG2zbwWhxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBn7X2xl KzjCXjF532L2BsadbF2MnBwSAiYSE7b8ZOxi5OIQEljBKHG1ZT8rhPOFUWLal8csEM5nRonL bY3sMC1TT5+BSixnlJjUPI8ZwvnEKHFjZS8rSBWbgK3EkZlfwWwRgTCJ5ua9QB0cHMwCzhJP voLtFhZwkuj9vx+shEVAVaL/2jtmEJtXwE2i7/1XqGXyEqs3HACLcwLFz3YdZAPZJSFwmU2i p/8qI0SRi0TH60lQDcISr45vgbJlJP7vnM8E0bAN6LnfEJ9KCOxnlLjeuwKqylri8L/fbBDX aUqs36UPEXaU+P/vEztIWEKAT+LGW0GQMDOQOWnbdGaIMK9ER5sQRLWexNOeqYwwa/+sfcIC YXtIzDswkQkSPlcZJdoaFzJPYJSfhbBsASPjKkbx1NLi3PTUYsO81HK94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0KG4c3V1RNUehKm5IeJH9DXixfTX9zFN+nWwfNeK/ZzqSmxFGckGmoxFxUnAgBh1UOoWgIA AA== X-CMS-MailID: 20201010160552eucas1p2efdec872c4aea2b63af29c84e9a5b52d X-Msg-Generator: CA X-RootMTR: 20201010160552eucas1p2efdec872c4aea2b63af29c84e9a5b52d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160552eucas1p2efdec872c4aea2b63af29c84e9a5b52d References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 15/16] distributor: fix clearing returns buffer 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" The patch clears distributors returns buffer in clear_returns() by setting start and count to 0. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- lib/librte_distributor/rte_distributor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 2478de3b7..57240304a 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -704,6 +704,8 @@ rte_distributor_clear_returns(struct rte_distributor *d) /* Sync with worker. Release retptrs. */ __atomic_store_n(&(d->bufs[wkr].retptr64[0]), 0, __ATOMIC_RELEASE); + + d->returns.start = d->returns.count = 0; } /* creates a distributor instance */ From patchwork Sat Oct 10 16:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 80292 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0265BA04B1; Sat, 10 Oct 2020 18:12:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 304EE1D8FD; Sat, 10 Oct 2020 18:06:24 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id DBCEB1D905 for ; Sat, 10 Oct 2020 18:06:22 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160611euoutp013f30be796059d454617450623ebb633a~8rSvz2qAG0381003810euoutp01j for ; Sat, 10 Oct 2020 16:06:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160611euoutp013f30be796059d454617450623ebb633a~8rSvz2qAG0381003810euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345971; bh=QLPUD9KOQYFHJXu7SCPKNy9u0rZMb6AcEwQp21bwlhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYiBXNIid3zX86zkPmGGvzpXplnlziIMVX930yGeeQmRsXm2TeiFzP4S6Dts+fOn6 neuhc9jChsRSrhIMPnpInLtaoRvKx5pScTtXTxY4927vKC3qYWD7YOmWIPGmD2cZvU oPCVKf+vOTsXdM7NoWVRg+G+twS/R45mC4nrfbJ4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201010160606eucas1p2518fa1c12ebf0b262f7362a4425ffd94~8rSqwCeQF0179501795eucas1p2w; Sat, 10 Oct 2020 16:06:06 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id EA.58.05997.EEBD18F5; Sat, 10 Oct 2020 17:06:06 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160605eucas1p1ff6b4cb5065e1355cb8eeafd4696abaf~8rSqDeZk92439624396eucas1p12; Sat, 10 Oct 2020 16:06:05 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201010160605eusmtrp1818a0a39442cc34ab2b5e89daa6c49d8~8rSqC8rOh2920229202eusmtrp10; Sat, 10 Oct 2020 16:06:05 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-9a-5f81dbee371f Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E7.5A.06314.DEBD18F5; Sat, 10 Oct 2020 17:06:05 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160554eusmtip17edb86a0f5afdbb94e6fc8f9b481f36c~8rSfW8EUO2972929729eusmtip1E; Sat, 10 Oct 2020 16:05:53 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Sat, 10 Oct 2020 18:05:07 +0200 Message-Id: <20201010160508.19709-17-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsWy7djP87rvbjfGG7Ts5Lfom/SRyeLdp+1M Fs961jE6MHv8WrCU1WPxnpdMHgff7WEKYI7isklJzcksSy3St0vgyphylb+gQbGi9cwJtgbG W1JdjJwcEgImEo/utzJ2MXJxCAmsYJTYOfUPlPOFUWL6usnMEM5nRokjC7aydDFygLVcvi0D EV/OKPGgdworhPOJUWLK0RXMIHPZBGwljsz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TswtLs1L10vOz93ECAy7bcd+bt7BeGlj 8CFGAQ5GJR5eiVON8UKsiWXFlbmHGCU4mJVEeJ3Ono4T4k1JrKxKLcqPLyrNSS0+xGgKdNVE ZinR5HxgTOSVxBuaGppbWBqaG5sbm1koifN2CByMERJITyxJzU5NLUgtgulj4uCUamAUtXu/ JiR7uvPhiKV+Uy4Y2c/k+f33DPfn3kl2xfM2f9l0avo3lVef22asbfkw84zV2Sn8Twp70tzX 7T33LbxwQsXVNde1nB563cwMLNZbYP7oV2tBoM/8dR+/aQieOnZc0LOncM/lfjup8PxDjpGG gWueii4r3tLd877kj+qDd99iOXNdfxjrK7EUZyQaajEXFScCACV3Zl1RAgAA X-CMS-MailID: 20201010160605eucas1p1ff6b4cb5065e1355cb8eeafd4696abaf X-Msg-Generator: CA X-RootMTR: 20201010160605eucas1p1ff6b4cb5065e1355cb8eeafd4696abaf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160605eucas1p1ff6b4cb5065e1355cb8eeafd4696abaf References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v7 16/16] test/distributor: ensure all packets are delivered 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" In all distributor tests there is a chance that tests will send packets to distributor with rte_distributor_process() before workers are started and requested for packets. This patch ensures that all packets are delivered to workers by calling rte_distributor_process() in loop until number of successfully processed packets reaches required by test. Change is applied to every first call in test case. Signed-off-by: Lukasz Wojciechowski Acked-by: David Hunt --- app/test/test_distributor.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 4fc10b3cc..3c56358d4 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -103,6 +103,7 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) struct rte_mbuf *returns[BURST*2]; unsigned int i, count; unsigned int retries; + unsigned int processed; printf("=== Basic distributor sanity tests ===\n"); clear_packet_count(); @@ -116,7 +117,11 @@ sanity_test(struct worker_params *wp, struct rte_mempool *p) for (i = 0; i < BURST; i++) bufs[i]->hash.usr = 0; - rte_distributor_process(db, bufs, BURST); + processed = 0; + while (processed < BURST) + processed += rte_distributor_process(db, &bufs[processed], + BURST - processed); + count = 0; do { @@ -304,6 +309,7 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) struct rte_distributor *d = wp->dist; unsigned i; struct rte_mbuf *bufs[BURST]; + unsigned int processed; printf("=== Sanity test with mbuf alloc/free (%s) ===\n", wp->name); @@ -316,7 +322,10 @@ sanity_test_with_mbuf_alloc(struct worker_params *wp, struct rte_mempool *p) bufs[j]->hash.usr = (i+j) << 1; } - rte_distributor_process(d, bufs, BURST); + processed = 0; + while (processed < BURST) + processed += rte_distributor_process(d, + &bufs[processed], BURST - processed); } rte_distributor_flush(d); @@ -409,6 +418,7 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, struct rte_mbuf *bufs2[BURST]; unsigned int i; unsigned int failed = 0; + unsigned int processed = 0; printf("=== Sanity test of worker shutdown ===\n"); @@ -426,7 +436,10 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, for (i = 0; i < BURST; i++) bufs[i]->hash.usr = 1; - rte_distributor_process(d, bufs, BURST); + processed = 0; + while (processed < BURST) + processed += rte_distributor_process(d, &bufs[processed], + BURST - processed); rte_distributor_flush(d); /* at this point, we will have processed some packets and have a full @@ -488,6 +501,7 @@ test_flush_with_worker_shutdown(struct worker_params *wp, struct rte_mbuf *bufs[BURST]; unsigned int i; unsigned int failed = 0; + unsigned int processed; printf("=== Test flush fn with worker shutdown (%s) ===\n", wp->name); @@ -502,7 +516,10 @@ test_flush_with_worker_shutdown(struct worker_params *wp, for (i = 0; i < BURST; i++) bufs[i]->hash.usr = 0; - rte_distributor_process(d, bufs, BURST); + processed = 0; + while (processed < BURST) + processed += rte_distributor_process(d, &bufs[processed], + BURST - processed); /* at this point, we will have processed some packets and have a full * backlog for the other ones at worker 0. */ @@ -584,6 +601,7 @@ sanity_mark_test(struct worker_params *wp, struct rte_mempool *p) unsigned int i, count, id; unsigned int sorted[buf_count], seq; unsigned int failed = 0; + unsigned int processed; printf("=== Marked packets test ===\n"); clear_packet_count(); @@ -614,7 +632,11 @@ sanity_mark_test(struct worker_params *wp, struct rte_mempool *p) count = 0; for (i = 0; i < buf_count/burst; i++) { - rte_distributor_process(db, &bufs[i * burst], burst); + processed = 0; + while (processed < burst) + processed += rte_distributor_process(db, + &bufs[i * burst + processed], + burst - processed); count += rte_distributor_returned_pkts(db, &returns[count], buf_count - count); }