From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D10B37E2F for ; Fri, 26 Sep 2014 12:30:01 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 26 Sep 2014 03:36:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,604,1406617200"; d="scan'208";a="609020348" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2014 03:36:07 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX104.ger.corp.intel.com (163.33.3.159) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 26 Sep 2014 11:34:29 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.248]) by IRSMSX155.ger.corp.intel.com ([169.254.14.152]) with mapi id 14.03.0195.001; Fri, 26 Sep 2014 11:34:29 +0100 From: "Ananyev, Konstantin" To: "Nemeth, Balazs" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ixgbe: fix crash caused by bulk allocation failure in vector pmd Thread-Index: AQHP2XA2kr1XxVYGWkq4ujy4DwqJmJwTN3dw Date: Fri, 26 Sep 2014 10:34:28 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772582137C148@IRSMSX104.ger.corp.intel.com> References: <1411725440-4520-1-git-send-email-balazs.nemeth@intel.com> In-Reply-To: <1411725440-4520-1-git-send-email-balazs.nemeth@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "Nemeth, Balazs" Subject: Re: [dpdk-dev] [PATCH] ixgbe: fix crash caused by bulk allocation failure in vector pmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Sep 2014 10:30:02 -0000 > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Balazs Nemeth > Sent: Friday, September 26, 2014 10:57 AM > To: dev@dpdk.org > Cc: Nemeth, Balazs > Subject: [dpdk-dev] [PATCH] ixgbe: fix crash caused by bulk allocation fa= ilure in vector pmd >=20 > Since the introduction of vector PMD, a bug in ixgbe_rxq_rearm could > cause a crash. As long as the memory pool allocated to the RX queue > has mbufs available, there is no problem. After allocation of _all_ > mbufs from the memory pool, previously returned mbufs by > rte_eth_rx_burst could be accessed by subsequent calls to the PMD and > could be returned by subsequent calls to rte_eth_rx_burst. From the > perspective of the application, the means that fields within the mbuf > could change and that previously allocated mbufs could appear multiple > times. >=20 > After failure of mbuf allocation, the dd bits should indicate that the > packets are not ready. For this, this patch adds code to reset the dd > bits in the first RTE_IXGBE_DESCS_PER_LOOP packets of the next > RTE_IXGBE_RXQ_REARM_THRESH packets only if the next > RTE_IXGBE_RXQ_REARM_THRESH packets that will be accessed contain > previously allocated packets. >=20 > Setting the bits is not enough. The bits are checked _after_ setting > the mbuf fields, thus a mechanism is needed to prevent the previously > used mbuf pointers from being accessed during the speculative load of > the mbuf fields. For this reason, not only the dd bits are reset, but > also the mbufs associated to those descriptors are set to point to a > "fake" mbuf. >=20 > Signed-off-by: Balazs Nemeth > --- > lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c b/lib/librte_pmd_ixgbe= /ixgbe_rxtx_vec.c > index 203ddf7..457f267 100644 > --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c > +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx_vec.c > @@ -54,17 +54,28 @@ ixgbe_rxq_rearm(struct igb_rx_queue *rxq) > struct rte_mbuf *mb0, *mb1; > __m128i hdr_room =3D _mm_set_epi64x(RTE_PKTMBUF_HEADROOM, > RTE_PKTMBUF_HEADROOM); > + __m128i dma_addr0, dma_addr1; > + > + rxdp =3D rxq->rx_ring + rxq->rxrearm_start; >=20 > /* Pull 'n' more MBUFs into the software ring */ > if (rte_mempool_get_bulk(rxq->mb_pool, > - (void *)rxep, RTE_IXGBE_RXQ_REARM_THRESH) < 0) > + (void *)rxep, > + RTE_IXGBE_RXQ_REARM_THRESH) < 0) { > + if (rxq->rxrearm_nb + RTE_IXGBE_RXQ_REARM_THRESH >=3D > + rxq->nb_rx_desc) { > + dma_addr0 =3D _mm_xor_si128(dma_addr0, dma_addr0); > + for (i =3D 0; i < RTE_IXGBE_DESCS_PER_LOOP; i++) { > + rxep[i].mbuf =3D &rxq->fake_mbuf; > + _mm_store_si128((__m128i *)&rxdp[i].read, > + dma_addr0); > + } > + } > return; > - > - rxdp =3D rxq->rx_ring + rxq->rxrearm_start; > + } >=20 > /* Initialize the mbufs in vector, process 2 mbufs in one loop */ > for (i =3D 0; i < RTE_IXGBE_RXQ_REARM_THRESH; i +=3D 2, rxep +=3D 2) { > - __m128i dma_addr0, dma_addr1; > __m128i vaddr0, vaddr1; >=20 > mb0 =3D rxep[0].mbuf; > -- > 2.1.0 Acked-by: Konstantin Ananyev