From patchwork Thu Oct 8 05:23:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79970 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 4D128A04BC; Thu, 8 Oct 2020 07:23:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A94BE1B67B; Thu, 8 Oct 2020 07:23:40 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A7B935F13 for ; Thu, 8 Oct 2020 07:23:39 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052338euoutp026822e799c625439c94bb764eea4bf397~77PJoUBBW0526205262euoutp02f for ; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052338euoutp026822e799c625439c94bb764eea4bf397~77PJoUBBW0526205262euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134618; bh=yH3M1Cb4L5UauMPb4vqNmQJysLFgOKEd5bHi5VjtoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GUFXII41bW1J9wMa9IRiSB23F4ik5zRDsGO9T3WPdXJKB0ggqy9Tymv0dB3/D1acP X0CcAThZM1NMKbsCPrWJtUSKuAmmgPAKoFfrsmbTw9nru4yh1E2y/dZB+3FkZt4aWS iQax3UOWAHK1nm7fv6qjkIO9GiOUClh99IuVBoW4= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052337eucas1p142250dc709e80a02f50e11ce42e5c834~77PI38SPJ3161431614eucas1p1f; Thu, 8 Oct 2020 05:23:37 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 51.01.05997.952AE7F5; Thu, 8 Oct 2020 06:23:37 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052337eucas1p22b9e89987caf151ba8771442385fec16~77PIl5yrl2346723467eucas1p2y; Thu, 8 Oct 2020 05:23:37 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052337eusmtrp188f3839c05f1a92e680f4e9753793053~77PIlQ8pb2941529415eusmtrp1O; Thu, 8 Oct 2020 05:23:37 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-61-5f7ea259ab83 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 4B.F0.06017.952AE7F5; Thu, 8 Oct 2020 06:23:37 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052336eusmtip16dc79853a183229f19ec26516d6b3668~77PH-2HZh2484324843eusmtip1i; Thu, 8 Oct 2020 05:23:36 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:09 +0200 Message-Id: <20201008052323.11547-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7qRi+riDbZPlbW4screom/SRyaL d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F2MXBxCAksZJT51NwE5HEAJGYkPlwQgaoQl/lzrgqr5wChx+c9XFpAEm4CtxJGZ X1lB6kUEwiROrPQHCTMLuEtsWTyVGcQWFvCR+P99B5jNIqAq8XHLQXYQm1fAVeLr3gVsEPPl JVZvOABWwyngJnH2/11WiF2NjBI3z89km8DIt4CRYRWjSGppcW56brGRXnFibnFpXrpecn7u JkZgKG479nPLDsaud8GHGAU4GJV4eA2O1sYLsSaWFVfmHmKU4GBWEuF1Ons6Tog3JbGyKrUo P76oNCe1+BCjKdBVE5mlRJPzgXGSVxJvaGpobmFpaG5sbmxmoSTO2yFwMEZIID2xJDU7NbUg tQimj4mDU6qB8UYFy3mXWWxH2Tpff2PqUOWuaAudrXlsX//jNRe7auLrfPn/eum75K2snGT1 adMuk6eGJQdvBHWqJRcv6L22a+m07IsfenmNX8//xLFV7X6uWaLnD1PdhU7vQiql8mUEfrU1 CKWonDZ4NW/pcT23N0n/OW54pP/n+yT/jGP9/uCVm2TPSEd/UGIpzkg01GIuKk4EAApM4cVb AgAA X-CMS-MailID: 20201008052337eucas1p22b9e89987caf151ba8771442385fec16 X-Msg-Generator: CA X-RootMTR: 20201008052337eucas1p22b9e89987caf151ba8771442385fec16 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052337eucas1p22b9e89987caf151ba8771442385fec16 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 01/15] 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 Thu Oct 8 05:23:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79972 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 1D5B1A04C0; Thu, 8 Oct 2020 07:24:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5268F1B6F3; Thu, 8 Oct 2020 07:23:45 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 90A035F13 for ; Thu, 8 Oct 2020 07:23:40 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052339euoutp02b82fbcc7c8cdbe23a592ef5ec6f12e69~77PKljC0S0526205262euoutp02g for ; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052339euoutp02b82fbcc7c8cdbe23a592ef5ec6f12e69~77PKljC0S0526205262euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134619; bh=vuwpOk5DYAg8nrtQAkN6Jx3ymyd0V4eE98pnCakaiTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tMCmtLEPPo0Ku+1gSCvSGgDRN6tJC0N8tSCzPssnt+Q7hcC/p1UYLi/S+u4s/e1yR KlqWL3firj60hvf+fpykHNOxHTF6l5kBcmvkCQdSY1baGoFJis8974I3vBP9i/L9rI CXaiFtdCDPWCPwyxRryKp/Vlcx/BAWVh+ErTZSFc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052339eucas1p14c357f34fcf9f44008f7f99979ab5791~77PKY7YWE1098510985eucas1p1J; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5D.9D.06318.A52AE7F5; Thu, 8 Oct 2020 06:23:39 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052338eucas1p2d26a8705b17d07fd24056f0aeaf3504e~77PJVib2J2348123481eucas1p25; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052338eusmtrp1929294c410306fd9294694ce0dea1d87~77PJU8nLA2941529415eusmtrp1P; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-a5-5f7ea25ac114 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AB.F0.06017.952AE7F5; Thu, 8 Oct 2020 06:23:37 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052337eusmtip1ddc458dcd0a56213c8bb53ec9f988667~77PIuEB7N2786627866eusmtip1Y; Thu, 8 Oct 2020 05:23:37 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:10 +0200 Message-Id: <20201008052323.11547-3-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7rRi+riDR6cZbK4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroy9U+Yy FhwRrLj88ihjA+Mhvi5GTg4JAROJP/+uMncxcnEICaxglPjUuZsJwvnCKPHm6x02COczo8Tv LwcZuxg5wFpe33WHiC9nlGj6/4QdwvnEKHHh4HomkLlsArYSR2Z+ZQWxRQTCJJqb97KANDML OEs8+coGEhYGKlnf9xushEVAVeLmnkuMIDavgKvEjsknmCDOk5dYveEAM4jNKeAmcfb/XVaQ XRICl9kkmt/sY4UocpE4+34eM4QtLPHq+BZ2CFtG4vTkHhaIhm2MEld//2SEcPYzSlzvXQFV ZS1x+N9vNojrNCXW79KHCDtKXP80hRXiYz6JG28FQcLMQOakbdOZIcK8Eh1tQhDVehJPe6Yy wqz9s/YJC4TtIfFy/yFo8F5llJj8poV5AqP8LIRlCxgZVzGKp5YW56anFhvnpZbrFSfmFpfm pesl5+duYgRG/+l/x7/uYNz3J+kQowAHoxIPr8HR2ngh1sSy4srcQ4wSHMxKIrxOZ0/HCfGm JFZWpRblxxeV5qQWH2KU5mBREuc1XvQyVkggPbEkNTs1tSC1CCbLxMEp1cDoMmfCmdcbO/mW Cf7YnTHn5NfXr44GnotrXqiyq+5L5qult6csj/2TsmViQdi3I63bbpl383m0rS19eLvko5H/ lOOcn/eYHPq9wEt5ypK5Mw48mfKE5ficvA8mZivWfNx63Pzxr2nOC+8/yimrvWpf98LnmGrb mfDPzFOPMtfz/13SWP8w4pdp/1YlluKMREMt5qLiRABDVM49+gIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsVy+t/xu7qRi+riDf4ssbK4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYy9U+YyFhwRrLj88ihjA+Mhvi5GDg4J AROJ13fduxi5OIQEljJK3J42iR0iLiPx4ZJAFyMnkCks8edaFxtEzQdGiWnbv7ODJNgEbCWO zPzKClIvIhAmcWKlP0iYWcBdYsviqcwgtjBQyfq+36wgNouAqsTNPZcYQWxeAVeJHZNPMEHM l5dYveEAWD2ngJvE2f93WSF2NTJK3Dw/k20CI98CRoZVjCKppcW56bnFRnrFibnFpXnpesn5 uZsYgYG47djPLTsYu94FH2IU4GBU4uE1OFobL8SaWFZcmXuIUYKDWUmE1+ns6Tgh3pTEyqrU ovz4otKc1OJDjKZAV01klhJNzgdGSV5JvKGpobmFpaG5sbmxmYWSOG+HwMEYIYH0xJLU7NTU gtQimD4mDk6pBsZpd9RvqXzy1mdNeeUaZDpfluFRcFbwq97726vy/ddbhzBnHp5SPS/yb5Ba je6ZkjCjf3vZRVNiA/5et+tPez5T4Fur86JFuikVJukTeKfeLMhjq05pTT/p4CY3y9wh4fEk E1XTU6sXzph824VZpORv79Ql+c/afbkY79TNTY/kYrV4/nfWXiWW4oxEQy3mouJEAJWqYFJa AgAA X-CMS-MailID: 20201008052338eucas1p2d26a8705b17d07fd24056f0aeaf3504e X-Msg-Generator: CA X-RootMTR: 20201008052338eucas1p2d26a8705b17d07fd24056f0aeaf3504e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052338eucas1p2d26a8705b17d07fd24056f0aeaf3504e References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 02/15] 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 Thu Oct 8 05:23:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79973 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 59958A04BC; Thu, 8 Oct 2020 07:24:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88BB21B737; Thu, 8 Oct 2020 07:23:48 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A4F831B679 for ; Thu, 8 Oct 2020 07:23:40 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052339euoutp02720ee40bdf1e5ec0f534d5a41a6ef7b9~77PKqkB_G0526205262euoutp02h for ; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052339euoutp02720ee40bdf1e5ec0f534d5a41a6ef7b9~77PKqkB_G0526205262euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134619; bh=lhQ/D+SY7TOKzAV9BiJtJFcrM6bI5dfm+5iI6rDO14c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2FYzb/YoiIopJ11jhGoDfv3NbsRM9e9a5fD+o6bVGGmaaC6t+aDkuEgvqvAaRaFl 3igqjylzY/zwYaJfaQLBhwGveEYLgJ/w9bNiZJi/VpzAxG9qW/WjcKOJV1zvS69zPX fLhpOlQ49cjWc2qDITXtQVmEyObNuAV16T4bJKzY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052339eucas1p191b68071c651775da7895f0c9955bbda~77PKiLPNe1098510985eucas1p1N; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id BD.9D.06318.B52AE7F5; Thu, 8 Oct 2020 06:23:39 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052339eucas1p1a4e571cc3f5a277badff9d352ad7da8e~77PKReoho1294612946eucas1p1B; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052338eusmtrp15bb73002c8d57d2c926ab664e5b32e53~77PKKmkVF2941529415eusmtrp1Q; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-a6-5f7ea25b43ef Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0C.F0.06017.A52AE7F5; Thu, 8 Oct 2020 06:23:38 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052338eusmtip16443939cea5066143ec1f3da2b43fc06~77PJeKsFP2964029640eusmtip1e; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:11 +0200 Message-Id: <20201008052323.11547-4-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djPc7rRi+riDeYd57W4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mA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mwCthJH Zn5lBakXEQiTOLHSHyTMLOAusWXxVGYQW1jAQ2LWrTdgNouAqsSbFTNYQWxeAVeJzsXPWSHm y0us3nAArIZTwE3i7P+7rBC7Ghklbp6fyTaBkW8BI8MqRpHU0uLc9NxiI73ixNzi0rx0veT8 3E2MwEDcduznlh2MXe+CDzEKcDAq8fAaHK2NF2JNLCuuzD3EKMHBrCTC63T2dJwQb0piZVVq UX58UWlOavEhRlOgqyYyS4km5wOjJK8k3tDU0NzC0tDc2NzYzEJJnLdD4GCMkEB6Yklqdmpq QWoRTB8TB6dUA2Omz+tFLR+MHE6c93i8yyTkRvYE0V2LT6syXrCqzYwyNzT/mhGzQr4qbm3f 1T6d7TLsf6pTBUQzbpzmP5XC0NOjyhV6eUbD4pKvSl5C9k38Gln5cyRvLg4VXBHFut6z8u+r 3ztkwjIaNr5veCPGaZVxZ27tFpWTxa6pX36v2uVzu6Fr6h1mKSWW4oxEQy3mouJEAE3phbBa AgAA X-CMS-MailID: 20201008052339eucas1p1a4e571cc3f5a277badff9d352ad7da8e X-Msg-Generator: CA X-RootMTR: 20201008052339eucas1p1a4e571cc3f5a277badff9d352ad7da8e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052339eucas1p1a4e571cc3f5a277badff9d352ad7da8e References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 03/15] 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 Thu Oct 8 05:23:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79974 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 67361A04BC; Thu, 8 Oct 2020 07:25:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F1CA41B7C0; Thu, 8 Oct 2020 07:23:51 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 10AB01B686 for ; Thu, 8 Oct 2020 07:23:41 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052340euoutp02d2ec54dbf36c43f44b9956a0a5a42715~77PL-K6uZ0628306283euoutp02D for ; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052340euoutp02d2ec54dbf36c43f44b9956a0a5a42715~77PL-K6uZ0628306283euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134620; bh=U6IhjXVsEwfcc7sBKu4x/L9REGeac99kbibJmzp3oL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRX9tI2tU6AispbGMOVKH+ol93WKcdw/a4mtRsSnYjyC85zAXbt3VKbyH4y1/SpQZ duGfbeEg5h8KNezYllCeigYYT3vKXJ6gafM6y5KHCAaCo9vHoGuxCEE8iepod+M1M0 UYqbOvwIHB6niQMQc9PyjkWRR+tN8ue+ert9DIyQ= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052340eucas1p10cb8072eb07f2c87267171a191fd9331~77PLwv-wH1098510985eucas1p1Q; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 92.01.05997.C52AE7F5; Thu, 8 Oct 2020 06:23:40 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052339eucas1p15697f457b8b96809d04f737e041af08a~77PK626JD1295112951eucas1p1D; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052339eusmtrp19605251bfa4ef0c90d79102e8718e681~77PK6Uat32941629416eusmtrp1P; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-68-5f7ea25c12d0 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8C.F0.06017.B52AE7F5; Thu, 8 Oct 2020 06:23:39 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052338eusmtip1b7ed02f4cfa5cfd0e1e9898bceacdd79~77PKOiL802484324843eusmtip1j; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:12 +0200 Message-Id: <20201008052323.11547-5-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87oxi+riDaZPVbW4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroy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XEQiTOLHSHyTMLOAusWXxVGYQW1jAW+Js31lmkBIWAVWJn1+VQcK8Aq4Sc2e3MkGM l5dYveEAWDmngJvE2f93WSFWNTJK3Dw/k20CI98CRoZVjCKppcW56bnFRnrFibnFpXnpesn5 uZsYgWG47djPLTsYu94FH2IU4GBU4uE1OFobL8SaWFZcmXuIUYKDWUmE1+ns6Tgh3pTEyqrU ovz4otKc1OJDjKZAR01klhJNzgfGSF5JvKGpobmFpaG5sbmxmYWSOG+HwMEYIYH0xJLU7NTU gtQimD4mDk6pBkatZNlDvwJ2hZbcaTb5v+bAjv3hHjdY5obMkHpeLprSYJG7+8+1IG1Lt9UO /SsKn81b2sg275Z9Sugf/kXtPRb2zTa9G1kXzLNfEr5nZ6OyUqxn2+fCts/fSpv+crazG+84 OsmrVuOfrrBh+1f/43qlm/81p+x5snLJ2i4e19VFE6wCBecbbVViKc5INNRiLipOBACvKCvM WQIAAA== X-CMS-MailID: 20201008052339eucas1p15697f457b8b96809d04f737e041af08a X-Msg-Generator: CA X-RootMTR: 20201008052339eucas1p15697f457b8b96809d04f737e041af08a X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052339eucas1p15697f457b8b96809d04f737e041af08a References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 04/15] 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 Thu Oct 8 05:23:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79975 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 8BC77A04BC; Thu, 8 Oct 2020 07:25:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F07231B819; Thu, 8 Oct 2020 07:23:54 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 6645E1B68E for ; Thu, 8 Oct 2020 07:23:42 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052341euoutp0211bfd375d50d6b5667627abd13a589eb~77PMS7zAS0628706287euoutp02B for ; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052341euoutp0211bfd375d50d6b5667627abd13a589eb~77PMS7zAS0628706287euoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134621; bh=LemR1YjnE+c23RXwEQzxMBn4x6DVQHDmQWboTCBU/MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhKFkUzZLcwTAOE3CVMhSa50njrXFEq5XmWKpE8ZWtEksMFTym1hgSIa4SBzQj6hO K27kvANSNlthAiZzo9PfFqHK+fjTp6l/IrtRigqdC9ZjOZfvxm2OvgEwFm0s3JqVBe 5hB+OvX2krz2jwyQicRBjL1S3UJk3OanHjzY1H9k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052340eucas1p1dd62d069025c86113dfb0812bed029b6~77PMEJUCH0288802888eucas1p1s; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 8F.83.06456.C52AE7F5; Thu, 8 Oct 2020 06:23:40 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052340eucas1p1451f2bf1b6475067491753274547b837~77PLvLFMN1294712947eucas1p1D; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052340eusmtrp14b8dcd0170bfc4c8909776b4b7dc609d~77PLumX8u2941629416eusmtrp1R; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-40-5f7ea25c6d01 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 66.89.06314.C52AE7F5; Thu, 8 Oct 2020 06:23:40 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052339eusmtip1f5ca171f586f79d7267b7643778b89c2~77PLAe7_H2786627866eusmtip1a; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:13 +0200 Message-Id: <20201008052323.11547-6-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87oxi+riDS5uMLO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroynz46y FJyVqji0fhNjA+N20S5GTg4JAROJDxPWMXYxcnEICaxglFj+bRsLhPOFUeLtgVdQzmdGiX/t j9hgWrb9uM4OkVjOKHHt4mso5xOjxOnG28wgVWwCthJHZn5lBbFFBMIkmpv3Ao3i4GAWcJZ4 8hVskLCAu8TjhbcZQWwWAVWJyVNnsIPYvAKuEjv29zBDLJOXWL3hAJjNKeAmcfb/XVaQXRIC 19kkznxfwgRR5CIxr3MPVIOwxKvjW9ghbBmJ05N7WCAatjFKXP39kxHC2c8ocb13BVSVtcTh f7/ZIK7TlFi/Sx8i7Cgx8c5LdpCwhACfxI23giBhZiBz0rbpzBBhXomONiGIaj2Jpz1TGWHW /ln7hAWixENi5iYfSPBcZZRYcuY38wRG+VkIuxYwMq5iFE8tLc5NTy02zEst1ytOzC0uzUvX S87P3cQIjP7T/45/2sH49VLSIUYBDkYlHl6Do7XxQqyJZcWVuYcYJTiYlUR4nc6ejhPiTUms rEotyo8vKs1JLT7EKM3BoiTOa7zoZayQQHpiSWp2ampBahFMlomDU6qBMcza7kJHr7v3Av1l wTvcQxRW2m3V8fwXdVdthqThzxff/89q9whanpa7NGDVycqwnhvphdGXpE45V7DsmjNl549p RWW11RxLz2zfGzQh2GfqtIk5HBczr/xx+pYvGGn38xlz5Yfdn/P/vl73xzJPNe2iU1Lj1pDd 5dd8k7tk0/wfnPNUM2HgUGIpzkg01GIuKk4EAJ153rT6AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBLMWRmVeSWpSXmKPExsVy+t/xu7oxi+riDR6vkbW4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYynz46yFJyVqji0fhNjA+N20S5GTg4J AROJbT+us3cxcnEICSxllFhyehdTFyMHUEJG4sMlAYgaYYk/17rYIGo+MEq0dHWygiTYBGwl jsz8ygpSLyIQJnFipT9ImFnAXWLL4qnMILYwkP144W1GEJtFQFVi8tQZ7CA2r4CrxI79PcwQ 8+UlVm84AGZzCrhJnP1/lxViVyOjxM3zM9kmMPItYGRYxSiSWlqcm55bbKhXnJhbXJqXrpec n7uJERiK24793LyD8dLG4EOMAhyMSjy8Bkdr44VYE8uKK3MPMUpwMCuJ8DqdPR0nxJuSWFmV WpQfX1Sak1p8iNEU6KqJzFKiyfnAOMkriTc0NTS3sDQ0NzY3NrNQEuftEDgYIySQnliSmp2a WpBaBNPHxMEp1cDoWlLk7Tf5ap+5+rbu9rYl9ecjUqO+ifrxLVv+89f9ezdjXdzXdenJLLJj WG+pKfXvb5ygqYnew4+vi5/p2Fvt8f9la925P/905dPizwZ7z3z32Ddxf09weP6ZT309bU+m nO6dbfyzdcf6Y9OOTPlUttmB2brzwEqnJ83zl9Qf+qL1a4KUOlezEktxRqKhFnNRcSIAbMNZ 7lsCAAA= X-CMS-MailID: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 X-Msg-Generator: CA X-RootMTR: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052340eucas1p1451f2bf1b6475067491753274547b837 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 05/15] 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 Thu Oct 8 05:23:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79977 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 7FE2BA04BC; Thu, 8 Oct 2020 07:26:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 061ED1BA45; Thu, 8 Oct 2020 07:23:59 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 154951B6C1 for ; Thu, 8 Oct 2020 07:23:43 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052341euoutp0169fd1e86a33fca355ddaad9a3e5390af~77PM7bAHi2348223482euoutp016 for ; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052341euoutp0169fd1e86a33fca355ddaad9a3e5390af~77PM7bAHi2348223482euoutp016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134621; bh=Ac7zUxbaUtkPUHeaPly+rcwUzr6TKwAmXEJAVMzD+lE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTtVn9Oe4H0MwZ838H3DXyPALrygS+HAUMOhOOghH2fkgZmOMeeYeKLNK+eSZv8pv A0JARpRL8J1pabcgHE6OvDp6IY3fSFE8Qfwk3luexuiNvhk7Z0mUAQXywMdseSvCNo T8xfjjNMCsK6rE+wDoveKb02LH5TOhfcrrPOoBeY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052341eucas1p17cddb94aabddf6cd16600ae12904bcc4~77PMywzRH1294712947eucas1p1E; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 90.93.06456.D52AE7F5; Thu, 8 Oct 2020 06:23:41 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052341eucas1p2379b186206e5bf481e3c680de46e5c16~77PMY5Ghp2348123481eucas1p28; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052341eusmtrp189b078d52c662bcd37df7080735bd401~77PMYXd_c2941529415eusmtrp1V; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-43-5f7ea25d2008 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 57.89.06314.D52AE7F5; Thu, 8 Oct 2020 06:23:41 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052340eusmtip16daea8d9a3ed5f8c04dfd977ac04d13a~77PLxLsa22784127841eusmtip17; Thu, 8 Oct 2020 05:23:40 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:14 +0200 Message-Id: <20201008052323.11547-7-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87qxi+riDU5/0LK4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErozLnWcZ Cx7qVvTu2snYwDhJtYuRk0NCwETi8MWtrF2MXBxCAisYJV6vWcwE4XxhlNh5op8FwvnMKNH/ +QYbTEvbri5miMRyRol5399AOZ8YJSaemsQOUsUmYCtxZOZXVhBbRCBMorl5L9AoDg5mAWeJ J1/ZQExhAU+Jtre2IBUsAqoSXTcuglXzCrhKTO9ZwwyxS15i9YYDYDangJvE2f93wU6VELjN JtG7+hJUkYvEz6sNrBC2sMSr41vYIWwZidOTe1ggGrYxSlz9/ZMRwtnPKHG9dwVUlbXE4X+/ 2SCO05RYv0sfIuwo8bj1MdjNEgJ8EjfeCoKEmYHMSdumM0OEeSU62oQgqvUknvZMZYRZ+2ft ExYI20Pi1Z+30OC9yiix8tRftgmM8rMQli1gZFzFKJ5aWpybnlpsmJdarlecmFtcmpeul5yf u4kRGP2n/x3/tIPx66WkQ4wCHIxKPLwGR2vjhVgTy4orcw8xSnAwK4nwOp09HSfEm5JYWZVa lB9fVJqTWnyIUZqDRUmc13jRy1ghgfTEktTs1NSC1CKYLBMHp1QD40SWjV5xhy3Svj5tneKX pHJ5RuUtnwDZFb7nF7/kT8pM/GDyIc1RTvT52u7Aw++PvVA/WWnulnNDsmCq3alJNsn+WnXR LzUecEWZbi669lMwc/MS8eTTG8VLVI8pTzazzTrbcbThT5eNAWOD6c4JInrv1RY55/3n5m+w 6nlybuEGjSNLAxy2K7EUZyQaajEXFScCAKLbwsv6AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsVy+t/xu7qxi+riDf685LO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYzLnWcZCx7qVvTu2snYwDhJtYuRk0NC wESibVcXcxcjF4eQwFJGiSmLXrB3MXIAJWQkPlwSgKgRlvhzrYsNxBYS+MAo8fVfPYjNJmAr cWTmV1aQchGBMIkTK/1BwswC7hJbFk9lBgkLC3hKtL21BQmzCKhKdN24yApi8wq4SkzvWcMM MV1eYvWGA2A2p4CbxNn/d1khrmlklLh5fibbBEa+BYwMqxhFUkuLc9Nziw31ihNzi0vz0vWS 83M3MQLDcNuxn5t3MF7aGHyIUYCDUYmH1+BobbwQa2JZcWXuIUYJDmYlEV6ns6fjhHhTEiur Uovy44tKc1KLDzGaAl01kVlKNDkfGCN5JfGGpobmFpaG5sbmxmYWSuK8HQIHY4QE0hNLUrNT UwtSi2D6mDg4pRoYk/LXFmZo9B/4OvUSl9GZ6donC518ry9+cWiHv87J0tbbaz027J0QN69z y7xTTzJilL8dncDFeIV9Xwqf0p8pJTytLXHhzz556Nbvf7/an81FZQLvnAdKH7s/HL/Af6dp zsPWp0piezdNeTVt/dOl3D16/lu2rLRmdN1R52v561D/wQ2XJi86wqfEUpyRaKjFXFScCACl cyK0WQIAAA== X-CMS-MailID: 20201008052341eucas1p2379b186206e5bf481e3c680de46e5c16 X-Msg-Generator: CA X-RootMTR: 20201008052341eucas1p2379b186206e5bf481e3c680de46e5c16 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052341eucas1p2379b186206e5bf481e3c680de46e5c16 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 06/15] 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 Thu Oct 8 05:23:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79976 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 D55B4A04BC; Thu, 8 Oct 2020 07:25:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7E74F1B9EB; Thu, 8 Oct 2020 07:23:57 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 5AF5B1B6F3 for ; Thu, 8 Oct 2020 07:23:44 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052343euoutp0250323c53f8d9eb362b5ae6147d4a4255~77POImena0628306283euoutp02G for ; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052343euoutp0250323c53f8d9eb362b5ae6147d4a4255~77POImena0628306283euoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134623; bh=d2Ivz18BZBFcd9qsptaPD2eCpo7338aFKgdxjhU4CdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cYqJb/zedW3Z8WoQika2ezWCNwkCRixeJ2EqyjY2Zna5YM7agwbyYj0UHxzzqy8kV 1HVfXj8u/e1FUuyNDZa23yXf6v0/fVr8k6y4MXJeHpFU/UYejJx5oUVyzJCZgbn/l/ TASbJiZeZAor5cloEzLenG7Ip6vVuQ96BJkIdp1Q= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052342eucas1p29ce813c686d9bb5e11d35aaf76d09cb1~77PN1fWSv2346323463eucas1p25; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 42.93.06456.E52AE7F5; Thu, 8 Oct 2020 06:23:42 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052342eucas1p2376e75d9ac38f5054ca393b0ef7e663d~77PNIlyse2346323463eucas1p24; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052342eusmtrp1d1f37767640eb7ae86714f1313e4b35f~77PNIDmFJ2941629416eusmtrp1T; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-46-5f7ea25e6e84 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id B7.89.06314.D52AE7F5; Thu, 8 Oct 2020 06:23:41 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052341eusmtip1d707103c1ceac909f7acd97722e17a55~77PMf2LCr2786627866eusmtip1b; Thu, 8 Oct 2020 05:23:41 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:15 +0200 Message-Id: <20201008052323.11547-8-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djP87pxi+riDf4/NrC4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErozOXSfY C55yVVy5HtXA2M3ZxcjJISFgIjFt7me2LkYuDiGBFYwSrS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1bgRImEVAVeJD42ywMK+Aq8SN/9oQ0+Ul Vm84wAxicwq4SZz9f5cVYlMjo8TN8zPZJjDyLWBkWMUoklpanJueW2yoV5yYW1yal66XnJ+7 iREYhNuO/dy8g/HSxuBDjAIcjEo8vAZHa+OFWBPLiitzDzFKcDArifA6nT0dJ8SbklhZlVqU H19UmpNafIjRFOioicxSosn5wAjJK4k3NDU0t7A0NDc2NzazUBLn7RA4GCMkkJ5YkpqdmlqQ WgTTx8TBKdXAyFf99OHJxQ+3P3BbGiGkzb2g+1rRjKamGTX5Tw22f/3feenPic/zW5sXRUQL PT5YvGlxDU/lKb3+iNXOPdem3rP6nnrsrIiCgZ9f1ItZ8y9VXYnYyj71mE/LkY3rv8er2e2q ip39outd/vZVJ/Jf75xnW+X8dmlFyhzfg6qNncs6XONZU1bu4VZiKc5INNRiLipOBABuWY+1 WAIAAA== X-CMS-MailID: 20201008052342eucas1p2376e75d9ac38f5054ca393b0ef7e663d X-Msg-Generator: CA X-RootMTR: 20201008052342eucas1p2376e75d9ac38f5054ca393b0ef7e663d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052342eucas1p2376e75d9ac38f5054ca393b0ef7e663d References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 07/15] 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 Thu Oct 8 05:23:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79978 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 AA295A04BC; Thu, 8 Oct 2020 07:26:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AD6AB1BA83; Thu, 8 Oct 2020 07:24:00 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id AA14E1B6F6 for ; Thu, 8 Oct 2020 07:23:43 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052343euoutp0287bdd1a64df853203a8d83d97af296ae~77POct8Te0526205262euoutp02l for ; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052343euoutp0287bdd1a64df853203a8d83d97af296ae~77POct8Te0526205262euoutp02l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134623; bh=/a4nS1Xs22D+fHT+StZS8IYevrAhZXaTRDYMrBl1Ydk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9cQ7c5CkmUBMM5X5Cl9XLVwAJbNM6mKPYOgUeOR++la+quZRhwMFFLAAbQ6riHxG zMN2hig7GPr+GrGMZKVjYlRho+kD/drAll7LDTEOAtkk5a9YUEBP5McQn2bno7TqF8 PzPrqTjsUA8/qXQYxp5d0Q7HcovOwBg8wKe7Sj9s= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052343eucas1p226336ef8ff569c64ade58f052f2aa967~77POQtZpE2346323463eucas1p27; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 10.AD.06318.F52AE7F5; Thu, 8 Oct 2020 06:23:43 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052342eucas1p19e8474360d1f7dacd4164b3e21e54290~77PNyUfuM1295112951eucas1p1G; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052342eusmtrp172037bbcb360a9ff57c1886b3597950f~77PNxxU042941529415eusmtrp1X; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-af-5f7ea25f5349 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C8.89.06314.E52AE7F5; Thu, 8 Oct 2020 06:23:42 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052342eusmtip148d5bf5fe1ea72805defc53c6d4689eb~77PNMl1d92784127841eusmtip18; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:16 +0200 Message-Id: <20201008052323.11547-9-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djP87rxi+riDZa+4bO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErozVXVuZ CqY5VBycuYypgfG0cRcjJ4eEgInEsjdvGbsYuTiEBFYwSrRNv8kM4XxhlFiy/gmU85lR4vXP 6ywwLfP/zIRKLGeUONsygQ3C+cQoMXHWUbAqNgFbiSMzv7KC2CICYRLNzXuB4hwczALOEk++ soGEhYFKlp2+A1bCIqAqsf/EA3YQm1fAVWJzz0pWiGXyEqs3HGAGsTkF3CTO/r8LFb/OJnH2 NQ+E7SIx9clzRghbWOLV8S3sELaMxOnJPSwgt0kIbGOUuPr7JyOEs59R4nrvCqgqa4nD/36z QRynKbF+lz5E2FHi8tqFYGEJAT6JG28FQcLMQOakbdOZIcK8Eh1tQhDVehJPe6Yywqz9s/YJ NKw8JFbtmwcN3quMEqeevWOZwCg/C2HZAkbGVYziqaXFuempxcZ5qeV6xYm5xaV56XrJ+bmb GIHRf/rf8a87GPf9STrEKMDBqMTDa3C0Nl6INbGsuDL3EKMEB7OSCK/T2dNxQrwpiZVVqUX5 8UWlOanFhxilOViUxHmNF72MFRJITyxJzU5NLUgtgskycXBKNTAqNb7vSwydnZL49Jjl5Zvt LtLsnTKce/39K7f5Baw0PdUyndH32K245aKiUiFLvJ5ZmavzX9F457HhLq/8o8TXd9nOq3j3 xfbx6VunvtBK32D1eYXcC+0s5oIAy3/vnRMq+yfPEo6Vkum2jufbPveVxjqJsAUCepMa/z5x v3x7imi6/tHQDCWW4oxEQy3mouJEACzXbdP6AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBLMWRmVeSWpSXmKPExsVy+t/xu7pxi+riDebt17O4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYzVXVuZCqY5VBycuYypgfG0cRcjJ4eE gInE/D8zmbsYuTiEBJYySiz4tZy1i5EDKCEj8eGSAESNsMSfa11sEDUfGCUuT93KDJJgE7CV ODLzK1i9iECYxImV/iBhZgF3iS2Lp4KVCAOVLDt9hxXEZhFQldh/4gE7iM0r4CqxuWclK8R8 eYnVGw6A1XMKuEmc/X+XFWJXI6PEzfMz2SYw8i1gZFjFKJJaWpybnltsqFecmFtcmpeul5yf u4kRGIrbjv3cvIPx0sbgQ4wCHIxKPLwGR2vjhVgTy4orcw8xSnAwK4nwOp09HSfEm5JYWZVa lB9fVJqTWnyI0RToqonMUqLJ+cA4ySuJNzQ1NLewNDQ3Njc2s1AS5+0QOBgjJJCeWJKanZpa kFoE08fEwSnVwDjtzxK5YM7bmhsuRm++s+1PQsLd39+E/jxapzzZ0YMrSH7LhiVL7bP9fJpU 4lYesH/0zULNMjuad/VmDfN9+g//XeK36kwyrDeaFvhyBesnn2+H0y7/9lra//R34RPj3Gkn D7rGe6b+9Yp+GfdZvcmM8V9B9Pf8jgfbZIX2Llc7+kpHv2nWnZtKLMUZiYZazEXFiQCvaKj3 WwIAAA== X-CMS-MailID: 20201008052342eucas1p19e8474360d1f7dacd4164b3e21e54290 X-Msg-Generator: CA X-RootMTR: 20201008052342eucas1p19e8474360d1f7dacd4164b3e21e54290 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052342eucas1p19e8474360d1f7dacd4164b3e21e54290 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 08/15] 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 | 68 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/app/test/test_distributor.c b/app/test/test_distributor.c index 838459392..d7f780acc 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -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; num = rte_distributor_get_pkt(db, id, buf, buf, num); } __atomic_fetch_add(&worker_stats[id].handled_packets, num, __ATOMIC_ACQ_REL); - count += num; rte_distributor_return_pkt(db, id, buf, num); return 0; } @@ -276,21 +274,18 @@ 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); 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); rte_distributor_return_pkt(d, id, buf, num); @@ -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]); 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); 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. */ @@ -401,14 +384,10 @@ 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 = 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); @@ -474,9 +456,15 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, 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); @@ -528,9 +517,14 @@ test_flush_with_worker_shutdown(struct worker_params *wp, 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 Thu Oct 8 05:23:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79979 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 7E8C9A04BC; Thu, 8 Oct 2020 07:26:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 273341BAB5; Thu, 8 Oct 2020 07:24:02 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 90C581B703 for ; Thu, 8 Oct 2020 07:23:44 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052344euoutp027fa733bf5d8cf3bf528c5134d00db460~77PPQNd-V0628706287euoutp02E for ; Thu, 8 Oct 2020 05:23:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052344euoutp027fa733bf5d8cf3bf528c5134d00db460~77PPQNd-V0628706287euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134624; bh=Mf1tYMpRrpiHimFKfjMxNVXK98BWt+Vs7ADSETF/S1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQoFCd0AHmgntxbEkTlDrHgV4hBoSQaYn0dP6viH74V3t/yUyCDZAsHhiG5NcQoRW 7PiYilsl9JHKso5jtAaVldyelQ4Q+jeFjCO3HE0f4mvMtyd9bwcOztJwrokjIBBGpy /JTWh2hzR3r2zD8T8XubnClSOJPirfWwf2SmIfCY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052343eucas1p20225096822953452417112fcc8e15111~77POugu432933529335eucas1p2e; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 90.AD.06318.F52AE7F5; Thu, 8 Oct 2020 06:23:43 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052343eucas1p1649655353d6c76cdf6320a04e8d43f32~77POcFZJn1098510985eucas1p1Z; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052343eusmtrp1490f570bffee265c6af7327d4d490e73~77PObgqH92941629416eusmtrp1W; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-b2-5f7ea25f85fc Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 29.89.06314.F52AE7F5; Thu, 8 Oct 2020 06:23:43 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052342eusmtip1374f2316f2e9ce555996538734639b0f~77PN6UYgC2786627866eusmtip1c; Thu, 8 Oct 2020 05:23:42 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:17 +0200 Message-Id: <20201008052323.11547-10-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7rxi+riDVbO17G4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroy3rSvY Cl7wVFx48oKlgfEVVxcjJ4eEgInEpCur2LsYuTiEBFYwStztXs8CkhAS+MIocfmEAUTiM6PE hiWTWWA6DrR9YYZILGeU2LLlAguE84lRYk/DSbAqNgF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PDKkaR1NLi3PTcYkO94sTc4tK8dL3k /NxNjMBQ3Hbs5+YdjJc2Bh9iFOBgVOLhNThaGy/EmlhWXJl7iFGCg1lJhNfp7Ok4Id6UxMqq 1KL8+KLSnNTiQ4ymQFdNZJYSTc4HxkleSbyhqaG5haWhubG5sZmFkjhvh8DBGCGB9MSS1OzU 1ILUIpg+Jg5OqQZGEaGUuNV1/ZnMq498tNr3tmWaxIQ5TqtertnNEtxo5OjPWP7ze5VHlUGn v7JtifKW5Zsiu3/qvV1pXxt3dvblg1+lDyZtSfvrdUO5Mtux/stuPbOHGjX/uLZeVsxaLxOv 0nsn69Pky7M13rzYefSyrRbHvR+ZKVa1fYc41xr6fZnomxvO1SWixFKckWioxVxUnAgAM1Gu A1sCAAA= X-CMS-MailID: 20201008052343eucas1p1649655353d6c76cdf6320a04e8d43f32 X-Msg-Generator: CA X-RootMTR: 20201008052343eucas1p1649655353d6c76cdf6320a04e8d43f32 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052343eucas1p1649655353d6c76cdf6320a04e8d43f32 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 09/15] 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 d7f780acc..838a67515 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 Thu Oct 8 05:23:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79981 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 DAD3AA04BC; Thu, 8 Oct 2020 07:27:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 01C881BAF5; Thu, 8 Oct 2020 07:24:05 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 52E291B6F6 for ; Thu, 8 Oct 2020 07:23:45 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052345euoutp02c5c867e0c6275f3f4a984211020380fe~77PP_VZth0628306283euoutp02I for ; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052345euoutp02c5c867e0c6275f3f4a984211020380fe~77PP_VZth0628306283euoutp02I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134625; bh=dU7rWktTPIfjQZ7fCAIykFYYMgwWcdJlLIM6bxgVZkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JtoXj9v+Ei9hWUNKUWZnKke7DBqRVUx49m0NTRzOs47R/dfstEW/8E2WNF+KnJC7k rHj+JfW0n9KbfEFO81xUxHrD0Zol/CLt8zvdexkK1Ib/hHhxLZv1OfWTLoqBQ09Skq BqLfOUZPRuTcg4mhdP54C0Y8wpFY9ST5iTpMS48U= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052345eucas1p1a31fc4d671e0ce725b75cfe5a29168b3~77PP2DVDq0288802888eucas1p1x; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F0.AD.06318.062AE7F5; Thu, 8 Oct 2020 06:23:44 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052344eucas1p270b04ad2c4346e6beb5f5ef844827085~77PPNEA4X2933529335eucas1p2g; Thu, 8 Oct 2020 05:23:44 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052344eusmtrp18065f384e12ff8762c85305bfaa22cb5~77PPMgvt42941529415eusmtrp1Z; Thu, 8 Oct 2020 05:23:44 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-b4-5f7ea26008ed Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 8D.F0.06017.062AE7F5; Thu, 8 Oct 2020 06:23:44 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052343eusmtip11f9068f3fb3c564113b4d817649b348b~77POlXP4h2784127841eusmtip19; Thu, 8 Oct 2020 05:23:43 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:18 +0200 Message-Id: <20201008052323.11547-11-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djPc7oJi+riDY58s7a4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroyLx36z FhyWqnjz6zxTA+M20S5GTg4JAROJhvsLGLsYuTiEBFYwSrw+eIkFwvnCKHHr0UJWCOczo0TP rh+sMC0/lkPYQgLLGSW+3TCBsD8xSrw4HgViswnYShyZ+RWsRkQgTKK5eS/QVA4OZgFniSdf 2UBMYQEPiUmLuEAqWARUJSY+2scOYvMKuElc/PwfapO8xOoNB5hBbE6g+Nn/d8HOkRC4zibx +vUVqCIXiUkbd0HZwhKvjm9hh7BlJE5P7mGBaNjGKHH1909GCGc/o8T13hVQVdYSh//9ZoM4 TlNi/S59iLCjxLLPt5lAwhICfBI33gqChJmBzEnbpjNDhHklOtqEIKr1JJ72TGWEWftn7RMW CNtD4vXbPdAgvAp0QvNk5gmM8rMQli1gZFzFKJ5aWpybnlpsnJdarlecmFtcmpeul5yfu4kR GPmn/x3/uoNx35+kQ4wCHIxKPLwGR2vjhVgTy4orcw8xSnAwK4nwOp09HSfEm5JYWZValB9f VJqTWnyIUZqDRUmc13jRy1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b5f5ef844827085 X-Msg-Generator: CA X-RootMTR: 20201008052344eucas1p270b04ad2c4346e6beb5f5ef844827085 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052344eucas1p270b04ad2c4346e6beb5f5ef844827085 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 10/15] 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 Thu Oct 8 05:23:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79980 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 B308FA04BC; Thu, 8 Oct 2020 07:27:20 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BFE201BAE4; Thu, 8 Oct 2020 07:24:03 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 600A91B709 for ; Thu, 8 Oct 2020 07:23:46 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052346euoutp0275515a2a217960f8a8d93c32cda83d89~77PQ9HsV80628306283euoutp02J for ; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201008052346euoutp0275515a2a217960f8a8d93c32cda83d89~77PQ9HsV80628306283euoutp02J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134626; bh=5tY3N01YS6Scl9JxLIYxnJAj3A+6+tzDlSAFmFn7+vA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hpszh40U/JA68dyVZVAjPEASeNK+23WcxS+rFAGaWgB48i+qW1o3Mrgi50QpYgvDH 6AWW0ukaTn+FYD2nprzNeREIEiJb9T4nbLJ8WIEwZYSp20DUBxd+QKxQ5vCDnZ7h4F BVLB7S1WtQkHH0dSErhhbiZJ4o1uMkvLSpl5pljo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052346eucas1p291d3b26d2878550ab2002234ecf710a7~77PQy3hGa2348123481eucas1p2E; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id F4.01.05997.162AE7F5; Thu, 8 Oct 2020 06:23:45 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18~77PP7f83G2348123481eucas1p2B; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052345eusmtrp165b59c8635194998bb554d1c4a16f551~77PP6pvcl2941529415eusmtrp1a; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-73-5f7ea2618a9a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 99.89.06314.162AE7F5; Thu, 8 Oct 2020 06:23:45 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052344eusmtip1df2afac6652a9fdb6d99c7ae780c5877~77PPU9EPT2784127841eusmtip1_; Thu, 8 Oct 2020 05:23:44 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:19 +0200 Message-Id: <20201008052323.11547-12-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBIsWRmVeSWpSXmKPExsWy7djPc7qJi+riDb7+t7a4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErown214w FtwVqdi9fxVrA2OLYBcjJ4eEgInEmvunmboYuTiEBFYwSpx71c0G4XxhlLiy7zszhPOZUWLf qtVsMC0/LrWwQCSWM0pcvDCbFcL5xCixau9kVpAqNgFbiSMzv4LZIgJhEs3Ne4E6ODiYBZwl nnwFGyQs4CUx8WYLWAmLgKrEk6PTWUBsXgE3idtr/zFCLJOXWL3hADOIzQkUP/v/LtguCYHr bBKnn21ghihykZjavxrKFpZ4dXwLO4QtI3F6cg8LRMM2Romrv38yQjj7GSWu966AqrKWOPzv NxvEdZoS63fpQ4QdJbqmTmIFCUsI8EnceAsOMGYgc9K26cwQYV6JjjYhiGo9iac9Uxlh1v5Z +4QFwvaQuHfiJDR8rzJKfGrsYZ3AKD8LYdkCRsZVjOKppcW56anFRnmp5XrFibnFpXnpesn5 uZsYgfF/+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K55xblyVnVUyHODpUvOKp6syl/660FsqOv142o/lViKMxINtZiLihMBI80K XFsCAAA= X-CMS-MailID: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 X-Msg-Generator: CA X-RootMTR: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052345eucas1p29e14456610d4ed48c09b8cf7bd338e18 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 11/15] 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 838a67515..1e0a079ff 100644 --- a/app/test/test_distributor.c +++ b/app/test/test_distributor.c @@ -27,6 +27,7 @@ struct worker_params worker_params; /* statics - all zero-initialized by default */ static volatile int quit; /**< general quit variable for all threads */ static volatile int zero_quit; /**< var for when we just want thr0 to quit*/ +static volatile int zero_sleep; /**< thr0 has quit basic loop and is sleeping*/ static volatile unsigned worker_idx; static volatile unsigned zero_idx; @@ -376,8 +377,10 @@ handle_work_for_shutdown_test(void *arg) /* for worker zero, allow it to restart to pick up last packet * when all workers are shutting down. */ + __atomic_store_n(&zero_sleep, 1, __ATOMIC_RELEASE); while (zero_quit) usleep(100); + __atomic_store_n(&zero_sleep, 0, __ATOMIC_RELEASE); num = rte_distributor_get_pkt(d, id, buf, NULL, 0); @@ -445,7 +448,12 @@ sanity_test_with_worker_shutdown(struct worker_params *wp, /* flush the distributor */ rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); + + zero_quit = 0; + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, @@ -505,9 +513,14 @@ test_flush_with_worker_shutdown(struct worker_params *wp, /* flush the distributor */ rte_distributor_flush(d); - rte_delay_us(10000); + while (!__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_distributor_flush(d); zero_quit = 0; + + while (__atomic_load_n(&zero_sleep, __ATOMIC_ACQUIRE)) + rte_delay_us(100); + for (i = 0; i < rte_lcore_count() - 1; i++) printf("Worker %u handled %u packets\n", i, __atomic_load_n(&worker_stats[i].handled_packets, @@ -615,6 +628,8 @@ quit_workers(struct worker_params *wp, struct rte_mempool *p) quit = 0; worker_idx = 0; zero_idx = RTE_MAX_LCORE; + zero_quit = 0; + zero_sleep = 0; } static int From patchwork Thu Oct 8 05:23:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79982 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 A29ADA04BC; Thu, 8 Oct 2020 07:28:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3371A1BBD7; Thu, 8 Oct 2020 07:24:07 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 09E7D1B70A for ; Thu, 8 Oct 2020 07:23:48 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052346euoutp01dce646f905ebc012273c99959199c2e2~77PRZHOKv2268722687euoutp01i for ; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052346euoutp01dce646f905ebc012273c99959199c2e2~77PRZHOKv2268722687euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134626; bh=b8I//1LDMElaJ1YT0yZPEEVEetWTit5yqncv7yYfAnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+qxeki7CrVK/8zhZWqVJMtUzOxZjMcB2KaXoarwLD0j/3H37oLq9rXQZSBYieG95 50aYTg/xA1ZUC5cuB4wc6bwWF9WODcLAyomosfNMwj6W4HxVODLdH8g+X5hef4yi9J lFlOgH6qZZ1aNlWKQa9kgiNkKn9sEqa0RcQ/FcMg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052346eucas1p1939d67066616615b6425731edad6d848~77PREBi9Y0288802888eucas1p10; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C2.93.06456.262AE7F5; Thu, 8 Oct 2020 06:23:46 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052345eucas1p17a05f99986032885a0316d3419cdea2d~77PQtSacs0288802888eucas1p1z; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052345eusmtrp1cd3825364cd3fe258158e106218db7c4~77PQstZUF2941629416eusmtrp1Y; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-4b-5f7ea26272f3 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0E.F0.06017.162AE7F5; Thu, 8 Oct 2020 06:23:45 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052345eusmtip12cd01deee4606fbe9f196eaace361931~77PQDdjyI2964029640eusmtip1j; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:20 +0200 Message-Id: <20201008052323.11547-13-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7pJi+riDR484LO4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErozLPUsZ C35zVlz//p+9gbGJo4uRg0NCwETiyDvFLkYuDiGBFYwS3zpfsEA4XxglXnzYxwjhfGaUePv1 IFsXIydYx7T365ggEssZJTYvnwTlfGKUWHWziRGkik3AVuLIzK+sILaIQJhEc/NeFpB9zALO Ek++gg0SFrCS6P/wG6ycRUBV4s66l2DlvAJuEs/2nmOBWCYvsXrDAWYQmxMofvb/XVaQXRIC l9kkJncdgSpykVhzYRUrhC0s8er4FnYIW0bi9OQeFoiGbYwSV3//ZIRw9jNKXO9dAVVlLXH4 3282iOs0Jdbv0ocIO0pMeX+bHRJIfBI33gqChJmBzEnbpjNDhHklOtqEIKr1JJ72TGWEWftn 7ROo0zwk9s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cbff0H11bM7rksEH70bPwyg6PbrPYcdLwgzWLV+HhZSdNz5q63aauVAm39 wvfEM0s4uSU2NJ/uenb14dadKnc/f2rdUzr98rMM7eAVnrNFlJVYijMSDbWYi4oTAcXULAZa AgAA X-CMS-MailID: 20201008052345eucas1p17a05f99986032885a0316d3419cdea2d X-Msg-Generator: CA X-RootMTR: 20201008052345eucas1p17a05f99986032885a0316d3419cdea2d X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052345eucas1p17a05f99986032885a0316d3419cdea2d References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 12/15] 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 Thu Oct 8 05:23:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79983 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 D70A0A04BC; Thu, 8 Oct 2020 07:28:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 85E701BC0C; Thu, 8 Oct 2020 07:24:08 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 87D171B733 for ; Thu, 8 Oct 2020 07:23:47 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052347euoutp012ea755b944c20017850914f822871e4c~77PSCGKJU2347823478euoutp01A for ; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052347euoutp012ea755b944c20017850914f822871e4c~77PSCGKJU2347823478euoutp01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134627; bh=jMHuFwore4XCujWFa4FPHZRC4UgHvZ5ghfXB+hPBmOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=byeXNuHVkA7ynwyLJ2MkUMgUZYLfl/B4Oe2bV6BQVX89hYu/vjF8OG2f4r3pths7+ qyCI33fDlZn4KpGJNEWrvgyIuHcgfdiGDGfluSYx8uuGh4rMKTSVA5EY92fqpzyGcL +gAZg2+qBMf78rnm8FAcAQ2/PVbCgxAPxUvUfFTA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052347eucas1p280cd984b68178743ed7774188d4f14a1~77PR6av9g2934729347eucas1p2W; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 55.01.05997.362AE7F5; Thu, 8 Oct 2020 06:23:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39~77PRW3p1u1495514955eucas1p1C; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052346eusmtrp116169c7e5de2076253e5fe70aece2f75~77PRQf77Y2941629416eusmtrp1Z; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-75-5f7ea2630eda Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 6E.F0.06017.262AE7F5; Thu, 8 Oct 2020 06:23:46 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052346eusmtip1b64152b47d6b23d57c700ec04fe88cef~77PQ0msyK2784127841eusmtip1-; Thu, 8 Oct 2020 05:23:45 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com Date: Thu, 8 Oct 2020 07:23:21 +0200 Message-Id: <20201008052323.11547-14-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+N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FWr4vn9iAbGXsUuRk4OCQETiZUrd7B2MXJx CAksZZTo//eIpYuRAyghI/HhkgBEjbDEn2tdbBA1Hxgl7u29zwqSYBOwlTgy8yuYLSKgKvFv /ycmEJsZaOjteU1sILawgKfEhN+3WEFmsgDVLJsjDBLmFXCTuDu1gw1ivrzE6g0HmEFsTqD4 2f93oe5pZJS4eX4m2wRGvgWMDKsYRVJLi3PTc4uN9IoTc4tL89L1kvNzNzECw27bsZ9bdjB2 vQs+xCjAwajEw2twtDZeiDWxrLgy9xCjBAezkgiv09nTcUK8KYmVValF+fFFpTmpxYcYTYGO msgsJZqcD4yJvJJ4Q1NDcwtLQ3Njc2MzCyVx3g6BgzFCAumJJanZqakFqUUwfUwcnFINjDN5 Fpu+7uV8MO+UeoSqd3JC7GOX2Ey5ELHG+AXPFscnchzRDwmKO+C825gv2EhPzNm+NtCXMfFZ S8+eXtep1t5pptxf+SfMrhWKSvCY2XzXIvkm9xS5kzoTM4MZNH54nP1RxM5tErZI6uS7K07P HRi33c4+eX11nkhIwvxv1abG68Vn2D5UYinOSDTUYi4qTgQAXsCt/lECAAA= X-CMS-MailID: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 X-Msg-Generator: CA X-RootMTR: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052346eucas1p15b04bf84cafc2ba52bbe063f57d08c39 References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 13/15] 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 1e0a079ff..0404e463a 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_ACQ_REL); + 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_ACQ_REL); + 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_ACQUIRE)); + +/* 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 Thu Oct 8 05:23:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79984 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 79FD5A04BC; Thu, 8 Oct 2020 07:28:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04EEB1BC72; Thu, 8 Oct 2020 07:24:10 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 428921B733 for ; Thu, 8 Oct 2020 07:23:48 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052348euoutp019c05fbcd6c28fc8cafacfc6d400d9985~77PSuC3AW2268722687euoutp01j for ; Thu, 8 Oct 2020 05:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052348euoutp019c05fbcd6c28fc8cafacfc6d400d9985~77PSuC3AW2268722687euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134628; bh=FsFW6hcE1Xj1KduQH/cVHUIWcYyv6nc/poXSMMFFipk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZcMzF0Qf3CIq4Y1B4M3wOi93tnMnxwOlWHfLIFmehmfhHgRI2jnZIiJ9ES15qqP7m ueg60iTVu36ncF0JzKjmDwQVbbqnTHhWskRjlKlEWb4b1gJ+9lIUErYy1QBesvRR9b jciBq1tjCIWx0vpL8YpGxwDV/urxwXCZ5IHucGyE= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201008052347eucas1p18f010b2312e0919fec007fbd74ffe6a9~77PSdCEnQ1294612946eucas1p1K; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id C2.AD.06318.362AE7F5; Thu, 8 Oct 2020 06:23:47 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052347eucas1p1570239523104a0d609c928d8b149ebdf~77PR_9wAT1496314963eucas1p1B; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052347eusmtrp136d2ee3c644a305e8ce20a6a369b834c~77PR9xOgP2941529415eusmtrp1c; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-ba-5f7ea263fb2e Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 2A.89.06314.362AE7F5; Thu, 8 Oct 2020 06:23:47 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052346eusmtip1ee1a964f7b6131bbbb64453c6e763e6f~77PRWzqxi2964029640eusmtip1k; Thu, 8 Oct 2020 05:23:46 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:22 +0200 Message-Id: <20201008052323.11547-15-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87rJi+riDXZt17a4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroxZnyoL 1gpV9CzezdLA2M/fxcjJISFgInHoxGdmEFtIYAWjxL/eqi5GLiD7C6PE6i+H2SGcz4wSMw8s ZoXpWPPhByNEYjmjxNzFl5ggnE+MEkd2P2AHqWITsJU4MvMrWIeIQJhEc/Neli5GDg5mAWeJ J1/ZQMLCAq4Si391gNksAqoSD/7/YwSxeQXcJC6tfgS1TF5i9YYDYOdxAsXP/r/LCrJLQuAy m8TnBR8YIYpcJNavuA3VICzx6vgWdghbRuL05B4WiIZtjBJXf/9khHD2M0pc710BVWUtcfjf bzaI6zQl1u/Shwg7Svzfs5kZJCwhwCdx460gSJgZyJy0bTpUmFeio00IolpP4mnPVEaYtX/W PmGBsD0kXv1+zwYJn6uMEq1nJjJOYJSfhbBsASPjKkbx1NLi3PTUYuO81HK94sTc4tK8dL3k /NxNjMDYP/3v+NcdjPv+JB1iFOBgVOLhNThaGy/EmlhWXJl7iFGCg1lJhNfp7Ok4Id6UxMqq 1KL8+KLSnNTiQ4zSHCxK4rzGi17GCgmkJ5akZqemFqQWwWSZODilGhjT1PU/tzQUtOzo3L3n 5tS92revBWibTu/1eyiRvPekj/jLs7EJ11oEF/RkTz//RdV0kYH2nq83Nry/7Rk+7cJ2kxee DbZ7ZcSOlatMs69MWhaiEa91f3XINP/2fwuvG/74mXnvi/DNE2v3fH1w8tupOYumxejND9JR S//74Hfz97ztCS7rH8UnK7EUZyQaajEXFScCAL+GGGP5AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsVy+t/xu7rJi+riDXYv5re4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYxZnyoL1gpV9CzezdLA2M/fxcjJISFg IrHmww/GLkYuDiGBpYwSDU09QA4HUEJG4sMlAYgaYYk/17rYIGo+ANWc38IEkmATsJU4MvMr K0i9iECYxImV/iBhZgF3iS2LpzKD2MICrhKLf3WwgdgsAqoSD/7/YwSxeQXcJC6tfsQKMV9e YvWGA2D1nEDxs//vskLsamSUuHl+JtsERr4FjAyrGEVSS4tz03OLDfWKE3OLS/PS9ZLzczcx AgNx27Gfm3cwXtoYfIhRgINRiYfX4GhtvBBrYllxZe4hRgkOZiURXqezp+OEeFMSK6tSi/Lj i0pzUosPMZoCXTWRWUo0OR8YJXkl8YamhuYWlobmxubGZhZK4rwdAgdjhATSE0tSs1NTC1KL YPqYODilGhgb1p+b0qkd/Wf+1bfq0WtaVLqZtf/+EAiLnHDzl8enQ712jGn7D5l0Nj8zN0is tOlIOlij++RZ/t9P/w5m/cl+++piR/gFe9neNIu9T7czvzPn+FQ7LXat+8nUUDaX9lsBnMwV jbmMr0KdZXy3xj1a6bFQVtN0Gtcb75PPIte1CXHovC7956rEUpyRaKjFXFScCABiHU+TWgIA AA== X-CMS-MailID: 20201008052347eucas1p1570239523104a0d609c928d8b149ebdf X-Msg-Generator: CA X-RootMTR: 20201008052347eucas1p1570239523104a0d609c928d8b149ebdf X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052347eucas1p1570239523104a0d609c928d8b149ebdf References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 14/15] 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 Thu Oct 8 05:23:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Wojciechowski X-Patchwork-Id: 79985 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 0359CA04BC; Thu, 8 Oct 2020 07:29:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 39AAF1BC84; Thu, 8 Oct 2020 07:24:11 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 07F8C1B755 for ; Thu, 8 Oct 2020 07:23:50 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052348euoutp0160a1f085e3dc21f299e9fc125038c9ec~77PTaelYU2347823478euoutp01B for ; Thu, 8 Oct 2020 05:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052348euoutp0160a1f085e3dc21f299e9fc125038c9ec~77PTaelYU2347823478euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602134628; bh=ywYmxm+abMK7/w3PVolIPgc4wvJLruFOcPrSb20b5X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxiyz2YSUMVQTVXl4eIfshCjV4n8QA4eFtGUxB/myw4+bRlVmjwPuH0ZUsw48/0JO qXTcGDQQ0ZrxhlT+V/QKslNCVlC6WLcRG2KgsXLxIkxnKe331BIOxHke3FUVoQ4vFk cdHHn8HXYkkdi19R4+qVk0WQdMXCisNACYFD+LDs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201008052348eucas1p26c4484948e8b1bca59791cca491e2047~77PTMu_rG2346323463eucas1p2A; Thu, 8 Oct 2020 05:23:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 43.AD.06318.462AE7F5; Thu, 8 Oct 2020 06:23:48 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201008052348eucas1p183cfbe10d10bd98c7a63a34af98b80df~77PSwcc8C1496314963eucas1p1C; Thu, 8 Oct 2020 05:23:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201008052348eusmtrp1482c4bd751e8d7cd87d3f91687757625~77PSv35D92941629416eusmtrp1a; Thu, 8 Oct 2020 05:23:48 +0000 (GMT) X-AuditID: cbfec7f5-371ff700000018ae-bc-5f7ea2640149 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AE.F0.06017.462AE7F5; Thu, 8 Oct 2020 06:23:48 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201008052347eusmtip1114450c93ae5557d367b098bd71fef9a~77PSGTBSg2964029640eusmtip1l; Thu, 8 Oct 2020 05:23:47 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Thu, 8 Oct 2020 07:23:23 +0200 Message-Id: <20201008052323.11547-16-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djP87opi+riDVZMVrS4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsErozrO9ez Fkxnr9jzPLKBcSJbFyMnh4SAicSC1u0sXYxcHEICKxglep6vYoVwvjBK9L/dwQJSJSTwmVHi z3uRLkYOsI4b/SkQNcsZJWbM/sAOUfOJUeLV2XQQm03AVuLIzK+sILaIQJhEc/NeFpBeZgFn iSdfwRYLCzhJTJh1BMxmEVCVmNJ7EqycV8BNYsvi6ywQx8lLrN5wgBnE5gSKn/1/F+w2CYHL bBLNh2czQxS5SDzpugtlC0u8Or6FHcKWkTg9uYcFomEbo8TV3z8ZIZz9jBLXe1dAVVlLHP73 mw3iOk2J9bv0IcKOEke7drNCPMwnceOtIEiYGcictG06M0SYV6KjTQiiWk/iac9URpi1f9Y+ gbrfQ2Lm/6fskLC6yiix7PtyxgmM8rMQli1gZFzFKJ5aWpybnlpsnJdarlecmFtcmpeul5yf u4kRGPen/x3/uoNx35+kQ4wCHIxKPLwGR2vjhVgTy4orcw8xSnAwK4nwOp09HSfEm5JYWZVa lB9fVJqTWnyIUZqDRUmc13jRy1ghgfTEktTs1NSC1CKYLBMHp1QD4xKTvmO7lLacXdB/SsRR cFNU9Hlf7cNn+YoiDc6vYl1tNSduDduZbA6TnXl7bL/IXz7NuuvBpKuy/7MeX+R89VSgfM0d o+3xstYy967fsxW+/495Od/PsovXIl5tFdZbU8Zs8dP8j4P/kgpjXaPyfWoSXnmBl2f/q1v8 o4dr5jwlKddvGxpk1ZVYijMSDbWYi4oTAfKYWqb3AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGLMWRmVeSWpSXmKPExsVy+t/xu7opi+riDVYvYLW4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoPZui/NKSVIWM/OISW6VoQwsj PUNLCz0jE0s9Q2PzWCsjUyV9O5uU1JzMstQifbsEvYzrO9ezFkxnr9jzPLKBcSJbFyMHh4SA icSN/pQuRi4OIYGljBILnq1lh4jLSHy4JNDFyAlkCkv8udbFBlHzgVGi5+9kZpAEm4CtxJGZ X1lB6kUEwiROrPQHCTMLuEtsWTwVrERYwEliwqwjbCA2i4CqxJTek6wgNq+AG1DNdRaI+fIS qzccAKvnBIqf/X+XFWJXI6PEzfMz2SYw8i1gZFjFKJJaWpybnltspFecmFtcmpeul5yfu4kR GIbbjv3csoOx613wIUYBDkYlHl6Do7XxQqyJZcWVuYcYJTiYlUR4nc6ejhPiTUmsrEotyo8v Ks1JLT7EaAp01URmKdHkfGCM5JXEG5oamltYGpobmxubWSiJ83YIHIwREkhPLEnNTk0tSC2C 6WPi4JRqYDyyuvjpxxeiJ1n1VtuenvRubspSa5bdfvf+L5PUkT9+hdFtx40H70seuhXMcGac Fsl0ZevPay4188O2m5+dp6F78HVCQKpO1KeStKMuT2MMpzfNOLXFzOeWp8/59+cyGfxjY/ZI fHpncSHueeRXz2W2JQfPVOYaeBk5Bsjkz3Z+aPh8wX5jQRclluKMREMt5qLiRADFLOHCWQIA AA== X-CMS-MailID: 20201008052348eucas1p183cfbe10d10bd98c7a63a34af98b80df X-Msg-Generator: CA X-RootMTR: 20201008052348eucas1p183cfbe10d10bd98c7a63a34af98b80df X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201008052348eucas1p183cfbe10d10bd98c7a63a34af98b80df References: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> <20201008052323.11547-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-dev] [PATCH v5 15/15] 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 */