From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f175.google.com (mail-yw0-f175.google.com [209.85.161.175]) by dpdk.org (Postfix) with ESMTP id 486352BE5 for ; Fri, 3 Feb 2017 07:22:16 +0100 (CET) Received: by mail-yw0-f175.google.com with SMTP id l19so5979523ywc.2 for ; Thu, 02 Feb 2017 22:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0zvumSNrsCs6iB9sY+RkjnaXGwUfnDDTic7B6KSQbmk=; b=g13Inhj9eumuzQWDAZv0G59QRIHlDelA3rTaOzZXDmWskeRdJP4Kh4y0BkeoSjIJqI R20UIzEH/BK7OxYyw0A2rbirjqRd5eikmSNyXyMNv8g163s2I0eNozAg4cFsq0Ne3uLs MnQzLsKzZCAWdNuh+G+fDgbILZeiXN+X1Lodg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0zvumSNrsCs6iB9sY+RkjnaXGwUfnDDTic7B6KSQbmk=; b=IqclDcL0EUjrU7AEVPrsqqFVtoBr5Cjjecdn5Z6DeWi8dqwA1yHmo5s1hyNG5sGFhg 5K+byStENXs+qXaz0Lk/sduT9Fri6YvniIBtw0CKzsMRV1YZAYcCTBhOsh6gvNmp7GzR hxajZDEMtNzHQFW19bo9VobnbIsTnA0sf0ddvE/mMmPPrnwAoBMFO/QVV/YbQLcu/Aab aUMsQrQkF7GvHqNAJEgYnLx2+H2WR0uJqbVmWMgYA7oZ3HIQLyO8UbvN5KQvRmt4FhIV cwSVQs2xuuXI4MHuvbm0V/ApDhwdDcNyWgweAWjJwdvDh/hBwtR9hFlwcq8z3bL+/uli 3sNQ== X-Gm-Message-State: AIkVDXJ9fPgoLb7MKbRr5T+wDZide2FudBKgeinDV2QT0jx9qLgi1in5ttgwjPhc+uePaqJD/6PztohxpPBCiv0t X-Received: by 10.129.105.196 with SMTP id e187mr8158569ywc.221.1486102935524; Thu, 02 Feb 2017 22:22:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.200.4 with HTTP; Thu, 2 Feb 2017 22:22:15 -0800 (PST) In-Reply-To: <2601191342CEEE43887BDE71AB9772583F10FF87@irsmsx105.ger.corp.intel.com> References: <1482127758-4904-1-git-send-email-jianbo.liu@linaro.org> <2601191342CEEE43887BDE71AB9772583F10FF87@irsmsx105.ger.corp.intel.com> From: Jianbo Liu Date: Fri, 3 Feb 2017 14:22:15 +0800 Message-ID: To: "Ananyev, Konstantin" Cc: "dev@dpdk.org" , "Zhang, Helin" , "jerin.jacob@caviumnetworks.com" Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-dev] [PATCH 1/2] net/ixgbe: calculate the correct number of received packets in bulk alloc function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Feb 2017 06:22:16 -0000 On 2 February 2017 at 00:19, Ananyev, Konstantin wrote: > Hi, > >> -----Original Message----- >> From: Jianbo Liu [mailto:jianbo.liu@linaro.org] >> Sent: Monday, December 19, 2016 6:09 AM >> To: dev@dpdk.org; Zhang, Helin ; Ananyev, Konstantin ; >> jerin.jacob@caviumnetworks.com >> Cc: Jianbo Liu >> Subject: [PATCH 1/2] net/ixgbe: calculate the correct number of received packets in bulk alloc function >> >> To get better performance, Rx bulk alloc recv function will scan 8 descriptors >> in one time, but the statuses are not consistent on ARM platform because >> the memory allocated for Rx descriptors is cacheable hugepages. >> This patch is to calculate the number of received packets by scanning DD bit >> sequentially, and stops when meeting the first packet with DD bit unset. >> >> Signed-off-by: Jianbo Liu >> --- >> drivers/net/ixgbe/ixgbe_rxtx.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c >> index b2d9f45..2866bdb 100644 >> --- a/drivers/net/ixgbe/ixgbe_rxtx.c >> +++ b/drivers/net/ixgbe/ixgbe_rxtx.c >> @@ -1402,17 +1402,21 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) >> for (i = 0; i < RTE_PMD_IXGBE_RX_MAX_BURST; >> i += LOOK_AHEAD, rxdp += LOOK_AHEAD, rxep += LOOK_AHEAD) { >> /* Read desc statuses backwards to avoid race condition */ >> - for (j = LOOK_AHEAD-1; j >= 0; --j) >> + for (j = LOOK_AHEAD - 1; j >= 0; --j) { >> s[j] = rte_le_to_cpu_32(rxdp[j].wb.upper.status_error); >> - >> - for (j = LOOK_AHEAD - 1; j >= 0; --j) >> pkt_info[j] = rte_le_to_cpu_32(rxdp[j].wb.lower. >> lo_dword.data); >> + } >> + >> + rte_smp_rmb(); > > If reads can be reordered, shouldn't we fill pkt_info[] after smp_rmb() here? The barrier is to forbid the reordering from the following readings, which will count the number of actual received packets. And as wb.uper and wb.lower of one descriptor are in the same cacheline, could it be better to read them at the same time?. > As another nit - with rmb() in and because you are looking the first gap in s[] now, > no need to read TXDs in backward order. Reading backward is just to keep as it is for x86 platform. > How it looks to me (as a suggestion): > > for (j = 0; j != LOOK_AHEAD; j++) > s[j] = rte_le_to_cpu_32(rxdp[j].wb.upper.status_error); > > rte_smp_rmb(); > > for (j = 0; j < LOOK_AHEAD && (s[j] & IXGBE_RXDADV_STAT_DD) != 0; j++) > ; > > for (j = 0; j < nb_dd; ++j) { > pkt_info[j] = rte_le_to_cpu_32(rxdp[j].wb.lower.lo_dword.data); > .... > > Konstantin > > >> >> /* Compute how many status bits were set */ >> nb_dd = 0; >> for (j = 0; j < LOOK_AHEAD; ++j) >> - nb_dd += s[j] & IXGBE_RXDADV_STAT_DD; >> + if (s[j] & IXGBE_RXDADV_STAT_DD) >> + ++nb_dd; >> + else >> + break; >> >> nb_rx += nb_dd; >> >> -- >> 2.4.11 >