From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7913FA04BC for ; Thu, 8 Oct 2020 07:23:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 484DF1B694; Thu, 8 Oct 2020 07:23:48 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 9778C1B669 for ; Thu, 8 Oct 2020 07:23:40 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052339euoutp0137af1fe3be21922c9b8edc4414c427ad~77PKl0TM_2348223482euoutp014 for ; Thu, 8 Oct 2020 05:23:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052339euoutp0137af1fe3be21922c9b8edc4414c427ad~77PKl0TM_2348223482euoutp014 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/+uMncxcnEICaxglPjUuZsJwvnCKPHm6x02COczo8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D2ngJvE2f93WSF2NTJK3Dw/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 Content-Type: text/plain; charset="utf-8" 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-stable] [PATCH v5 02/15] distributor: fix handshake deadlock X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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); -- 2.17.1