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 57C61A04DB for ; Sat, 17 Oct 2020 05:14:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 00FFDE2CC; Sat, 17 Oct 2020 05:14:16 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 4E47EE2C0 for ; Sat, 17 Oct 2020 05:14:13 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201017031401euoutp02deb6a615f1820f7cd2177083676a6fb4~_qRjsCs232305923059euoutp02h for ; Sat, 17 Oct 2020 03:14:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201017031401euoutp02deb6a615f1820f7cd2177083676a6fb4~_qRjsCs232305923059euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1602904441; bh=9+4LuJuHFPstZZeyg1xuorvkqPag/chge0RF9mzR5DI=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=IDpSf9S4GeUNT8ZifJUH/SgcULxgjaQj5O3NY+Woy9qd5CBpe9SMHGLcCqJGvP85X 7DM6LIbA8dMDmvxi1VZ//HvCLzczj9qau06cREZVRjGzhPZre3RxwV0DJa0Z3cjsiD kjlGuVVXupEppnCFWrhuF7AqSzF1vmh143Yk3hX4= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201017031355eucas1p2d510313205bf8329d1c5095fe73ee20c~_qRd7qS7s2936529365eucas1p2T; Sat, 17 Oct 2020 03:13:55 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 7F.E8.06456.3716A8F5; Sat, 17 Oct 2020 04:13:55 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201017031354eucas1p1196820dedcdcd0ef9c357c77513ad679~_qRc_eJWp2408924089eucas1p1J; Sat, 17 Oct 2020 03:13:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20201017031354eusmtrp2da9869bbd91059c2b35c627e6dfc91d8~_qRc93goO2813028130eusmtrp2d; Sat, 17 Oct 2020 03:13:54 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-c6-5f8a61730dbb Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 60.A9.06314.2716A8F5; Sat, 17 Oct 2020 04:13:54 +0100 (BST) Received: from [106.210.88.70] (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201017031354eusmtip26c9e220b6ad8974f14cb0edcfeebe3f0~_qRcWete31278912789eusmtip2G; Sat, 17 Oct 2020 03:13:53 +0000 (GMT) To: Honnappa Nagarahalli , David Hunt , Bruce Richardson Cc: "dev@dpdk.org" , "stable@dpdk.org" , nd , "\"'Lukasz Wojciechowski'\"," From: Lukasz Wojciechowski Message-ID: <4bba98b3-614c-ba7f-3b40-188d3076948a@partner.samsung.com> Date: Sat, 17 Oct 2020 05:13:53 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGKsWRmVeSWpSXmKPExsWy7djP87rFiV3xBqtuaVrcWGVv0TfpI5PF u0/bmSxmPm1ht3jWs47R4szyHmaLfx1/2B3YPdbMW8Po8WvBUla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pOvJFqYPws3sXIySEhYCJx99tDpi5GLg4hgaWMErNv3mPtYuQASshIfLgkAFEjLPHnWhcb RM1rRomVK7YwgySEBWIlTv+dA5YQEehllNjeNRdsErPAXEaJqY1PGSFanjBJ9FzvYQJpYROw lTgy8ysriM0r4CYx9/EmsFEsAqoSPzrvgdWICsRJ/JjYywZRIyhxcuYTFhCbE2jdltVTwOLM AmYS8zY/ZIaw5SWat86GssUlbj2ZzzSBUWgWkvZZSFpmIWmZhaRlASPLKkaR1NLi3PTcYkO9 4sTc4tK8dL3k/NxNjMBo23bs5+YdjJc2Bh9iFOBgVOLh3bCoM16INbGsuDL3EKMEB7OSCK/T 2dNxQrwpiZVVqUX58UWlOanFhxhNgZ6byCwlmpwPTAR5JfGGpobmFpaG5sbmxmYWSuK8HQIH Y4QE0hNLUrNTUwtSi2D6mDg4gdHklVjJeXQ7U3XUt8oir3RR48NMsqkW1suft8o/eh91+8I0 prN1b+3Xv/TI5jPxM5VdHlhw1CSnVdqtrW/CRQHbpxVmE4Pkhed67TyeM7NxXWbJp7aGs0tX VM6xmz7lWtnB74ceasR2XtzyUXrhb6GOpl0rpp4v2rA7MpnblXUNX5plzoLWDeFKLMUZiYZa zEXFiQAGRfMWzAIAAA== X-CMS-MailID: 20201017031354eucas1p1196820dedcdcd0ef9c357c77513ad679 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> <20201010160508.19709-2-l.wojciechow@partner.samsung.com> Subject: Re: [dpdk-stable] [dpdk-dev] [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" All suggested changes applied and published in v8. W dniu 16.10.2020 o 01:47, Honnappa Nagarahalli pisze: > > >> 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; > volatile is not needed here as use of __atomic_load_n implies volatile inherently. retptr64 variable removed at all >> 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) > nit. we could avoid using the temp variable retptr64, you could use '&buf->retptr64[0]' directly. > RELAXED memory order should be good as the thread_fence below will ensure that this load does not sink. retptr64 variable removed and relaxed memory order used > > [1] >> + & 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 -- Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 l.wojciechow@partner.samsung.com