Received: from eggs.gnu.org ([2001:4830:134:3::10]:46011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UugEY-0004E9-5M for qemu-devel@nongnu.org; Thu, 04 Jul 2013 05:53:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UugEV-0002Lt-4i for qemu-devel@nongnu.org; Thu, 04 Jul 2013 05:53:50 -0400 Received: from [222.73.24.84] (port=53256 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UugEU-0002Jf-N2 for qemu-devel@nongnu.org; Thu, 04 Jul 2013 05:53:46 -0400 From: Wanlong Gao Date: Thu, 4 Jul 2013 17:53:17 +0800 Message-Id: <1372931597-28115-11-git-send-email-gaowanlong@cn.fujitsu.com> In-Reply-To: <1372931597-28115-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1372931597-28115-1-git-send-email-gaowanlong@cn.fujitsu.com> Subject: [Qemu-devel] [PATCH V4 10/10] NUMA: show host memory policy info in info numa command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, ehabkost@redhat.com, lcapitulino@redhat.com, bsd@redhat.com, y-goto@jp.fujitsu.com, pbonzini@redhat.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com Show host memory policy of nodes in the info numa monitor command. After this patch, the monitor command "info numa" will show the information like following if the host numa support is enabled: (qemu) info numa 2 nodes node 0 cpus: 0 node 0 size: 1024 MB node 0 mempolicy: membind=0,1 node 1 cpus: 1 node 1 size: 1024 MB node 1 mempolicy: interleave=1 Signed-off-by: Wanlong Gao --- monitor.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/monitor.c b/monitor.c index 93ac045..a40415d 100644 --- a/monitor.c +++ b/monitor.c @@ -74,6 +74,11 @@ #endif #include "hw/lm32/lm32_pic.h" +#ifdef CONFIG_NUMA +#include +#include +#endif + //#define DEBUG //#define DEBUG_COMPLETION @@ -1808,6 +1813,7 @@ static void do_info_numa(Monitor *mon, const QDict *qdict) int i; CPUArchState *env; CPUState *cpu; + unsigned long first, next; monitor_printf(mon, "%d nodes\n", nb_numa_nodes); for (i = 0; i < nb_numa_nodes; i++) { @@ -1821,6 +1827,42 @@ 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); + +#ifdef CONFIG_NUMA + monitor_printf(mon, "node %d mempolicy: ", i); + switch (numa_info[i].flags & NODE_HOST_POLICY_MASK) { + case NODE_HOST_BIND: + monitor_printf(mon, "membind="); + break; + case NODE_HOST_INTERLEAVE: + monitor_printf(mon, "interleave="); + break; + case NODE_HOST_PREFERRED: + monitor_printf(mon, "preferred="); + break; + default: + monitor_printf(mon, "default\n"); + continue; + } + + if (numa_info[i].flags & NODE_HOST_RELATIVE) + monitor_printf(mon, "+"); + + next = first = find_first_bit(numa_info[i].host_mem, MAX_CPUMASK_BITS); + monitor_printf(mon, "%lu", first); + do { + if (next == numa_max_node()) + break; + next = find_next_bit(numa_info[i].host_mem, MAX_CPUMASK_BITS, + next + 1); + if (next > numa_max_node() || next == MAX_CPUMASK_BITS) + break; + + monitor_printf(mon, ",%lu", next); + } while (true); + + monitor_printf(mon, "\n"); +#endif } } -- 1.8.3.2.634.g7a3187e