From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v2 1/7] vhost: refactor rte_vhost_dequeue_burst Date: Fri, 4 Mar 2016 10:17:05 +0800 Message-ID: <20160304021705.GT14300@yliu-dev.sh.intel.com> References: <1449122773-25510-1-git-send-email-yuanhan.liu@linux.intel.com> <1455803352-5518-1-git-send-email-yuanhan.liu@linux.intel.com> <1455803352-5518-2-git-send-email-yuanhan.liu@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "Michael S. Tsirkin" , "dev@dpdk.org" , Victor Kaplansky To: "Xie, Huawei" Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id EAFE32BC9 for ; Fri, 4 Mar 2016 03:15:30 +0100 (CET) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Mar 03, 2016 at 04:30:42PM +0000, Xie, Huawei wrote: > On 2/18/2016 9:48 PM, Yuanhan Liu wrote: > > + mbuf_avail = 0; > > + mbuf_offset = 0; > > + while (desc_avail || (desc->flags & VRING_DESC_F_NEXT) != 0) { > > + /* This desc reachs to its end, get the next one */ > > + if (desc_avail == 0) { > > + desc = &vq->desc[desc->next]; > > + > > + desc_addr = gpa_to_vva(dev, desc->addr); > > + rte_prefetch0((void *)(uintptr_t)desc_addr); > > + > > + desc_offset = 0; > > + desc_avail = desc->len; > > + > > + PRINT_PACKET(dev, (uintptr_t)desc_addr, desc->len, 0); > > + } > > + > > + /* > > + * This mbuf reachs to its end, get a new one > > + * to hold more data. > > + */ > > + if (mbuf_avail == 0) { > > + cur = rte_pktmbuf_alloc(mbuf_pool); > > + if (unlikely(!cur)) { > > + RTE_LOG(ERR, VHOST_DATA, "Failed to " > > + "allocate memory for mbuf.\n"); > > + if (head) > > + rte_pktmbuf_free(head); > > + return NULL; > > + } > > We could always allocate the head mbuf before the loop, then we save the > following branch and make the code more streamlined. > It reminds me that this change prevents the possibility of mbuf bulk > allocation, one solution is we pass the head mbuf from an additional > parameter. Yep, that's also something I have thought of. > Btw, put unlikely before the check of mbuf_avail and checks elsewhere. I don't think so. It would benifit for the small packets. What if, however, when TSO or jumbo frame is enabled that we have big packets? --yliu