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 030ECA0546; Tue, 6 Apr 2021 17:45:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BA6D14123F; Tue, 6 Apr 2021 17:45:11 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id 10CBF14123F for ; Tue, 6 Apr 2021 17:45:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617723909; 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=bNMkQSDM37iQgeXBsO03T/H5kNmjktBosWEsQfowfr4=; b=dIKuLnDQ7iz/kN/JXaMNoANH6QieAAhbGGqwydw/czdbvXFQqBTv+1Sh52Exods0UdjYBa LeO+BCAQQgWafTrLDxF9Ydszh+xA/MdehtOFHzUftgsCmIB8cvrI5e8elYENI15dHWTaSE 0euJ137OOWeX2khP5IixO4Vj5eJYZ6c= 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-506-esBT-yVSMnGE-8OzQLWC2Q-1; Tue, 06 Apr 2021 11:45:08 -0400 X-MC-Unique: esBT-yVSMnGE-8OzQLWC2Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A55CF81746A for ; Tue, 6 Apr 2021 15:45:06 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-112-176.ams2.redhat.com [10.36.112.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9E1E6A03B; Tue, 6 Apr 2021 15:45:02 +0000 (UTC) From: Balazs Nemeth To: bnemeth@redhat.com, dev@dpdk.org Date: Tue, 6 Apr 2021 17:44:45 +0200 Message-Id: <431a22e899c4491e6af747714ff4cc6fb9ed2c28.1617723339.git.bnemeth@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 3/4] vhost: allocate and free packets in bulk 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" Now that all allocation and freeing has been moved together, use the faster bulk versions instead of handling packets one by one. Signed-off-by: Balazs Nemeth --- lib/librte_vhost/virtio_net.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 496f750e3..e1696c0c0 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -2471,8 +2471,9 @@ 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); + if (rte_pktmbuf_alloc_bulk(mbuf_pool, pkts, count)) { + return 0; + } do { rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]); @@ -2497,8 +2498,9 @@ virtio_dev_tx_packed(struct virtio_net *dev, } while (remained); - for (i = pkt_idx; i < count; ++i) - rte_pktmbuf_free(pkts[i]); + if (pkt_idx != count) { + rte_pktmbuf_free_bulk(&pkts[pkt_idx], count - pkt_idx); + } if (vq->shadow_used_idx) { do_data_copy_dequeue(vq); -- 2.30.2