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 E0184A0C3F for ; Tue, 29 Jun 2021 18:11:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38502411C7; Tue, 29 Jun 2021 18:11:51 +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 D689F4117E for ; Tue, 29 Jun 2021 18:11:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624983107; 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=cP+XjcLIDCf8ElNwaeEu6XLhEofcNtQu2qhSsbWNAXs=; b=M6l77DMeC9MZu4kj2CtQKG2xZWE/dV7VmLsB/+Z03OgnA5aazAArk3J5t7X2CRhaEtX64e YIqCVxlIaFEFuTjTi0VunpSbtclLzuSbPYsOpr8RbfNgZOkdtgv0BX7DDp37Z7HAOR1fKj 4uITu/W3KvLfn6FEV7IxE8XnmVRGFx8= 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-2-6PtiYmf1P4WBacd0AcjFOQ-1; Tue, 29 Jun 2021 12:11:45 -0400 X-MC-Unique: 6PtiYmf1P4WBacd0AcjFOQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDD86A0CB7; Tue, 29 Jun 2021 16:11:44 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id B31295C1D0; Tue, 29 Jun 2021 16:11:43 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com Cc: Maxime Coquelin , stable@dpdk.org Date: Tue, 29 Jun 2021 18:11:27 +0200 Message-Id: <20210629161133.79472-2-maxime.coquelin@redhat.com> In-Reply-To: <20210629161133.79472-1-maxime.coquelin@redhat.com> References: <20210629161133.79472-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-stable] [PATCH v7 1/7] vhost: fix missing memory table NUMA realloc X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" When the guest allocates virtqueues on a different NUMA node than the one the Vhost metadata are allocated, both the Vhost device struct and the virtqueues struct are reallocated. However, reallocating the Vhost memory table was missing, which likely causes at least one cross-NUMA accesses for every burst of packets. This patch reallocates this table on the same NUMA node as the other metadata. Fixes: 552e8fd3d2b4 ("vhost: simplify memory regions handling") Cc: stable@dpdk.org Reported-by: David Marchand Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- lib/vhost/vhost_user.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 8f0eba6412..b5a84f3dcd 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -473,8 +473,8 @@ vhost_user_set_vring_num(struct virtio_net **pdev, } /* - * Reallocate virtio_dev and vhost_virtqueue data structure to make them on the - * same numa node as the memory of vring descriptor. + * Reallocate virtio_dev, vhost_virtqueue and related data structures to + * make them on the same numa node as the memory of vring descriptor. */ #ifdef RTE_LIBRTE_VHOST_NUMA static struct virtio_net* @@ -557,6 +557,9 @@ numa_realloc(struct virtio_net *dev, int index) goto out; } if (oldnode != newnode) { + struct rte_vhost_memory *old_mem; + ssize_t mem_size; + VHOST_LOG_CONFIG(INFO, "reallocate dev from %d to %d node\n", oldnode, newnode); @@ -568,6 +571,18 @@ numa_realloc(struct virtio_net *dev, int index) memcpy(dev, old_dev, sizeof(*dev)); rte_free(old_dev); + + mem_size = sizeof(struct rte_vhost_memory) + + sizeof(struct rte_vhost_mem_region) * dev->mem->nregions; + old_mem = dev->mem; + dev->mem = rte_malloc_socket(NULL, mem_size, 0, newnode); + if (!dev->mem) { + dev->mem = old_mem; + goto out; + } + + memcpy(dev->mem, old_mem, mem_size); + rte_free(old_mem); } out: -- 2.31.1