From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 04691A0579; Wed, 7 Apr 2021 12:19:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4346140E24; Wed, 7 Apr 2021 12:19:21 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 541D14013F for ; Wed, 7 Apr 2021 12:19:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617790757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4nUXP11oEMOcpk+t781Q7YYUq6F92oSdll/5NsleqPw=; b=FDXiPGq8DR8WmTeQYTccqJEk8KBLuBG8BIx2pQ4Kv2bRkJb53q3eTGJV+L9d1rOmJ5ZunZ /UHna2G+2lLH9/m0wF1ShHn3s79HKBZqdr70H8Ke//xvVFInKj8gz+5jG3YQ7mWJAGExr+ doh6H7Vrl8/fVLJBc7ajMx8G+g34Dzc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-ylEOUXpjMZSS26B_h1g8ag-1; Wed, 07 Apr 2021 06:19:15 -0400 X-MC-Unique: ylEOUXpjMZSS26B_h1g8ag-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E028A83DD24 for ; Wed, 7 Apr 2021 10:19:14 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-114-106.ams2.redhat.com [10.36.114.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12FF75D9D0; Wed, 7 Apr 2021 10:19:13 +0000 (UTC) From: Balazs Nemeth To: bnemeth@redhat.com, dev@dpdk.org Date: Wed, 7 Apr 2021 12:17:19 +0200 Message-Id: <589dabc3c3a22a8e297e09cb554810aa811bc9a7.1617790501.git.bnemeth@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bnemeth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2 2/4] vhost: perform all mbuf allocations in one loop X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Move allocation out further and perform all allocation in one loop. The same goes for freeing packets. This is to prepare for use of bulk versions of these functions. Signed-off-by: Balazs Nemeth --- lib/librte_vhost/virtio_net.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 666e7fdb8..496f750e3 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -2471,14 +2471,13 @@ virtio_dev_tx_packed(struct virtio_net *dev, uint32_t remained = count; uint16_t i; + for (i = 0; i < count; ++i) + pkts[i] = rte_pktmbuf_alloc(mbuf_pool); + do { rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]); if (remained >= PACKED_BATCH_SIZE) { - vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { - pkts[pkt_idx + i] = - rte_pktmbuf_alloc(mbuf_pool); - } if (!virtio_dev_tx_batch_packed(dev, vq, &pkts[pkt_idx])) { @@ -2486,19 +2485,11 @@ virtio_dev_tx_packed(struct virtio_net *dev, remained -= PACKED_BATCH_SIZE; continue; - } else { - vhost_for_each_try_unroll(i, 0, - PACKED_BATCH_SIZE) { - rte_pktmbuf_free(pkts[pkt_idx + i]); - } } } - pkts[pkt_idx] = rte_pktmbuf_alloc(mbuf_pool); - if (virtio_dev_tx_single_packed(dev, vq, mbuf_pool, &pkts[pkt_idx])) { - rte_pktmbuf_free(pkts[pkt_idx]); break; } pkt_idx++; @@ -2506,6 +2497,9 @@ virtio_dev_tx_packed(struct virtio_net *dev, } while (remained); + for (i = pkt_idx; i < count; ++i) + rte_pktmbuf_free(pkts[i]); + if (vq->shadow_used_idx) { do_data_copy_dequeue(vq); -- 2.30.2