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 56C7AA04C0 for ; Sat, 26 Sep 2020 00:42:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 774CC1EA49; Sat, 26 Sep 2020 00:42:37 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 302171E9CF for ; Sat, 26 Sep 2020 00:42:22 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200925224221euoutp0201a8e15216b349c87c4f18764ae009f1~4KBXhb4U22280822808euoutp02K for ; Fri, 25 Sep 2020 22:42:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200925224221euoutp0201a8e15216b349c87c4f18764ae009f1~4KBXhb4U22280822808euoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601073742; bh=IT34NvI0qjZfN3aPvUwJ3M46g2VUjNeBE+s1ltqL+k0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RKoS4cBWeu8itnHCO4rMIMJEZ+fDm5BKmCvG+T7ldx1D3msZz7OfXMW4ldeafLGwE nxni9g97dJfMZA9mrUGs5kdgeMW4LADF3h3ibc3hjHCIwqqRK0188cNUWpqQub0Gr8 4kLfyosX4+jKDqEttAj9l3vg3Wmi8qy20gyIWvhU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200925224221eucas1p1e1273097e8b022f7cc42fff288efafb7~4KBXDxudl2913529135eucas1p1r; Fri, 25 Sep 2020 22:42:21 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id AB.6B.06456.D427E6F5; Fri, 25 Sep 2020 23:42:21 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200925224220eucas1p1a44e99a1d7750d37d5aefa61f329209b~4KBWPlaxZ2520225202eucas1p1k; Fri, 25 Sep 2020 22:42:20 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200925224220eusmtrp1734e2776cd89a7d7a2ca510edbe34119~4KBWPAuqv1720917209eusmtrp1_; Fri, 25 Sep 2020 22:42:20 +0000 (GMT) X-AuditID: cbfec7f2-7efff70000001938-01-5f6e724df185 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CE.3C.06314.C427E6F5; Fri, 25 Sep 2020 23:42:20 +0100 (BST) Received: from localhost.localdomain (unknown [106.210.88.70]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200925224219eusmtip2df9d51e9c6d8d4ad8ea7c8115a6ae764~4KBVoIEva1081510815eusmtip23; Fri, 25 Sep 2020 22:42:19 +0000 (GMT) From: Lukasz Wojciechowski To: David Hunt , Bruce Richardson Cc: dev@dpdk.org, l.wojciechow@partner.samsung.com, stable@dpdk.org Date: Sat, 26 Sep 2020 00:42:07 +0200 Message-Id: <20200925224209.12173-7-l.wojciechow@partner.samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200925224209.12173-1-l.wojciechow@partner.samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRmVeSWpSXmKPExsWy7djPc7q+RXnxBsubpS1urLK36Jv0kcni 3aftTBbPetYxWvzr+MPuwOrxa8FSVo/Fe14yeRx8t4cpgDmKyyYlNSezLLVI3y6BK2Pl+pfM BadFK152/GRuYFwv1MXIySEhYCKx+twcti5GLg4hgRWMEq+/LGAGSQgJfGGUeHxRH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sMQvE fHmJ1RsOgNVzCrhJfNs3lxliVyOjRM+bPtYJjHwLGBlWMYqklhbnpucWG+oVJ+YWl+al6yXn 525iBIbitmM/N+9gvLQx+BCjAAejEg/viUe58UKsiWXFlbmHGCU4mJVEeJ3Ono4T4k1JrKxK LcqPLyrNSS0+xGgKdNVEZinR5HxgnOSVxBuaGppbWBqaG5sbm1koifN2CByMERJITyxJzU5N LUgtgulj4uCUamCUCnzwb+nEm+fjBHNO8EY9S5H98XI5Q9d2D3HJSK+0uSz5BrYLta5v8GJ5 7+IXMaH5AneqjEbdo2i5qPpn7h87Vy9MOaf8QXun9N16i+fX3eY8sjFefc3stGDuUtbSsrPf alwfxje98pn0Q1TPLqC2r1QtrfXuvoJsV9O586cv23epJuQpL78SS3FGoqEWc1FxIgCAzv99 WwIAAA== X-CMS-MailID: 20200925224220eucas1p1a44e99a1d7750d37d5aefa61f329209b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200925224220eucas1p1a44e99a1d7750d37d5aefa61f329209b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200925224220eucas1p1a44e99a1d7750d37d5aefa61f329209b References: <20200923132541.21417-1-l.wojciechow@partner.samsung.com> <20200925224209.12173-1-l.wojciechow@partner.samsung.com> Subject: [dpdk-stable] [PATCH v4 6/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 8a12bf856..dd68bc233 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