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 CF99FA04BC for ; Sat, 10 Oct 2020 00:02:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 914241D5F3; Sat, 10 Oct 2020 00:02:51 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id CE3521D5EA for ; Sat, 10 Oct 2020 00:02:47 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201009220236euoutp02f3ecffc0709204fabe0e71d087bf7b49~8cgpyOx-W1684516845euoutp02p for ; Fri, 9 Oct 2020 22:02:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201009220236euoutp02f3ecffc0709204fabe0e71d087bf7b49~8cgpyOx-W1684516845euoutp02p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602280956; bh=yH3M1Cb4L5UauMPb4vqNmQJysLFgOKEd5bHi5VjtoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ox8R0LYFjXuoyuV7eHZxDbL8d3/nRzOyFqTVnlRgFaYbAQ2WMWofDDJjs82ksx9t4 ShDyc3xvLRl1VLgP0bFmTpNDBHo032pkiuyKm8JDqkJ51tL0kbR4Qb4PNG+I4n7Kdq h1sFTXzTGSAZDf3sS+2qn1Pla8a9ROqN5gONSXFc= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201009220231eucas1p228d0dc392f16bee5cd170cfa5ac90400~8cgk_ZZX41995819958eucas1p2S; Fri, 9 Oct 2020 22:02:31 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 7D.E2.06318.7FDD08F5; Fri, 9 Oct 2020 23:02:31 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201009220229eucas1p17ad627f31005ed506c5422b93ad6d112~8cgjlWdP10450404504eucas1p1y; Fri, 9 Oct 2020 22:02:29 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201009220229eusmtrp29284b30d5953b910aa235f33ff39f20a~8cgjk02Gq1642116421eusmtrp2W; Fri, 9 Oct 2020 22:02:29 +0000 (GMT) X-AuditID: cbfec7f5-38bff700000018ae-95-5f80ddf7b097 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 02.5F.06017.5FDD08F5; Fri, 9 Oct 2020 23:02:29 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201009220210eusmtip1850c0d5c6eb400f2bda759aed12f0c2b~8cgR6kEFs1334813348eusmtip1r; Fri, 9 Oct 2020 22:02:07 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 10 Oct 2020 00:01:48 +0200 Message-Id: <20201009220202.20834-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7rf7zbEG0z8KmpxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBkdD84x FpwWrXjwaRNzA+N6oS5GTg4JAROJxxN2snQxcnEICaxglLi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4CrxKIVG5gg 5stLrN5wAKyeU8BNonXXMhaIXY2MElsOvGSewMi3gJFhFaNIamlxbnpusZFecWJucWleul5y fu4mRmAgbjv2c8sOxq53wYcYBTgYlXh4NRIb4oVYE8uKK3MPMUpwMCuJ8DqdPR0nxJuSWFmV WpQfX1Sak1p8iNEU6KqJzFKiyfnAKMkriTc0NTS3sDQ0NzY3NrNQEuftEDgYIySQnliSmp2a WpBaBNPHxMEp1cBoeZRtafQOb8NJ6Zn7/nIJLipkni4VFmMh+Mf+T5fAZLu+y42JP7+uWM96 6se+B9ML1vec3hCiolZy7WtP8fapyas61gtM4k92YPzwTv85t33YCsnoQ2aJdTofFj1d1Vi7 9tjSnNVJxkXLw0uilNtn3PxoIBHP9iF+cpYnY5/b3ubYXZMnK5xWYinOSDTUYi4qTgQAJSAw 01oCAAA= X-CMS-MailID: 20201009220229eucas1p17ad627f31005ed506c5422b93ad6d112 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201009220229eucas1p17ad627f31005ed506c5422b93ad6d112 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201009220229eucas1p17ad627f31005ed506c5422b93ad6d112 References: <20201008052323.11547-1-l.wojciechow@partner.samsung.com> <20201009220202.20834-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v6 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