From patchwork Wed Jun 5 03:58:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wanlong Gao X-Patchwork-Id: 248887 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 F3B422C009D for ; Wed, 5 Jun 2013 14:01:20 +1000 (EST) Received: from localhost ([::1]:50567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk4uU-0004cg-Dd for incoming@patchwork.ozlabs.org; Wed, 05 Jun 2013 00:01:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk4tS-0003q5-2w for qemu-devel@nongnu.org; Wed, 05 Jun 2013 00:00:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uk4tR-0004RX-09 for qemu-devel@nongnu.org; Wed, 05 Jun 2013 00:00:14 -0400 Received: from [222.73.24.84] (port=32458 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uk4tQ-0004AK-LU for qemu-devel@nongnu.org; Wed, 05 Jun 2013 00:00:12 -0400 X-IronPort-AV: E=Sophos;i="4.87,804,1363104000"; d="scan'208";a="7463708" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 05 Jun 2013 11:57:06 +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 r553xrr5028601; Wed, 5 Jun 2013 11:59:54 +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 2013060511581297-1836264 ; Wed, 5 Jun 2013 11:58:12 +0800 From: Wanlong Gao To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2013 11:58:25 +0800 Message-Id: <1370404705-4620-2-git-send-email-gaowanlong@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.rc2.10.g0c2b1cf In-Reply-To: <1370404705-4620-1-git-send-email-gaowanlong@cn.fujitsu.com> References: <1370404705-4620-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/05 11:58:13, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/05 11:58:17, Serialize complete at 2013/06/05 11:58:17 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, Wanlong Gao Subject: [Qemu-devel] [PATCH 2/2] Add monitor command mem-nodes 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 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 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 = "",