From patchwork Thu Jun 17 15:37:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 94364 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CEB33A0C4B; Thu, 17 Jun 2021 17:37:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8D05410E4; Thu, 17 Jun 2021 17:37:59 +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 BDB8E410E3 for ; Thu, 17 Jun 2021 17:37:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623944277; 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=oJhGR6NiPWyKfoOC8Q6Oj2J0o69GIZIwPS2nwBQYCOY=; b=I8pRCTZqJEuVNuRwtiHYxDorA4BUwh577xxbBeicocrXbiOFSr6pHgHH3/MKmEUAH48JPT JuMFgcULVlv7tduKjZN7nzrvZpACN6wtXZtfw9Kh3eoLhm9xeY5T/SHEPMRiZC9U/xcyGx QEKru/XYuf5sA1Jm3v76XCGxdvSR9OE= 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-539-dxSpFFWJME2ij7Nnmm0QhA-1; Thu, 17 Jun 2021 11:37:56 -0400 X-MC-Unique: dxSpFFWJME2ij7Nnmm0QhA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B77E6101C8A8; Thu, 17 Jun 2021 15:37:55 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6EF360E3A; Thu, 17 Jun 2021 15:37:49 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbo.xia@intel.com Cc: Maxime Coquelin , stable@dpdk.org Date: Thu, 17 Jun 2021 17:37:33 +0200 Message-Id: <20210617153739.178011-2-maxime.coquelin@redhat.com> In-Reply-To: <20210617153739.178011-1-maxime.coquelin@redhat.com> References: <20210617153739.178011-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Subject: [dpdk-dev] [PATCH v4 1/7] vhost: fix missing memory table NUMA realloc 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" 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 iat 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 --- lib/vhost/vhost_user.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 8f0eba6412..031e3bfa2f 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -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: