From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTqoN-00049L-9q for qemu-devel@nongnu.org; Tue, 16 Sep 2014 07:20:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTqoI-00020d-53 for qemu-devel@nongnu.org; Tue, 16 Sep 2014 07:20:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46063) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTqoH-0001zo-RR for qemu-devel@nongnu.org; Tue, 16 Sep 2014 07:20:38 -0400 Date: Tue, 16 Sep 2014 13:20:13 +0200 From: Igor Mammedov Message-ID: <20140916132013.68f181ce@nial.usersys.redhat.com> In-Reply-To: <1410863956-11056-3-git-send-email-zhang.zhanghailiang@huawei.com> References: <1410863956-11056-1-git-send-email-zhang.zhanghailiang@huawei.com> <1410863956-11056-3-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] numa/pc-dimm: Fix stat of memory size in node when hotplug memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: mst@redhat.com, hutao@cn.fujitsu.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, pbonzini@redhat.com, gaowanlong@cn.fujitsu.com On Tue, 16 Sep 2014 18:39:16 +0800 zhanghailiang wrote: > When do memory hotplug, if there is numa node, we should add > the memory size to the corresponding node memory size. > > For now, it mainly affects the result of hmp command "info numa". > > Signed-off-by: zhanghailiang > --- > hw/i386/pc.c | 1 + > include/sysemu/sysemu.h | 1 + > numa.c | 13 +++++++++++++ > 3 files changed, 15 insertions(+) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 77b6782..bafe48e 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -1607,6 +1607,7 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev, > memory_region_add_subregion(&pcms->hotplug_memory, > addr - pcms->hotplug_memory_base, mr); > vmstate_register_ram(mr, dev); > + update_numa_node_mem_size(dimm->node, memory_region_size(mr), true); > > hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); > hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index d8539fd..5bc9d73 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -160,6 +160,7 @@ typedef struct node_info { > extern NodeInfo numa_info[MAX_NODES]; > void set_numa_nodes(void); > void set_numa_modes(void); > +void update_numa_node_mem_size(int node, uint64_t size, bool hotplug); > extern QemuOptsList qemu_numa_opts; > int numa_init_func(QemuOpts *opts, void *opaque); > > diff --git a/numa.c b/numa.c > index 3b98135..bbfa16f 100644 > --- a/numa.c > +++ b/numa.c > @@ -315,6 +315,19 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, > } > } > > +void update_numa_node_mem_size(int node, uint64_t size, bool hotplug) > +{ > + if (!nb_numa_nodes) { > + return; > + } > + > + if (hotplug) { > + numa_info[node].node_mem += size; > + } else { > + numa_info[node].node_mem -= size; > + } > +} I don't think is right thing to do. numa_info.node_mem provides mapping of initial memory specified with -m XXX option, and later used for building ACPI SRAT table. I'd suggest to fix 'info numa' command instead. Add to it ability to enumerate all memory devices, in that case when initial memory is converted to memory devices 'info numa' will continue to work correctly. > + > static int query_memdev(Object *obj, void *opaque) > { > MemdevList **list = opaque;