Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/94199/?format=api
https://patches.dpdk.org/api/patches/94199/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210615084241.139097-5-maxime.coquelin@redhat.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20210615084241.139097-5-maxime.coquelin@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20210615084241.139097-5-maxime.coquelin@redhat.com", "date": "2021-06-15T08:42:39", "name": "[v2,4/6] vhost: improve NUMA reallocation", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "6d98195535a6e8850c95f97589ecffa418b28dd5", "submitter": { "id": 512, "url": "https://patches.dpdk.org/api/people/512/?format=api", "name": "Maxime Coquelin", "email": "maxime.coquelin@redhat.com" }, "delegate": { "id": 2642, "url": "https://patches.dpdk.org/api/users/2642/?format=api", "username": "mcoquelin", "first_name": "Maxime", "last_name": "Coquelin", "email": "maxime.coquelin@redhat.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210615084241.139097-5-maxime.coquelin@redhat.com/mbox/", "series": [ { "id": 17329, "url": "https://patches.dpdk.org/api/series/17329/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17329", "date": "2021-06-15T08:42:35", "name": "vhost: Fix and improve NUMA reallocation", "version": 2, "mbox": "https://patches.dpdk.org/series/17329/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/94199/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/94199/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 5ECBAA0C49;\n\tTue, 15 Jun 2021 10:43:20 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id CD46C41139;\n\tTue, 15 Jun 2021 10:43:01 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by mails.dpdk.org (Postfix) with ESMTP id 2683E4111C\n for <dev@dpdk.org>; Tue, 15 Jun 2021 10:43:00 +0200 (CEST)", "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-12-n3TEHXXQNmylr3wEpZnEEQ-1; Tue, 15 Jun 2021 04:42:58 -0400", "from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com\n [10.5.11.13])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DC521100B3B3;\n Tue, 15 Jun 2021 08:42:57 +0000 (UTC)", "from max-t490s.redhat.com (unknown [10.36.110.45])\n by smtp.corp.redhat.com (Postfix) with ESMTP id C5FDD60C03;\n Tue, 15 Jun 2021 08:42:56 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1623746579;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=K+z7Jo/200WlKSIXD2w5eb9cO/hJDga7W1usSb/syNY=;\n b=dOwB/GdFrl2zdccSVKOYll1BaUtftmDxTVoXkXpQRSsu3cLMfuCbND9FdorkL5Eb7asHUf\n eoQnVNAVpOoyMvUAmxghj4wqwz8NvY22pyDb1a7iPkX0aaxXxyD155bLd+szIY48KjukB7\n 8kTuesaoFG+Bnpo0t+zxeBK53C2x94U=", "X-MC-Unique": "n3TEHXXQNmylr3wEpZnEEQ-1", "From": "Maxime Coquelin <maxime.coquelin@redhat.com>", "To": "dev@dpdk.org,\n\tdavid.marchand@redhat.com,\n\tchenbo.xia@intel.com", "Cc": "Maxime Coquelin <maxime.coquelin@redhat.com>", "Date": "Tue, 15 Jun 2021 10:42:39 +0200", "Message-Id": "<20210615084241.139097-5-maxime.coquelin@redhat.com>", "In-Reply-To": "<20210615084241.139097-1-maxime.coquelin@redhat.com>", "References": "<20210615084241.139097-1-maxime.coquelin@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "Authentication-Results": "relay.mimecast.com;\n 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-dev] [PATCH v2 4/6] vhost: improve NUMA reallocation", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "This patch improves the numa_realloc() function by making use\nof rte_realloc_socket(), which takes care of the memory copy\nand freeing of the old data.\n\nSuggested-by: David Marchand <david.marchand@redhat.com>\nSigned-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>\n---\n lib/vhost/vhost_user.c | 177 +++++++++++++++++------------------------\n 1 file changed, 73 insertions(+), 104 deletions(-)", "diff": "diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c\nindex 0e9e26ebe0..b298312db6 100644\n--- a/lib/vhost/vhost_user.c\n+++ b/lib/vhost/vhost_user.c\n@@ -480,139 +480,108 @@ vhost_user_set_vring_num(struct virtio_net **pdev,\n static struct virtio_net*\n numa_realloc(struct virtio_net *dev, int index)\n {\n-\tint oldnode, newnode;\n+\tint node;\n \tstruct virtio_net *old_dev;\n-\tstruct vhost_virtqueue *old_vq, *vq;\n-\tstruct vring_used_elem *new_shadow_used_split;\n-\tstruct vring_used_elem_packed *new_shadow_used_packed;\n-\tstruct batch_copy_elem *new_batch_copy_elems;\n+\tstruct vhost_virtqueue *vq;\n+\tstruct batch_copy_elem *bce;\n+\tstruct guest_page *gp;\n+\tstruct rte_vhost_memory *mem;\n+\tsize_t mem_size;\n \tint ret;\n \n \tif (dev->flags & VIRTIO_DEV_RUNNING)\n \t\treturn dev;\n \n \told_dev = dev;\n-\tvq = old_vq = dev->virtqueue[index];\n-\n-\tret = get_mempolicy(&newnode, NULL, 0, old_vq->desc,\n-\t\t\t MPOL_F_NODE | MPOL_F_ADDR);\n+\tvq = dev->virtqueue[index];\n \n-\t/* check if we need to reallocate vq */\n-\tret |= get_mempolicy(&oldnode, NULL, 0, old_vq,\n-\t\t\t MPOL_F_NODE | MPOL_F_ADDR);\n+\tret = get_mempolicy(&node, NULL, 0, vq->desc, MPOL_F_NODE | MPOL_F_ADDR);\n \tif (ret) {\n-\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\"Unable to get vq numa information.\\n\");\n+\t\tVHOST_LOG_CONFIG(ERR, \"Unable to get virtqueue %d numa information.\\n\", index);\n \t\treturn dev;\n \t}\n-\tif (oldnode != newnode) {\n-\t\tVHOST_LOG_CONFIG(INFO,\n-\t\t\t\"reallocate vq from %d to %d node\\n\", oldnode, newnode);\n-\t\tvq = rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);\n-\t\tif (!vq)\n-\t\t\treturn dev;\n \n-\t\tmemcpy(vq, old_vq, sizeof(*vq));\n+\tvq = rte_realloc_socket(vq, sizeof(*vq), 0, node);\n+\tif (!vq) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc virtqueue %d on node %d\\n\",\n+\t\t\t\tindex, node);\n+\t\treturn dev;\n+\t}\n \n-\t\tif (vq_is_packed(dev)) {\n-\t\t\tnew_shadow_used_packed = rte_malloc_socket(NULL,\n-\t\t\t\t\tvq->size *\n-\t\t\t\t\tsizeof(struct vring_used_elem_packed),\n-\t\t\t\t\tRTE_CACHE_LINE_SIZE,\n-\t\t\t\t\tnewnode);\n-\t\t\tif (new_shadow_used_packed) {\n-\t\t\t\trte_free(vq->shadow_used_packed);\n-\t\t\t\tvq->shadow_used_packed = new_shadow_used_packed;\n-\t\t\t}\n-\t\t} else {\n-\t\t\tnew_shadow_used_split = rte_malloc_socket(NULL,\n-\t\t\t\t\tvq->size *\n-\t\t\t\t\tsizeof(struct vring_used_elem),\n-\t\t\t\t\tRTE_CACHE_LINE_SIZE,\n-\t\t\t\t\tnewnode);\n-\t\t\tif (new_shadow_used_split) {\n-\t\t\t\trte_free(vq->shadow_used_split);\n-\t\t\t\tvq->shadow_used_split = new_shadow_used_split;\n-\t\t\t}\n-\t\t}\n+\tif (vq != dev->virtqueue[index]) {\n+\t\tVHOST_LOG_CONFIG(INFO, \"reallocated virtqueue on node %d\\n\", node);\n+\t\tdev->virtqueue[index] = vq;\n+\t\tvhost_user_iotlb_init(dev, index);\n+\t}\n \n-\t\tnew_batch_copy_elems = rte_malloc_socket(NULL,\n-\t\t\tvq->size * sizeof(struct batch_copy_elem),\n-\t\t\tRTE_CACHE_LINE_SIZE,\n-\t\t\tnewnode);\n-\t\tif (new_batch_copy_elems) {\n-\t\t\trte_free(vq->batch_copy_elems);\n-\t\t\tvq->batch_copy_elems = new_batch_copy_elems;\n+\tif (vq_is_packed(dev)) {\n+\t\tstruct vring_used_elem_packed *sup;\n+\n+\t\tsup = rte_realloc_socket(vq->shadow_used_packed, vq->size * sizeof(*sup),\n+\t\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\t\tif (!sup) {\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc shadow packed on node %d\\n\", node);\n+\t\t\treturn dev;\n \t\t}\n+\t\tvq->shadow_used_packed = sup;\n \n-\t\tif (vq->log_cache) {\n-\t\t\tstruct log_cache_entry *log_cache;\n+\t} else {\n+\t\tstruct vring_used_elem *sus;\n \n-\t\t\tlog_cache = rte_realloc_socket(vq->log_cache,\n-\t\t\t\t\tsizeof(struct log_cache_entry) * VHOST_LOG_CACHE_NR,\n-\t\t\t\t\t0, newnode);\n-\t\t\tif (log_cache)\n-\t\t\t\tvq->log_cache = log_cache;\n+\t\tsus = rte_realloc_socket(vq->shadow_used_split, vq->size * sizeof(*sus),\n+\t\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\t\tif (!sus) {\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc shadow split on node %d\\n\", node);\n+\t\t\treturn dev;\n \t\t}\n-\n-\t\trte_free(old_vq);\n+\t\tvq->shadow_used_split = sus;\n \t}\n \n-\t/* check if we need to reallocate dev */\n-\tret = get_mempolicy(&oldnode, NULL, 0, old_dev,\n-\t\t\t MPOL_F_NODE | MPOL_F_ADDR);\n-\tif (ret) {\n-\t\tVHOST_LOG_CONFIG(ERR,\n-\t\t\t\"Unable to get dev numa information.\\n\");\n-\t\tgoto out;\n+\tbce = rte_realloc_socket(vq->batch_copy_elems, vq->size * sizeof(*bce),\n+\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\tif (!bce) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc batch copy elem on node %d\\n\", node);\n+\t\treturn dev;\n \t}\n-\tif (oldnode != newnode) {\n-\t\tstruct rte_vhost_memory *old_mem;\n-\t\tstruct guest_page *old_gp;\n-\t\tssize_t mem_size, gp_size;\n+\tvq->batch_copy_elems = bce;\n \n-\t\tVHOST_LOG_CONFIG(INFO,\n-\t\t\t\"reallocate dev from %d to %d node\\n\",\n-\t\t\toldnode, newnode);\n-\t\tdev = rte_malloc_socket(NULL, sizeof(*dev), 0, newnode);\n-\t\tif (!dev) {\n-\t\t\tdev = old_dev;\n-\t\t\tgoto out;\n-\t\t}\n-\n-\t\tmemcpy(dev, old_dev, sizeof(*dev));\n-\t\trte_free(old_dev);\n+\tif (vq->log_cache) {\n+\t\tstruct log_cache_entry *lc;\n \n-\t\tmem_size = sizeof(struct rte_vhost_memory) +\n-\t\t\tsizeof(struct rte_vhost_mem_region) * dev->mem->nregions;\n-\t\told_mem = dev->mem;\n-\t\tdev->mem = rte_malloc_socket(NULL, mem_size, 0, newnode);\n-\t\tif (!dev->mem) {\n-\t\t\tdev->mem = old_mem;\n-\t\t\tgoto out;\n+\t\tlc = rte_realloc_socket(vq->log_cache, sizeof(*lc) * VHOST_LOG_CACHE_NR, 0, node);\n+\t\tif (!lc) {\n+\t\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc log cache on node %d\\n\", node);\n+\t\t\treturn dev;\n \t\t}\n+\t\tvq->log_cache = lc;\n+\t}\n \n-\t\tmemcpy(dev->mem, old_mem, mem_size);\n-\t\trte_free(old_mem);\n-\n-\t\tgp_size = dev->max_guest_pages * sizeof(*dev->guest_pages);\n-\t\told_gp = dev->guest_pages;\n-\t\tdev->guest_pages = rte_malloc_socket(NULL, gp_size, RTE_CACHE_LINE_SIZE, newnode);\n-\t\tif (!dev->guest_pages) {\n-\t\t\tdev->guest_pages = old_gp;\n-\t\t\tgoto out;\n-\t\t}\n+\tdev = rte_realloc_socket(old_dev, sizeof(*dev), 0, node);\n+\tif (!dev) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc dev on node %d\\n\", node);\n+\t\treturn old_dev;\n+\t}\n \n-\t\tmemcpy(dev->guest_pages, old_gp, gp_size);\n-\t\trte_free(old_gp);\n+\tif (dev != old_dev) {\n+\t\tVHOST_LOG_CONFIG(INFO, \"reallocated device on node %d\\n\", node);\n+\t\tvhost_devices[dev->vid] = dev;\n \t}\n \n-out:\n-\tdev->virtqueue[index] = vq;\n-\tvhost_devices[dev->vid] = dev;\n+\tmem_size = sizeof(struct rte_vhost_memory) +\n+\t\tsizeof(struct rte_vhost_mem_region) * dev->mem->nregions;\n+\tmem = rte_realloc_socket(dev->mem, mem_size, 0, node);\n+\tif (!mem) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc mem table on node %d\\n\", node);\n+\t\treturn dev;\n+\t}\n \n-\tif (old_vq != vq)\n-\t\tvhost_user_iotlb_init(dev, index);\n+\tgp = rte_realloc_socket(dev->guest_pages, dev->max_guest_pages * sizeof(*gp),\n+\t\t\tRTE_CACHE_LINE_SIZE, node);\n+\tif (!gp) {\n+\t\tVHOST_LOG_CONFIG(ERR, \"Failed to realloc guest pages on node %d\\n\", node);\n+\t\treturn dev;\n+\t}\n+\tdev->guest_pages = gp;\n \n \treturn dev;\n }\n", "prefixes": [ "v2", "4/6" ] }{ "id": 94199, "url": "