qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com, ehabkost@redhat.com, bsd@redhat.com,
	pbonzini@redhat.com, y-goto@jp.fujitsu.com, afaerber@suse.de,
	gaowanlong@cn.fujitsu.com
Subject: [Qemu-devel] [PATCH V2 9/9] NUMA: show host memory policy info in info numa command
Date: Fri, 21 Jun 2013 14:26:00 +0800	[thread overview]
Message-ID: <1371795960-10478-10-git-send-email-gaowanlong@cn.fujitsu.com> (raw)
In-Reply-To: <1371795960-10478-1-git-send-email-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 <gaowanlong@cn.fujitsu.com>
---
 monitor.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/monitor.c b/monitor.c
index 61dbebb..b6e93e5 100644
--- a/monitor.c
+++ b/monitor.c
@@ -74,6 +74,11 @@
 #endif
 #include "hw/lm32/lm32_pic.h"
 
+#ifdef CONFIG_NUMA
+#include <numa.h>
+#include <numaif.h>
+#endif
+
 //#define DEBUG
 //#define DEBUG_COMPLETION
 
@@ -1807,6 +1812,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++) {
@@ -1820,6 +1826,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.1.448.gfb7dfaa

      parent reply	other threads:[~2013-06-21  6:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21  6:25 [Qemu-devel] [PATCH V2 0/9] Add support for binding guest numa nodes to host numa nodes Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 1/9] NUMA: Support multiple CPU ranges on -numa option Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 2/9] NUMA: Add numa_info structure to contain numa nodes info Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 3/9] NUMA: Add Linux libnuma detection Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 4/9] NUMA: parse guest numa nodes memory policy Wanlong Gao
2013-06-21 15:34   ` Bandan Das
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 5/9] NUMA: set " Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 6/9] NUMA: handle Error in mpol and hostnode parser Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 7/9] NUMA: add qmp command set-mpol to set memory policy for NUMA node Wanlong Gao
2013-06-21  6:25 ` [Qemu-devel] [PATCH V2 8/9] NUMA: add hmp command set-mpol Wanlong Gao
2013-06-21  6:26 ` Wanlong Gao [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=1371795960-10478-10-git-send-email-gaowanlong@cn.fujitsu.com \
    --to=gaowanlong@cn.fujitsu.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=bsd@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=y-goto@jp.fujitsu.com \
    /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).