From patchwork Tue Jun 18 08:09:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 252124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D3DFF2C029B for ; Tue, 18 Jun 2013 18:13:22 +1000 (EST) Received: from localhost ([::1]:34211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uor2W-0006yr-JT for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 04:13:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uor1s-0006qp-Vi for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:12:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uor1q-0001UD-E2 for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:12:40 -0400 Received: from [222.73.24.84] (port=18122 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uor1q-0001Oz-3N for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:12:38 -0400 X-IronPort-AV: E=Sophos;i="4.87,887,1363104000"; d="scan'208";a="7587538" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Jun 2013 16:09:12 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r5I8C2BQ003325; Tue, 18 Jun 2013 16:12:05 +0800 Received: from G08FNSTD121251.fnst.cn.fujitsu.com ([10.167.233.84]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013061816100044-2230907 ; Tue, 18 Jun 2013 16:10:00 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 16:09:51 +0800 Message-Id: <1371542991-15911-8-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.rc2.10.g0c2b1cf In-Reply-To: <1371542991-15911-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1371542991-15911-1-git-send-email-gaowanlong@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/18 16:10:00, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/18 16:10:03, Serialize complete at 2013/06/18 16:10:03 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: andre.przywara@amd.com, aliguori@us.ibm.com, ehabkost@redhat.com, pbonzini@redhat.com, y-goto@jp.fujitsu.com, afaerber@suse.de, gaowanlong@cn.fujitsu.com Subject: [Qemu-devel] [PATCH 7/7] NUMA: show host memory policy info in info numa command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 61dbebb..b6e93e5 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 @@ -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 } }