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 8DA81A0A0F; Wed, 30 Jun 2021 13:16:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 057E640141; Wed, 30 Jun 2021 13:16:52 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id F413D40040 for ; Wed, 30 Jun 2021 13:16:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625051809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W01N/by3PiZ9qP9sC6STW6idj0B4Z+EQacS0mHNJeSQ=; b=UFw3HybDEDofUqKvdWNvbVi20DX2SJbCzENMykM/jRbAMXg0CteKlsI0ObxWaSgfxpuVgj Hz93pxRMGEGO/Ha3Ak8XRu8tnCZrQD3cZ/bwzcaufrA2mMLKubi95sUL8clO7EHUGsxIXu 0nftghIHeqR3t7s/sZuvLecFg9alRa8= 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-204-5J9nP2sNNCOIcqixKlu6SQ-1; Wed, 30 Jun 2021 07:16:32 -0400 X-MC-Unique: 5J9nP2sNNCOIcqixKlu6SQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0780C18D6A2F; Wed, 30 Jun 2021 11:16:32 +0000 (UTC) Received: from [10.36.110.32] (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FE575D6AD; Wed, 30 Jun 2021 11:16:27 +0000 (UTC) To: David Marchand Cc: dev , "Xia, Chenbo" References: <20210629161133.79472-1-maxime.coquelin@redhat.com> <20210629161133.79472-8-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: Date: Wed, 30 Jun 2021 13:16:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v7 7/7] vhost: convert inflight data to DPDK allocation API 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" On 6/30/21 9:55 AM, David Marchand wrote: > On Tue, Jun 29, 2021 at 6:11 PM Maxime Coquelin > wrote: >> >> Inflight metadata are allocated using glibc's calloc. >> This patch converts them to rte_zmalloc_socket to take >> care of the NUMA affinity. > > About the title, maybe: > vhost: use DPDK allocations for inflight data Agree with your proposal. >> >> Signed-off-by: Maxime Coquelin > > [snip] > >> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c >> index d8ec087dfc..67935c4ccc 100644 >> --- a/lib/vhost/vhost_user.c >> +++ b/lib/vhost/vhost_user.c > > [snip] > >> @@ -1779,19 +1820,21 @@ vhost_check_queue_inflights_split(struct virtio_net *dev, >> vq->last_avail_idx += resubmit_num; >> >> if (resubmit_num) { >> - resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info)); >> + resubmit = rte_zmalloc_socket("resubmit", sizeof(struct rte_vhost_resubmit_info), > > Nit: double space. > Can be fixed while applying. >> + 0, vq->numa_node); >> if (!resubmit) { >> VHOST_LOG_CONFIG(ERR, >> "failed to allocate memory for resubmit info.\n"); >> return RTE_VHOST_MSG_RESULT_ERR; >> } >> >> - resubmit->resubmit_list = calloc(resubmit_num, >> - sizeof(struct rte_vhost_resubmit_desc)); >> + resubmit->resubmit_list = rte_zmalloc_socket("resubmit_list", >> + resubmit_num * sizeof(struct rte_vhost_resubmit_desc), >> + 0, vq->numa_node); >> if (!resubmit->resubmit_list) { >> VHOST_LOG_CONFIG(ERR, >> "failed to allocate memory for inflight desc.\n"); >> - free(resubmit); >> + rte_free(resubmit); >> return RTE_VHOST_MSG_RESULT_ERR; >> } >> >> @@ -1873,19 +1916,21 @@ vhost_check_queue_inflights_packed(struct virtio_net *dev, >> } >> >> if (resubmit_num) { >> - resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info)); >> + resubmit = rte_zmalloc_socket("resubmit", sizeof(struct rte_vhost_resubmit_info), > > Copy/paste detected :-) > Double space. Indeed! > Having a single allocator between split and packed implems would avoid > this, but it might not be that easy and this is out of the scope for > this patch. > Agree, I think the inflight code may be simpler. We can think of a refactoring for v21.11. Thanks, Maxime > >> + 0, vq->numa_node); >> if (resubmit == NULL) { >> VHOST_LOG_CONFIG(ERR, >> "failed to allocate memory for resubmit info.\n"); >> return RTE_VHOST_MSG_RESULT_ERR; >> } >> >> - resubmit->resubmit_list = calloc(resubmit_num, >> - sizeof(struct rte_vhost_resubmit_desc)); >> + resubmit->resubmit_list = rte_zmalloc_socket("resubmit_list", >> + resubmit_num * sizeof(struct rte_vhost_resubmit_desc), >> + 0, vq->numa_node); >> if (resubmit->resubmit_list == NULL) { >> VHOST_LOG_CONFIG(ERR, >> "failed to allocate memory for resubmit desc.\n"); >> - free(resubmit); >> + rte_free(resubmit); >> return RTE_VHOST_MSG_RESULT_ERR; >> } >> >> -- >> 2.31.1 >> > >