From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C07C6568F for ; Fri, 20 Mar 2015 17:54:15 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 20 Mar 2015 09:54:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,437,1422950400"; d="scan'208";a="543902319" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by orsmga003.jf.intel.com with ESMTP; 20 Mar 2015 09:54:13 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sat, 21 Mar 2015 00:54:12 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.36]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.108]) with mapi id 14.03.0224.002; Sat, 21 Mar 2015 00:54:05 +0800 From: "Xie, Huawei" To: linhaifeng , "dev@dpdk.org" Thread-Topic: [PATCH] lib/librte_pmd_virtio fix can't receive packets after rx_q is empty Thread-Index: AdBjLnlvftTdwbn/R/+zVnDJIPL/qg== Date: Fri, 20 Mar 2015 16:54:05 +0000 Message-ID: References: <1426848383-15764-1-git-send-email-haifeng.lin@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] lib/librte_pmd_virtio fix can't receive packets after rx_q is empty 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, 20 Mar 2015 16:54:16 -0000 On 3/20/2015 6:47 PM, linhaifeng wrote:=0A= > From: Linhaifeng =0A= >=0A= > If failed to alloc mbuf ring_size times the rx_q may be empty and can't= =0A= > receive any packets forever because nb_used is 0 forever.=0A= Agreed. In current implementation, once VQ becomes empty, we have no=0A= chance to refill it again.=0A= The simple fix is, receive one and then refill one as other PMDs. Need=0A= to consider which is best strategy in terms of performance in future.=0A= How did you find this? through code review or real workload?=0A= > so we should try to refill when nb_used is 0.After otherone free mbuf=0A= > we can restart to receive packets.=0A= >=0A= > Signed-off-by: Linhaifeng =0A= > ---=0A= > lib/librte_pmd_virtio/virtio_rxtx.c | 3 ++-=0A= > 1 file changed, 2 insertions(+), 1 deletion(-)=0A= >=0A= > diff --git a/lib/librte_pmd_virtio/virtio_rxtx.c b/lib/librte_pmd_virtio/= virtio_rxtx.c=0A= > index 1d74b34..5c7e0cd 100644=0A= > --- a/lib/librte_pmd_virtio/virtio_rxtx.c=0A= > +++ b/lib/librte_pmd_virtio/virtio_rxtx.c=0A= > @@ -495,7 +495,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx= _pkts, uint16_t nb_pkts)=0A= > num =3D num - ((rxvq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);= =0A= > =0A= > if (num =3D=3D 0)=0A= > - return 0;=0A= > + goto refill;=0A= > =0A= > num =3D virtqueue_dequeue_burst_rx(rxvq, rcv_pkts, len, num);=0A= > PMD_RX_LOG(DEBUG, "used:%d dequeue:%d", nb_used, num);=0A= > @@ -536,6 +536,7 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx= _pkts, uint16_t nb_pkts)=0A= > =0A= > rxvq->packets +=3D nb_rx;=0A= > =0A= > +refill:=0A= > /* Allocate new mbuf for the used descriptor */=0A= > error =3D ENOSPC;=0A= > while (likely(!virtqueue_full(rxvq))) {=0A= =0A=