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 C1E04A04B1 for ; Wed, 23 Sep 2020 15:26:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0E3FB1DCD9; Wed, 23 Sep 2020 15:26:00 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id AA8121DBDE for ; Wed, 23 Sep 2020 15:25:50 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200923132550euoutp01d67b48a13e73477db98f9d30225e8b3d~3bI4gczWV1163311633euoutp01Z for ; Wed, 23 Sep 2020 13:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200923132550euoutp01d67b48a13e73477db98f9d30225e8b3d~3bI4gczWV1163311633euoutp01Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1600867550; bh=yH3M1Cb4L5UauMPb4vqNmQJysLFgOKEd5bHi5VjtoSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UeIs+uiCmSA7YSt4DDD/CmBsHmfA00UoBVkO3KuA1u/XkyXoSq/4amM62EkNm5laR f+qPwyP8IIp332lRAGHmH17PSyIG+KCET+auNcrTAMmgo5PjjmmWgoemVBlb0FQAlt gSIBsry1L4QuPqx6tjs9oTPHFLpFkRSwniWCRDmo= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200923132550eucas1p153d02e3bab19e499f30c0a2cf6396f90~3bI4SVDev1413714137eucas1p1T; Wed, 23 Sep 2020 13:25:50 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C6.84.05997.DDC4B6F5; Wed, 23 Sep 2020 14:25:49 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200923132549eucas1p29fc391c3f236fa704ff800774ab851f0~3bI3YmgGH2615126151eucas1p2G; Wed, 23 Sep 2020 13:25:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200923132549eusmtrp1c05ab2d0365613015827202cd77b3b7e~3bI3YAdXX3190431904eusmtrp1F; Wed, 23 Sep 2020 13:25:49 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-60-5f6b4cdd5bb2 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1C.FA.06017.CDC4B6F5; Wed, 23 Sep 2020 14:25:48 +0100 (BST) Received: from Padamandas.fritz.box (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200923132548eusmtip283b25f6cde74e387e530d1f287a0e9c8~3bI2ubL6_2716727167eusmtip2e; Wed, 23 Sep 2020 13:25:48 +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 15:25:38 +0200 Message-Id: <20200923132541.21417-6-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200923132541.21417-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRmVeSWpSXmKPExsWy7djP87p3fbLjDVYuNrW4screom/SRyaL d5+2M1k861nHaPGv4w+7A6vHrwVLWT0W73nJ5HHw3R6mAOYoLpuU1JzMstQifbsEroyOB+cY C06LVjz4tIm5gXG9UBcjB4eEgInEp1taXYxcHEICKxglJqy8wQjhfGGUuDv/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P87kRHE5hVwldi2ehkj xHx5idUbDoDVcwq4SXz48Z4RYlcjo8TGt22MExj5FjAyrGIUSS0tzk3PLTbSK07MLS7NS9dL zs/dxAgMxW3Hfm7Zwdj1LvgQowAHoxIPL4dudrwQa2JZcWXuIUYJDmYlEV6ns6fjhHhTEiur Uovy44tKc1KLDzGaAl01kVlKNDkfGCd5JfGGpobmFpaG5sbmxmYWSuK8HQIHY4QE0hNLUrNT UwtSi2D6mDg4pRoYJ4atPnvEYv9vD55fPz7s4plx6ufe44r3lt9Su5NZ2rFlW8xavxNnHm7i in18ZopIOffprOs8JYLc8p+KpB0kZ7OHzax8PGfLsrapvVXTKnYd13EPfzn15jzXp8t71QT4 pz87bfpCcdXBPT95Xe8l+X6aeo9XaP953vBt67XmqX1OP/uL5fKlyVeUWIozEg21mIuKEwFF oJzvWwIAAA== X-CMS-MailID: 20200923132549eucas1p29fc391c3f236fa704ff800774ab851f0 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200923132549eucas1p29fc391c3f236fa704ff800774ab851f0 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200923132549eucas1p29fc391c3f236fa704ff800774ab851f0 References: <20200923014713.16932-1-l.wojciechow@partner.samsung.com> <20200923132541.21417-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v3 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 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