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 AD052A04C9 for ; Tue, 15 Sep 2020 21:35:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F6C61C198; Tue, 15 Sep 2020 21:35:09 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 258191C119 for ; Tue, 15 Sep 2020 21:35:01 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200915193500euoutp01c13c6c8a43c238dbd9ce54dc1288e93e~1DA7zfWaA1766217662euoutp01- for ; Tue, 15 Sep 2020 19:35:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200915193500euoutp01c13c6c8a43c238dbd9ce54dc1288e93e~1DA7zfWaA1766217662euoutp01- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600198500; bh=tCOSBquxDc/4BM7ZzzVEA+FCBvHG6w6JIej8fSYIkFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BmXWz5NgftDlGNkJDNuDZbcVcDPfb4IM8go7LaxI2lBbdG3JM1q8Rk3JxttKkyusa Nt5ZfcrOC4U9GRbuEPTxJS4Ks5EX1s10DojloEy/y4j2VRaFFdniqiiemAwzpigij3 jpbaLXg+GiZmnQR1/GNbXkOuryMETri4A03TB5dk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200915193500eucas1p27ae83690fe034915a6a4eb7d67050f3f~1DA7ev_W90572705727eucas1p2k; Tue, 15 Sep 2020 19:35:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 8F.C6.06318.467116F5; Tue, 15 Sep 2020 20:35:00 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200915193500eucas1p2b079e1dcfd2d54e01a5630609b82b370~1DA7PXrq-0363603636eucas1p2w; Tue, 15 Sep 2020 19:35:00 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200915193500eusmtrp151490540a2d63c0f40f7796d4df25235~1DA7O5md81473114731eusmtrp1C; Tue, 15 Sep 2020 19:35:00 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-2b-5f61176422ff Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 24.7C.06314.467116F5; Tue, 15 Sep 2020 20:35:00 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200915193459eusmtip2ff480d370d7dc265cbc604bab15fcdd5~1DA6pAlYD1389713897eusmtip2O; Tue, 15 Sep 2020 19:34:59 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Tue, 15 Sep 2020 21:34:48 +0200 Message-Id: <20200915193449.13310-6-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915193449.13310-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djPc7op4onxBtN/KFncWGVv0TfpI5PF u0/bmSye9axjtPjX8YfdgdXj14KlrB6L97xk8jj4bg9TAHMUl01Kak5mWWqRvl0CV8bxqxfY CxbxVtzadZi1gbGTu4uRk0NCwETi9YbLzF2MXBxCAisYJQ7dm8cMkhAS+MIo8auRDyL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esMBMJtTwE3i6sfZYLYQUM3ik+fZJzDyLWBkWMUoklpanJueW2yoV5yYW1yal66XnJ+7 iREYhtuO/dy8g/HSxuBDjAIcjEo8vAtuJ8QLsSaWFVfmHmKU4GBWEuF1Ons6Tog3JbGyKrUo P76oNCe1+BCjKdBNE5mlRJPzgTGSVxJvaGpobmFpaG5sbmxmoSTO2yFwMEZIID2xJDU7NbUg tQimj4mDU6qBUegH85Ll5amKhZNkVvSWd8movWK5tL07dVtfSmMUq4P5maKLoS8yuV0/vGI/ HCDZ0+Or6eWvVRAe1j4nSKb876PGv1I7n50XvvzScO50pg6ZiVHxKm8Ocy99L8zv6rVA8jjT xvw78SfO3RP1fhRmHP7t7mNpwfM9E6NnFrkem9i6JMW4vtJViaU4I9FQi7moOBEAG0LV4FkC AAA= X-CMS-MailID: 20200915193500eucas1p2b079e1dcfd2d54e01a5630609b82b370 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200915193500eucas1p2b079e1dcfd2d54e01a5630609b82b370 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200915193500eucas1p2b079e1dcfd2d54e01a5630609b82b370 References: <20200915193449.13310-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v1 5/6] 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. Fixes: 775003ad2f96 ("distributor: add new burst-capable library") Cc: david.hunt@intel.com Cc: stable@dpdk.org Signed-off-by: Lukasz Wojciechowski --- lib/librte_distributor/rte_distributor.c | 14 ++++++++++++++ 1 file changed, 14 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++) -- 2.17.1