aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memblock.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-07-06 18:39:19 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2010-08-04 22:56:26 -0400
commit6d03b885f0926ab5b66e21307d505afcafa6dced (patch)
treebb2fb54ef0dae38b2abf176544839665bbe10ff3 /mm/memblock.c
parent918fe8d60331f679519ab8239a7232272126da9e (diff)
memblock: Add debugfs files to dump the arrays content
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r--mm/memblock.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/mm/memblock.c b/mm/memblock.c
index 9de5fcdf8e2..cc15be29fd0 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -16,6 +16,8 @@
16#include <linux/bitops.h> 16#include <linux/bitops.h>
17#include <linux/poison.h> 17#include <linux/poison.h>
18#include <linux/pfn.h> 18#include <linux/pfn.h>
19#include <linux/debugfs.h>
20#include <linux/seq_file.h>
19#include <linux/memblock.h> 21#include <linux/memblock.h>
20 22
21struct memblock memblock; 23struct memblock memblock;
@@ -740,3 +742,52 @@ static int __init early_memblock(char *p)
740} 742}
741early_param("memblock", early_memblock); 743early_param("memblock", early_memblock);
742 744
745#ifdef CONFIG_DEBUG_FS
746
747static int memblock_debug_show(struct seq_file *m, void *private)
748{
749 struct memblock_type *type = m->private;
750 struct memblock_region *reg;
751 int i;
752
753 for (i = 0; i < type->cnt; i++) {
754 reg = &type->regions[i];
755 seq_printf(m, "%4d: ", i);
756 if (sizeof(phys_addr_t) == 4)
757 seq_printf(m, "0x%08lx..0x%08lx\n",
758 (unsigned long)reg->base,
759 (unsigned long)(reg->base + reg->size - 1));
760 else
761 seq_printf(m, "0x%016llx..0x%016llx\n",
762 (unsigned long long)reg->base,
763 (unsigned long long)(reg->base + reg->size - 1));
764
765 }
766 return 0;
767}
768
769static int memblock_debug_open(struct inode *inode, struct file *file)
770{
771 return single_open(file, memblock_debug_show, inode->i_private);
772}
773
774static const struct file_operations memblock_debug_fops = {
775 .open = memblock_debug_open,
776 .read = seq_read,
777 .llseek = seq_lseek,
778 .release = single_release,
779};
780
781static int __init memblock_init_debugfs(void)
782{
783 struct dentry *root = debugfs_create_dir("memblock", NULL);
784 if (!root)
785 return -ENXIO;
786 debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops);
787 debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops);
788
789 return 0;
790}
791__initcall(memblock_init_debugfs);
792
793#endif /* CONFIG_DEBUG_FS */