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 75DEBA04B1 for ; Sat, 10 Oct 2020 18:05:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9BE551D90D; Sat, 10 Oct 2020 18:05:37 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 8F7A61D901 for ; Sat, 10 Oct 2020 18:05:32 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201010160520euoutp01b2e15641019842f38e09a29dfcf52019~8rSAf42z40392303923euoutp01N for ; Sat, 10 Oct 2020 16:05:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201010160520euoutp01b2e15641019842f38e09a29dfcf52019~8rSAf42z40392303923euoutp01N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602345920; bh=yH3M1Cb4L5UauMPb4vqNmQJysLFgOKEd5bHi5VjtoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1NOX6M4WGBMhFcqBoXXzpZNdu5VtXL/BvluaEvSXw1TpG+IQvR2oQsxCss21q3PF ECTN10AxHlu3kInBjez7Zkm/YtGN2XMjc3kTM2/1iko8f1+/2mwNnz73d6JwLQk5hg jTGJbvrkCD4GzOkgZLJRGPe91miUz/X5IWYHUB1U= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201010160515eucas1p16f8030651ba8374cfa3e557883c24a26~8rR7p3dM42439624396eucas1p1t; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 35.58.05997.BBBD18F5; Sat, 10 Oct 2020 17:05:15 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f~8rR7Sc-Jz2236022360eucas1p1y; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201010160515eusmtrp24ce18be0a8cf1f1d39afb7d13ba57b91~8rR7R7fcZ1692616926eusmtrp2D; Sat, 10 Oct 2020 16:05:15 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-57-5f81dbbb2278 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 19.A6.06017.BBBD18F5; Sat, 10 Oct 2020 17:05:15 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201010160514eusmtip145dcd21efe3dc7aada781fab8a901583~8rR6iKivg2442224422eusmtip1v; Sat, 10 Oct 2020 16:05:14 +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 18:04:52 +0200 Message-Id: <20201010160508.19709-2-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201010160508.19709-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsWy7djP87q7bzfGG8yfpWFxY5W9Rd+kj0wW 7z5tZ7J41rOO0eJfxx92B1aPXwuWsnos3vOSyePguz1MAcxRXDYpqTmZZalF+nYJXBkdD84x FpwWrXjwaRNzA+N6oS5GTg4JAROJZy1f2bsYuTiEBFYwSszaPJsRJCEk8IVRY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8ZQWxeAVeJVVteMUHM l5dYveEAWD2ngJvE2a6DULsaGSVO3L7JNoGRbwEjwypGkdTS4tz03GIjveLE3OLSvHS95Pzc TYzAQNx27OeWHYxd74IPMQpwMCrx8EqcaowXYk0sK67MPcQowcGsJMLrdPZ0nBBvSmJlVWpR fnxRaU5q8SFGU6CrJjJLiSbnA6MkryTe0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2ampB ahFMHxMHp1QDY9jNxDuXeKyNtnLc5vAWisv6xv0lTPG3ccuT+/k/y039vNOuap36xN9mZzqT t0F58XmL5vwl328fE15WnMVpInhqT9UNed68x+UmCyew7Hh0bVHvVw7elKNfjwgciHLR+HbR 6UmkVaBO08tvAYLrNz+csH+rUe9pv/8HD/BGLD4d9WmyyIwyKSWW4oxEQy3mouJEABe24ERa AgAA X-CMS-MailID: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201010160515eucas1p18003d01d8217cdf04be3cba2e32f969f References: <20201009220202.20834-1-l.wojciechow@partner.samsung.com> <20201010160508.19709-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v7 01/16] 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