From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkDKE-0000iB-IQ for qemu-devel@nongnu.org; Wed, 05 Jun 2013 09:00:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkDKC-00026Y-KZ for qemu-devel@nongnu.org; Wed, 05 Jun 2013 09:00:26 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:48208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkDKC-00026P-Dv for qemu-devel@nongnu.org; Wed, 05 Jun 2013 09:00:24 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Jun 2013 07:00:22 -0600 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 94D8C1FF001E for ; Wed, 5 Jun 2013 06:52:57 -0600 (MDT) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r55Cw8vV388020 for ; Wed, 5 Jun 2013 06:58:08 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r55Cw8wo006494 for ; Wed, 5 Jun 2013 06:58:08 -0600 From: Anthony Liguori In-Reply-To: <1370404705-4620-2-git-send-email-gaowanlong@cn.fujitsu.com> References: <1370404705-4620-1-git-send-email-gaowanlong@cn.fujitsu.com> <1370404705-4620-2-git-send-email-gaowanlong@cn.fujitsu.com> Date: Wed, 05 Jun 2013 07:57:42 -0500 Message-ID: <874ndc67g9.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 2/2] Add monitor command mem-nodes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wanlong Gao , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, ehabkost@redhat.com, andre.przywara@amd.com Wanlong Gao writes: > Add monitor command mem-nodes to show the huge mapped > memory nodes locations. > > (qemu) info mem-nodes > /proc/14132/fd/13: 00002aaaaac00000-00002aaaeac00000: node0 > /proc/14132/fd/13: 00002aaaeac00000-00002aab2ac00000: node1 > /proc/14132/fd/14: 00002aab2ac00000-00002aab2b000000: node0 > /proc/14132/fd/14: 00002aab2b000000-00002aab2b400000: node1 This creates an ABI that we don't currently support. Memory hotplug or a variety of things can break this mapping and then we'd have to provide an interface to describe that the mapping was broken. Also, it only works with hugetlbfs which is probbably not widely used given the existance of THP. I had hoped that we would get proper userspace interfaces for describing memory groups but that appears to have stalled out. Does anyone know if this is still on the table? If we can't get a proper kernel interface, then perhaps we need to add full libnuma support but that would really be unfortunate... Regards, Anthony Liguori > > Refer to the proposal of Eduardo and Daniel. > http://article.gmane.org/gmane.comp.emulators.kvm.devel/93476 > > Signed-off-by: Wanlong Gao > --- > monitor.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > diff --git a/monitor.c b/monitor.c > index eefc7f0..85c865f 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -74,6 +74,10 @@ > #endif > #include "hw/lm32/lm32_pic.h" > > +#if defined(CONFIG_NUMA) > +#include > +#endif > + > //#define DEBUG > //#define DEBUG_COMPLETION > > @@ -1759,6 +1763,38 @@ static void mem_info(Monitor *mon, const QDict *qdict) > } > #endif > > +#if defined(CONFIG_NUMA) > +static void mem_nodes(Monitor *mon, const QDict *qdict) > +{ > + RAMBlock *block; > + int prevnode, node; > + unsigned long long c, start, area; > + int fd; > + int pid = getpid(); > + QTAILQ_FOREACH(block, &ram_list.blocks, next) { > + if (!(fd = block->fd)) > + continue; > + prevnode = -1; > + start = 0; > + area = (unsigned long long)block->host; > + for (c = 0; c < block->length; c += TARGET_PAGE_SIZE) { > + if (get_mempolicy(&node, NULL, 0, c + block->host, > + MPOL_F_ADDR | MPOL_F_NODE) < 0) > + continue; > + if (node == prevnode) > + continue; > + if (prevnode != -1) > + monitor_printf(mon, "/proc/%d/fd/%d: %016Lx-%016Lx: node%d\n", > + pid, fd, start + area, c + area, prevnode); > + prevnode = node; > + start = c; > + } > + monitor_printf(mon, "/proc/%d/fd/%d: %016Lx-%016Lx: node%d\n", > + pid, fd, start + area, c + area, prevnode); > + } > +} > +#endif > + > #if defined(TARGET_SH4) > > static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) > @@ -2567,6 +2603,15 @@ static mon_cmd_t info_cmds[] = { > .mhandler.cmd = mem_info, > }, > #endif > +#if defined(CONFIG_NUMA) > + { > + .name = "mem-nodes", > + .args_type = "", > + .params = "", > + .help = "show the huge mapped memory nodes location", > + .mhandler.cmd = mem_nodes, > + }, > +#endif > { > .name = "mtree", > .args_type = "", > -- > 1.8.3.rc2.10.g0c2b1cf