From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 7442A5323 for ; Tue, 20 Nov 2018 20:16:06 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3C4337E85; Tue, 20 Nov 2018 19:16:05 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id C539760141; Tue, 20 Nov 2018 19:16:04 +0000 (UTC) From: Kevin Traynor To: Tiwei Bie Cc: Maxime Coquelin , dpdk stable Date: Tue, 20 Nov 2018 19:12:48 +0000 Message-Id: <20181120191252.30277-58-ktraynor@redhat.com> In-Reply-To: <20181120191252.30277-1-ktraynor@redhat.com> References: <20181120191252.30277-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Nov 2018 19:16:05 +0000 (UTC) Subject: [dpdk-stable] patch 'net/virtio-user: fix memory hotplug support in vhost-kernel' has been queued to stable release 18.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Nov 2018 19:16:06 -0000 Hi, FYI, your patch has been queued to stable release 18.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/23/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From 4a4c3a7150f1fb714a7057e44672330c997d3d1b Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Wed, 5 Sep 2018 12:28:52 +0800 Subject: [PATCH] net/virtio-user: fix memory hotplug support in vhost-kernel [ upstream commit 757286542560ab7f326ae71f5ef8d83050ee5646 ] It's possible to have much more hugepage backed memory regions than what vhost-kernel supports due to the memory hotplug, which may cause problems. A better solution is to have the virtio-user pass all the memory ranges reserved by DPDK to vhost-kernel. Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug") Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/vhost_kernel.c | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c index a93fe5b28..b3bfcb76f 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c @@ -71,33 +71,34 @@ static uint64_t vhost_req_user_to_kernel[] = { }; -struct walk_arg { - struct vhost_memory_kernel *vm; - uint32_t region_nr; -}; static int -add_memory_region(const struct rte_memseg_list *msl __rte_unused, - const struct rte_memseg *ms, size_t len, void *arg) +add_memseg_list(const struct rte_memseg_list *msl, void *arg) { - struct walk_arg *wa = arg; + struct vhost_memory_kernel *vm = arg; struct vhost_memory_region *mr; void *start_addr; + uint64_t len; - if (wa->region_nr >= max_regions) + if (vm->nregions >= max_regions) return -1; - mr = &wa->vm->regions[wa->region_nr++]; - start_addr = ms->addr; + start_addr = msl->base_va; + len = msl->page_sz * msl->memseg_arr.len; + + mr = &vm->regions[vm->nregions++]; mr->guest_phys_addr = (uint64_t)(uintptr_t)start_addr; mr->userspace_addr = (uint64_t)(uintptr_t)start_addr; mr->memory_size = len; - mr->mmap_offset = 0; + mr->mmap_offset = 0; /* flags_padding */ + + PMD_DRV_LOG(DEBUG, "index=%u addr=%p len=%" PRIu64, + vm->nregions - 1, start_addr, len); return 0; } -/* By default, vhost kernel module allows 64 regions, but DPDK allows - * 256 segments. As a relief, below function merges those virtually - * adjacent memsegs into one region. +/* By default, vhost kernel module allows 64 regions, but DPDK may + * have much more memory regions. Below function will treat each + * contiguous memory space reserved by DPDK as one region. */ static struct vhost_memory_kernel * @@ -105,5 +106,4 @@ prepare_vhost_memory_kernel(void) { struct vhost_memory_kernel *vm; - struct walk_arg wa; vm = malloc(sizeof(struct vhost_memory_kernel) + @@ -113,6 +113,6 @@ prepare_vhost_memory_kernel(void) return NULL; - wa.region_nr = 0; - wa.vm = vm; + vm->nregions = 0; + vm->padding = 0; /* @@ -120,11 +120,9 @@ prepare_vhost_memory_kernel(void) * or virtio_user_start_device(). */ - if (rte_memseg_contig_walk_thread_unsafe(add_memory_region, &wa) < 0) { + if (rte_memseg_list_walk_thread_unsafe(add_memseg_list, vm) < 0) { free(vm); return NULL; } - vm->nregions = wa.region_nr; - vm->padding = 0; return vm; } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-20 17:53:08.855155197 +0000 +++ 0058-net-virtio-user-fix-memory-hotplug-support-in-vhost-.patch 2018-11-20 17:53:07.000000000 +0000 @@ -1,15 +1,16 @@ -From 757286542560ab7f326ae71f5ef8d83050ee5646 Mon Sep 17 00:00:00 2001 +From 4a4c3a7150f1fb714a7057e44672330c997d3d1b Mon Sep 17 00:00:00 2001 From: Tiwei Bie Date: Wed, 5 Sep 2018 12:28:52 +0800 Subject: [PATCH] net/virtio-user: fix memory hotplug support in vhost-kernel +[ upstream commit 757286542560ab7f326ae71f5ef8d83050ee5646 ] + It's possible to have much more hugepage backed memory regions than what vhost-kernel supports due to the memory hotplug, which may cause problems. A better solution is to have the virtio-user pass all the memory ranges reserved by DPDK to vhost-kernel. Fixes: 12ecb2f63b12 ("net/virtio-user: support memory hotplug") -Cc: stable@dpdk.org Signed-off-by: Tiwei Bie Reviewed-by: Maxime Coquelin