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 AEBF8A04BB for ; Thu, 17 Sep 2020 15:22:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 806761D667; Thu, 17 Sep 2020 15:22:10 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 2CE621D65B; Thu, 17 Sep 2020 15:22:07 +0200 (CEST) IronPort-SDR: 6XyAWoRDQTyOpZSsfk798s/kmGZmYYuoi2fmRg4m3w4qrOmVzlV/iMGLBULygvuw5GzPJb5ROo /oezgi+12MHA== X-IronPort-AV: E=McAfee;i="6000,8403,9746"; a="147380431" X-IronPort-AV: E=Sophos;i="5.76,437,1592895600"; d="scan'208";a="147380431" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 06:22:05 -0700 IronPort-SDR: /gw/FXEtCUugCQOw8+FiIgxxc2/+8IXX34DgnuAXR+sOJwP2/p2akGYIBnruh/f6O3gPvfhrWE mLNIAdi6pSsg== X-IronPort-AV: E=Sophos;i="5.76,437,1592895600"; d="scan'208";a="483743603" Received: from dhunt5-mobl5.ger.corp.intel.com (HELO [10.213.228.49]) ([10.213.228.49]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 06:22:04 -0700 To: Lukasz Wojciechowski , Bruce Richardson Cc: dev@dpdk.org, stable@dpdk.org References: <20200915193449.13310-1-l.wojciechow@partner.samsung.com> <20200915193449.13310-6-l.wojciechow@partner.samsung.com> From: David Hunt Message-ID: <3d40b114-bde2-1591-bc59-b4e6c56ab09e@intel.com> Date: Thu, 17 Sep 2020 14:22:03 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200915193449.13310-6-l.wojciechow@partner.samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [dpdk-stable] [PATCH v1 5/6] 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" Hi Lukasz, On 15/9/2020 8:34 PM, Lukasz Wojciechowski wrote: > 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. > > Fixes: 775003ad2f96 ("distributor: add new burst-capable library") > Cc: david.hunt@intel.com > Cc: stable@dpdk.org > > Signed-off-by: Lukasz Wojciechowski > --- > lib/librte_distributor/rte_distributor.c | 14 ++++++++++++++ > 1 file changed, 14 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(); > + } > + The 'unlikely' is appropriate, but when it does occur, this looks to be a necessary addition. And I've confirmed no loss in performance on my system. Acked-by: David Hunt