From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: pbonzini@redhat.com, peter.huangpeng@huawei.com,
luonengjun@huawei.com, qemu-devel@nongnu.org,
hutao@cn.fujitsu.com
Subject: Re: [Qemu-devel] [PATCH v4] pc-dimm/numa: Fix stat of memory size in node when hotplug memory
Date: Thu, 16 Oct 2014 19:29:48 +0800 [thread overview]
Message-ID: <543FAC2C.1010409@huawei.com> (raw)
In-Reply-To: <20141016123655.09402e4f@igors-macbook-pro.local>
On 2014/10/16 18:36, Igor Mammedov wrote:
> On Thu, 9 Oct 2014 20:21:57 +0800
> zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:
>
> reword subj with:
> numa: make 'info numa' take into account hotplugged memory
>
>> 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 <zhang.zhanghailiang@huawei.com>
> With above and below comments fixed,
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>
OK, Will fix them and send V5 with your Reviewd-by, Thanks:)
>
>> ---
>> v4:
>> - s/pc_dimm_stat_node_mem/numa_stat_memory_devices/ (Igor Mammedov)
>> - rewrite numa_stat_memory_devices as Igor's suggestion, and this
>> will also fix compile error for targets that don't support memory
>> hotplug v3:
>> - cold-plugged memory should not be excluded (Igor Mammedov)
>> v2:
>> - Don't modify the numa_info.node_mem directly when treating hotplug
>> memory, fix the "info numa" instead (Igor Mammedov)
>>
>> Thanks for review!;)
>> ---
>> include/sysemu/sysemu.h | 1 +
>> monitor.c | 6 +++++-
>> numa.c | 43
>> +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49
>> insertions(+), 1 deletion(-)
>>
>> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>> index d8539fd..cfc1592 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);
>> +int query_numa_node_mem(uint64_t *node_mem);
>> extern QemuOptsList qemu_numa_opts;
>> int numa_init_func(QemuOpts *opts, void *opaque);
>>
>> diff --git a/monitor.c b/monitor.c
>> index 2d14f39..d45b0a3 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -1949,7 +1949,10 @@ static void do_info_numa(Monitor *mon, const
>> QDict *qdict) {
>> int i;
>> CPUState *cpu;
>> + uint64_t *node_mem;
>>
>> + node_mem = g_new0(uint64_t, nb_numa_nodes);
>> + query_numa_node_mem(node_mem);
>> monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
>> for (i = 0; i < nb_numa_nodes; i++) {
>> monitor_printf(mon, "node %d cpus:", i);
>> @@ -1960,8 +1963,9 @@ static void do_info_numa(Monitor *mon, const
>> QDict *qdict) }
>> monitor_printf(mon, "\n");
>> monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
>> - numa_info[i].node_mem >> 20);
>> + node_mem[i] >> 20);
>> }
>> + g_free(node_mem);
>> }
>>
>> #ifdef CONFIG_PROFILER
>> diff --git a/numa.c b/numa.c
>> index 3b98135..f8ea327 100644
>> --- a/numa.c
>> +++ b/numa.c
>> @@ -35,6 +35,7 @@
>> #include "hw/boards.h"
>> #include "sysemu/hostmem.h"
>> #include "qmp-commands.h"
>> +#include "hw/mem/pc-dimm.h"
>>
>> QemuOptsList qemu_numa_opts = {
>> .name = "numa",
>> @@ -315,6 +316,48 @@ void
>> memory_region_allocate_system_memory(MemoryRegion *mr, Object
>> *owner, } }
>>
>> +static void numa_stat_memory_devices(uint64_t *node_mem)
>> +{
>> + MemoryDeviceInfoList *info_list = NULL;
>> + MemoryDeviceInfoList **prev = &info_list;
>> + MemoryDeviceInfoList *info;
>> +
>> + qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
>> + for (info = info_list; info; info = info->next) {
>> + MemoryDeviceInfo *value = info->value;
>> +
>> + if (value) {
>> + switch (value->kind) {
>> + case MEMORY_DEVICE_INFO_KIND_DIMM:{
>> + PCDIMMDeviceInfo *di = value->dimm;
>> +
>> + node_mem[di->node] += di->size;
>> + break;
>> + }
>> + default:
>> + break;
>> + }
>> + }
>> + }
>> +
> unnecessary blank line, drop it
>
>> + qapi_free_MemoryDeviceInfoList(info_list);
>> +}
>> +
>> +int query_numa_node_mem(uint64_t *node_mem)
>> +{
>> + int i;
>> +
>> + if (nb_numa_nodes <= 0) {
>> + return 0;
> since function's return value is not used,
> make function void pls
>
>> + }
>> +
>> + numa_stat_memory_devices(node_mem);
>> + for (i = 0; i < nb_numa_nodes; i++) {
>> + node_mem[i] += numa_info[i].node_mem;
>> + }
>> + return 0;
>> +}
>> +
>> static int query_memdev(Object *obj, void *opaque)
>> {
>> MemdevList **list = opaque;
>
>
> .
>
prev parent reply other threads:[~2014-10-16 11:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-09 12:21 [Qemu-devel] [PATCH v4] pc-dimm/numa: Fix stat of memory size in node when hotplug memory zhanghailiang
2014-10-15 9:21 ` zhanghailiang
2014-10-16 10:36 ` Igor Mammedov
2014-10-16 11:29 ` zhanghailiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=543FAC2C.1010409@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=hutao@cn.fujitsu.com \
--cc=imammedo@redhat.com \
--cc=luonengjun@huawei.com \
--cc=pbonzini@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).