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 56438A04DC for ; Sat, 17 Oct 2020 05:07:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E6EAEE299; Sat, 17 Oct 2020 05:07:30 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id CB784CFD9 for ; Sat, 17 Oct 2020 05:07:27 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201017030716euoutp01c61609d4bf1cb269f319734f48ac4ed3~_qLp3VFyq1627716277euoutp01T for ; Sat, 17 Oct 2020 03:07:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201017030716euoutp01c61609d4bf1cb269f319734f48ac4ed3~_qLp3VFyq1627716277euoutp01T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602904036; bh=MUA/AWoQYa93ZfKVmGkqKZTBhCmKyloue6Sqv5lZoBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p/V4r/qjnJobLH6YsUNrpO//yxqeu2AnTaB/uPigzFpFQ/z+grU54fJN2Myj2tO75 dmU2se/v4pZtRpzo/YZ1BeQDH4XgbOJ1KX0A9+xXVsg868Hm0nRwGLevw9VFZ0h3UN ZO/ggcIHLM849vHSpXPs8A41/As+j/qoYwd/a5E4= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201017030710eucas1p1d5908365d9468c3e7124e65258f84b3f~_qLlAsWmA0652806528eucas1p1w; Sat, 17 Oct 2020 03:07:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 87.D5.06318.EDF5A8F5; Sat, 17 Oct 2020 04:07:10 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201017030710eucas1p17fb6129fd3414b4b6b70dcd593c01a40~_qLkkgpWR0898408984eucas1p10; Sat, 17 Oct 2020 03:07:10 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201017030710eusmtrp1bc23ca0de75cdb11c7a8e7cd4b97d38d~_qLkj_0ph3018830188eusmtrp1S; Sat, 17 Oct 2020 03:07:10 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-8e-5f8a5fde76a2 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 4C.DE.06017.EDF5A8F5; Sat, 17 Oct 2020 04:07:10 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201017030709eusmtip19d39216685745960b0d65e58fe02a557~_qLj9S5aT3071330713eusmtip1E; Sat, 17 Oct 2020 03:07:09 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 17 Oct 2020 05:06:45 +0200 Message-Id: <20201017030701.16134-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201017030701.16134-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7r34rviDe71mFncWGVv0TfpI5PF u0/bmSye9axjtPjX8YfdgdXj14KlrB6L97xk8jj4bg9TAHMUl01Kak5mWWqRvl0CV8alv3MY C5YLV3x7toexgfGgQBcjJ4eEgInEmnO/2LoYuTiEBFYwSqz9uJcJwvn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q0Xr0BQvE fHmJ1RsOMIOM4RRwk2g87gqxqpFR4uysdSwTGPkWMDKsYhRJLS3OTc8tNtIrTswtLs1L10vO z93ECAzEbcd+btnB2PUu+BCjAAejEg/vhkWd8UKsiWXFlbmHGCU4mJVEeJ3Ono4T4k1JrKxK LcqPLyrNSS0+xGgKdNREZinR5HxglOSVxBuaGppbWBqaG5sbm1koifN2CByMERJITyxJzU5N LUgtgulj4uCUamCcwaUtftKfP8/dj/XUhvfVvrPt7zHpqP5WnxPXOv/tN7MbFsdWButNf/Dh hrWeQ+KbgtCKusBDxhNZL/z5auBuW6KxpOTNXJnzkfZJaZ2ugZbzT+9ZOzVh5vQ28RvmTXKp C97cXhb/w9w24KnmtXWt6YJfNvuW3qu3Xbkg/FWSXeeVp7vWBnQosRRnJBpqMRcVJwIA0oZn AFoCAAA= X-CMS-MailID: 20201017030710eucas1p17fb6129fd3414b4b6b70dcd593c01a40 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201017030710eucas1p17fb6129fd3414b4b6b70dcd593c01a40 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201017030710eucas1p17fb6129fd3414b4b6b70dcd593c01a40 References: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> <20201017030701.16134-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v8 01/17] 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 | 12 ++++++++++++ lib/librte_distributor/rte_distributor_single.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/lib/librte_distributor/rte_distributor.c b/lib/librte_distributor/rte_distributor.c index 1c047f065..c6b19a388 100644 --- a/lib/librte_distributor/rte_distributor.c +++ b/lib/librte_distributor/rte_distributor.c @@ -169,6 +169,18 @@ rte_distributor_return_pkt(struct rte_distributor *d, return -EINVAL; } + /* Spin while handshake bits are set (scheduler clears it). + * Sync with worker on GET_BUF flag. + */ + while (unlikely(__atomic_load_n(&(buf->retptr64[0]), __ATOMIC_RELAXED) + & 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