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 0D9D7A04B5 for ; Wed, 23 Sep 2020 03:47:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8C5811DB87; Wed, 23 Sep 2020 03:47:33 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 92E3D1DB48 for ; Wed, 23 Sep 2020 03:47:22 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200923014722euoutp01ef9c40febd6ed1fe30e729fe9b51e65e~3RnCxAKxM0326603266euoutp01D for ; Wed, 23 Sep 2020 01:47:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200923014722euoutp01ef9c40febd6ed1fe30e729fe9b51e65e~3RnCxAKxM0326603266euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600825642; bh=h2IUnowZC6g6U1PDEy2qPJDrhADn58pZEJ7CaYNOixw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ROFfQrI8uJVap7s8bg6Fk1F/leFKa8Vv1+0YZS08sKg0NZcQ5zeIuTirwNSfAfuhm 3wSVi9Dksq1mC5UFD6IkG3v5CGoh/+J0apCtO+3ETM2mBhZSzP5yjLGd4REndpeUXg dGS8ye349+wPgZz2eQDuyvucT9m/FZEIAxWVAfPY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200923014722eucas1p2eb16beca2b3cabb46c69d2db9f2829ab~3RnCgPmAa1707617076eucas1p2e; Wed, 23 Sep 2020 01:47:22 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 85.6D.06456.929AA6F5; Wed, 23 Sep 2020 02:47:22 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200923014721eucas1p1d22ac56c9b9e4fb49ac73d72d51a7a23~3RnCEZ8Fv2800828008eucas1p1q; Wed, 23 Sep 2020 01:47:21 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200923014721eusmtrp253abfdee65af5a13ee7efc225cec93ec~3RnCD3GY-2054820548eusmtrp2R; Wed, 23 Sep 2020 01:47:21 +0000 (GMT) X-AuditID: cbfec7f2-809ff70000001938-de-5f6aa929eae1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 94.9A.06314.929AA6F5; Wed, 23 Sep 2020 02:47:21 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200923014720eusmtip14b5f58e98f7802a1d1abd292b050dc6f~3RnBaKLUi0729307293eusmtip1P; Wed, 23 Sep 2020 01:47:20 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Wed, 23 Sep 2020 03:47:10 +0200 Message-Id: <20200923014713.16932-6-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923014713.16932-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7paK7PiDVa+Y7S4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroyNew+w FMwTrViy9z5zA2O7UBcjJ4eEgInEtu+TWboYuTiEBF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Qm1fAVeLC6l3s EPPlJVZvOMAMMoZTwE3i6T95iFWNjBIzFr5mn8DIt4CRYRWjSGppcW56brGhXnFibnFpXrpe cn7uJkZgIG479nPzDsZLG4MPMQpwMCrx8L54khkvxJpYVlyZe4hRgoNZSYTX6ezpOCHelMTK qtSi/Pii0pzU4kOMpkBHTWSWEk3OB0ZJXkm8oamhuYWlobmxubGZhZI4b4fAwRghgfTEktTs 1NSC1CKYPiYOTqkGRs2tE2I0s9OOb7OrmdNjurru44kEeU7jgg2HrFWT9y379+WckOjbiTJC u8NN9t/SqunMf+EY8lS1pEB1weHt1xdLWWVYfmf2YghI3nTNK0VoytoDTxWV9c5H5HJ8bH99 98U2zdgmLYmo1evrRaoZr3YxOW169pBJ61zC4q/Lb+dazg4tKZh2SYmlOCPRUIu5qDgRAM4G wTtaAgAA X-CMS-MailID: 20200923014721eucas1p1d22ac56c9b9e4fb49ac73d72d51a7a23 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200923014721eucas1p1d22ac56c9b9e4fb49ac73d72d51a7a23 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200923014721eucas1p1d22ac56c9b9e4fb49ac73d72d51a7a23 References: <20200915193449.13310-1-l.wojciechow@partner.samsung.com> <20200923014713.16932-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v2 5/8] 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 --- 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