From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: linux-kernel@vger.kernel.org,
Jeremy Fitzhardinge <jeremy@goop.org>,
hpa@zytor.com, Ian Campbell <Ian.Campbell@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
xen-devel@lists.xensource.com, Jan Beulich <JBeulich@novell.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 5/8] xen/debug: Print out all pages in the P2M.
Date: Thu, 30 Dec 2010 14:48:34 -0500 [thread overview]
Message-ID: <1293738517-7287-6-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1293738517-7287-1-git-send-email-konrad.wilk@oracle.com>
We walk over the whole P2M and constructing a simplified view of which
regions belong to what level and what type they are.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/xen/mmu.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 36bdd2d..e9dfdd6 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -46,6 +46,7 @@
#include <linux/module.h>
#include <linux/gfp.h>
#include <linux/memblock.h>
+#include <linux/seq_file.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
@@ -2764,6 +2765,88 @@ EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
#ifdef CONFIG_XEN_DEBUG_FS
+static int p2m_dump_show(struct seq_file *m, void *v)
+{
+ static const char * const level_name[] = { "top", "middle",
+ "entry", "abnormal" };
+ static const char * const type_name[] = { "identity", "missing",
+ "pfn", "abnormal"};
+#define TYPE_IDENTITY 0
+#define TYPE_MISSING 1
+#define TYPE_PFN 2
+#define TYPE_UNKN 3
+ unsigned long pfn, prev_pfn_type = 0, prev_pfn_level = 0;
+ unsigned int prev_level = 0;
+ unsigned int prev_type = TYPE_UNKN;
+
+ if (!p2m_top)
+ return 0;
+
+ for (pfn = 0; pfn < MAX_DOMAIN_PAGES; pfn++) {
+ unsigned topidx = p2m_top_index(pfn);
+ unsigned mididx = p2m_mid_index(pfn);
+ unsigned idx = p2m_index(pfn);
+ unsigned lvl, type;
+
+ lvl = 4;
+ type = TYPE_UNKN;
+ if (p2m_top[topidx] == p2m_mid_missing) {
+ lvl = 0; type = TYPE_MISSING;
+ } else if (p2m_top[topidx] == p2m_mid_identity) {
+ lvl = 0; type = TYPE_IDENTITY;
+ } else if (p2m_top[topidx][mididx] == p2m_identity) {
+ lvl = 1; type = TYPE_IDENTITY;
+ } else if (p2m_top[topidx][mididx][idx] == pfn) {
+ lvl = 2; type = TYPE_IDENTITY;
+ } else if (p2m_top[topidx] == NULL) {
+ lvl = 0; type = TYPE_UNKN;
+ } else if (p2m_top[topidx][mididx] == NULL) {
+ lvl = 1; type = TYPE_UNKN;
+ } else if (p2m_top[topidx][mididx][idx] == 0) {
+ lvl = 2; type = TYPE_UNKN;
+ } else if (p2m_top[topidx][mididx] == p2m_missing) {
+ lvl = 1; type = TYPE_MISSING;
+ } else if (p2m_top[topidx][mididx][idx] == INVALID_P2M_ENTRY) {
+ lvl = 2; type = TYPE_MISSING;
+ } else if (p2m_top[topidx][mididx][idx] != pfn) {
+ lvl = 2; type = TYPE_PFN;
+ }
+ if (pfn == 0) {
+ prev_level = lvl;
+ prev_type = type;
+ }
+ if (pfn == MAX_DOMAIN_PAGES-1) {
+ lvl = 3;
+ type = TYPE_UNKN;
+ }
+ if (prev_type != type) {
+ seq_printf(m, " [0x%lx->0x%lx] %s\n",
+ prev_pfn_type, pfn, type_name[prev_type]);
+ prev_pfn_type = pfn;
+ prev_type = type;
+ }
+ if (prev_level != lvl) {
+ seq_printf(m, " [0x%lx->0x%lx] level %s\n",
+ prev_pfn_level, pfn, level_name[prev_level]);
+ prev_pfn_level = pfn;
+ prev_level = lvl;
+ }
+ }
+ return 0;
+}
+
+static int p2m_dump_open(struct inode *inode, struct file *filp)
+{
+ return single_open(filp, p2m_dump_show, NULL);
+}
+
+static const struct file_operations p2m_dump_fops = {
+ .open = p2m_dump_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
static struct dentry *d_mmu_debug;
static int __init xen_mmu_debugfs(void)
@@ -2819,6 +2902,7 @@ static int __init xen_mmu_debugfs(void)
debugfs_create_u32("prot_commit_batched", 0444, d_mmu_debug,
&mmu_stats.prot_commit_batched);
+ debugfs_create_file("p2m", 0600, d_mmu_debug, NULL, &p2m_dump_fops);
return 0;
}
fs_initcall(xen_mmu_debugfs);
--
1.7.1
next prev parent reply other threads:[~2010-12-30 19:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-30 19:48 [PATCH RFC v2] Consider E820 non-RAM and E820 gaps as 1-1 mappings Konrad Rzeszutek Wilk
2010-12-30 19:48 ` [PATCH 1/8] xen: Mark all initial reserved pages for the balloon as INVALID_P2M_ENTRY Konrad Rzeszutek Wilk
2011-01-04 16:34 ` Ian Campbell
2011-01-04 16:45 ` Konrad Rzeszutek Wilk
2010-12-30 19:48 ` [PATCH 2/8] xen/mmu: Add the notion of identity (1-1) mapping Konrad Rzeszutek Wilk
2011-01-04 16:53 ` Ian Campbell
2011-01-04 16:59 ` Ian Campbell
2011-01-04 17:20 ` [Xen-devel] " Ian Campbell
2011-01-04 19:24 ` Konrad Rzeszutek Wilk
2011-01-05 14:03 ` Ian Campbell
2010-12-30 19:48 ` [PATCH 3/8] xen/setup: Set identity mapping for non-RAM E820 and E820 gaps Konrad Rzeszutek Wilk
2011-01-04 17:18 ` Ian Campbell
2011-01-04 18:38 ` Konrad Rzeszutek Wilk
2011-01-04 19:27 ` Ian Campbell
2011-01-04 21:28 ` Konrad Rzeszutek Wilk
2010-12-30 19:48 ` [PATCH 4/8] xen/mmu: Warn against races Konrad Rzeszutek Wilk
2010-12-30 19:48 ` Konrad Rzeszutek Wilk [this message]
2010-12-30 19:48 ` [PATCH 6/8] xen/debug: WARN_ON when 1-1 but no _PAGE_IOMAP flag set Konrad Rzeszutek Wilk
2011-01-04 17:24 ` Ian Campbell
2011-01-04 18:46 ` Konrad Rzeszutek Wilk
2011-01-04 19:20 ` Ian Campbell
2011-01-06 19:50 ` Stefano Stabellini
2011-01-06 20:17 ` Keir Fraser
2011-01-06 21:59 ` Konrad Rzeszutek Wilk
2011-01-06 22:17 ` Keir Fraser
2010-12-30 19:48 ` [PATCH 7/8] xen/mmu: Introduce IDENTITY_FRAME_BIT Konrad Rzeszutek Wilk
2011-01-04 16:26 ` Ian Campbell
2011-01-04 16:45 ` Konrad Rzeszutek Wilk
2010-12-30 19:48 ` [PATCH 8/8] xen/mmu: Set _PAGE_IOMAP if PFN is in identity P2M Konrad Rzeszutek Wilk
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=1293738517-7287-6-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@novell.com \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=konrad@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.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).