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 E92B7A04BC for ; Thu, 8 Oct 2020 07:23:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C4B381B694; Thu, 8 Oct 2020 07:23:42 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id CBECC1B669 for ; Thu, 8 Oct 2020 07:23:39 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201008052338euoutp01036ea4a55cccd18d636268950b1a6cf3~77PJo66IF2226222262euoutp01k for ; Thu, 8 Oct 2020 05:23:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201008052338euoutp01036ea4a55cccd18d636268950b1a6cf3~77PJo66IF2226222262euoutp01k 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 d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroyOB+cY C06LVjz4tIm5gXG9UBcjJ4eEgInEv7UdjF2MXBxCAisYJW42rGeHcL4wSkx98JgJwvnMKLHg 81R2mJaeWzPY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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 Content-Type: text/plain; charset="utf-8" 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-stable] [PATCH v5 01/15] distributor: fix missing handshake synchronization 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" 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; -- 2.17.1