linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list
@ 2008-07-18 23:08 venkatesh.pallipadi
  2008-07-18 23:08 ` [RFC patch 1/2] x86: Add a arch directory for x86 under debugfs venkatesh.pallipadi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: venkatesh.pallipadi @ 2008-07-18 23:08 UTC (permalink / raw)
  To: mingo, tglx, hpa, gregkh; +Cc: linux-kernel

Patchset adds a new entry for dumping PAT memtype list under debugfs.
I am adding a high level arch directory in debugfs to combine any other
such debug info. Not sure whether this is the 'right' approach or there
is anything else being planned for this. Hence the tag RFC.

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC patch 1/2] x86: Add a arch directory for x86 under debugfs
  2008-07-18 23:08 [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list venkatesh.pallipadi
@ 2008-07-18 23:08 ` venkatesh.pallipadi
  2008-07-18 23:08 ` [RFC patch 2/2] x86: Add a debugfs interface to dump PAT memtype venkatesh.pallipadi
  2008-07-19  0:23 ` [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list H. Peter Anvin
  2 siblings, 0 replies; 4+ messages in thread
From: venkatesh.pallipadi @ 2008-07-18 23:08 UTC (permalink / raw)
  To: mingo, tglx, hpa, gregkh; +Cc: linux-kernel, Venkatesh Pallipadi

[-- Attachment #1: x86_debugfs_dir.patch --]
[-- Type: text/plain, Size: 1565 bytes --]

Add a directory for x86 arch under debugfs. Can be used to accumulate all
x86 specific debugfs files.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>

---
 arch/x86/kernel/kdebugfs.c |    8 ++++++++
 include/linux/debugfs.h    |    2 ++
 2 files changed, 10 insertions(+)

Index: linux-2.6/arch/x86/kernel/kdebugfs.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/kdebugfs.c	2008-05-02 09:45:23.000000000 -0700
+++ linux-2.6/arch/x86/kernel/kdebugfs.c	2008-07-18 15:20:39.000000000 -0700
@@ -12,9 +12,13 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/mm.h>
+#include <linux/module.h>
 
 #include <asm/setup.h>
 
+struct dentry *arch_debugfs_dir;
+EXPORT_SYMBOL(arch_debugfs_dir);
+
 #ifdef CONFIG_DEBUG_BOOT_PARAMS
 struct setup_data_node {
 	u64 paddr;
@@ -209,6 +213,10 @@ static int __init arch_kdebugfs_init(voi
 {
 	int error = 0;
 
+	arch_debugfs_dir = debugfs_create_dir("x86", NULL);
+	if (!arch_debugfs_dir)
+		return -ENOMEM;
+
 #ifdef CONFIG_DEBUG_BOOT_PARAMS
 	error = boot_params_kdebugfs_init();
 #endif
Index: linux-2.6/include/linux/debugfs.h
===================================================================
--- linux-2.6.orig/include/linux/debugfs.h	2008-05-01 15:31:18.000000000 -0700
+++ linux-2.6/include/linux/debugfs.h	2008-07-18 15:20:01.000000000 -0700
@@ -26,6 +26,8 @@ struct debugfs_blob_wrapper {
 	unsigned long size;
 };
 
+extern struct dentry *arch_debugfs_dir;
+
 #if defined(CONFIG_DEBUG_FS)
 
 /* declared over in file.c */

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC patch 2/2] x86: Add a debugfs interface to dump PAT memtype
  2008-07-18 23:08 [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list venkatesh.pallipadi
  2008-07-18 23:08 ` [RFC patch 1/2] x86: Add a arch directory for x86 under debugfs venkatesh.pallipadi
@ 2008-07-18 23:08 ` venkatesh.pallipadi
  2008-07-19  0:23 ` [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list H. Peter Anvin
  2 siblings, 0 replies; 4+ messages in thread
From: venkatesh.pallipadi @ 2008-07-18 23:08 UTC (permalink / raw)
  To: mingo, tglx, hpa, gregkh; +Cc: linux-kernel, Venkatesh Pallipadi

[-- Attachment #1: pat_debugfs.patch --]
[-- Type: text/plain, Size: 2980 bytes --]

Add a debugfs interface to list out all the PAT memtype reservations.
Appears at debugfs x86/pat_memtype_list and output format is
type @ <start addr>-<end addr>

We do not hold the lock while printing the entire list. So, the list may not be
a consistent copy in case where regions are getting added or deleted
at the same time.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>

---
 arch/x86/mm/pat.c |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

Index: linux-2.6/arch/x86/mm/pat.c
===================================================================
--- linux-2.6.orig/arch/x86/mm/pat.c	2008-07-18 15:10:37.000000000 -0700
+++ linux-2.6/arch/x86/mm/pat.c	2008-07-18 15:48:31.000000000 -0700
@@ -12,6 +12,8 @@
 #include <linux/gfp.h>
 #include <linux/fs.h>
 #include <linux/bootmem.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
 
 #include <asm/msr.h>
 #include <asm/tlbflush.h>
@@ -489,3 +491,89 @@ void unmap_devmem(unsigned long pfn, uns
 
 	free_memtype(addr, addr + size);
 }
+
+#if defined(CONFIG_DEBUG_FS)
+
+/* get Nth element of the linked list */
+static struct memtype *memtype_get_idx(loff_t pos)
+{
+	struct memtype *list_node, *print_entry;
+	int i = 1;
+
+	print_entry  = kmalloc(sizeof(struct memtype), GFP_KERNEL);
+	if (!print_entry)
+		return NULL;
+
+	spin_lock(&memtype_lock);
+	list_for_each_entry(list_node, &memtype_list, nd) {
+		if (pos == i) {
+			*print_entry = *list_node;
+			spin_unlock(&memtype_lock);
+			return print_entry;
+		}
+		++i;
+	}
+	spin_unlock(&memtype_lock);
+	kfree(print_entry);
+	return NULL;
+}
+
+static void *memtype_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	if (*pos == 0) {
+		++*pos;
+		seq_printf(seq, "PAT memtype list:\n");
+	}
+
+	return memtype_get_idx(*pos);
+}
+
+static void *memtype_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+	++*pos;
+	return memtype_get_idx(*pos);
+}
+
+static void memtype_seq_stop(struct seq_file *seq, void *v)
+{
+}
+
+static int memtype_seq_show(struct seq_file *seq, void *v)
+{
+	struct memtype *print_entry = (struct memtype *)v;
+
+	seq_printf(seq, "%s @ 0x%Lx-0x%Lx\n", cattr_name(print_entry->type),
+			print_entry->start, print_entry->end);
+	kfree(print_entry);
+	return 0;
+}
+
+static struct seq_operations memtype_seq_ops = {
+	.start = memtype_seq_start,
+	.next  = memtype_seq_next,
+	.stop  = memtype_seq_stop,
+	.show  = memtype_seq_show,
+};
+
+static int memtype_seq_open(struct inode *inode, struct file *file)
+{
+	return seq_open(file, &memtype_seq_ops);
+}
+
+static const struct file_operations memtype_fops = {
+	.open    = memtype_seq_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release,
+};
+
+static int __init pat_memtype_list_init(void)
+{
+	debugfs_create_file("pat_memtype_list", S_IRUSR, arch_debugfs_dir,
+				NULL, &memtype_fops);
+	return 0;
+}
+
+late_initcall(pat_memtype_list_init);
+
+#endif /* CONFIG_DEBUG_FS */

-- 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list
  2008-07-18 23:08 [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list venkatesh.pallipadi
  2008-07-18 23:08 ` [RFC patch 1/2] x86: Add a arch directory for x86 under debugfs venkatesh.pallipadi
  2008-07-18 23:08 ` [RFC patch 2/2] x86: Add a debugfs interface to dump PAT memtype venkatesh.pallipadi
@ 2008-07-19  0:23 ` H. Peter Anvin
  2 siblings, 0 replies; 4+ messages in thread
From: H. Peter Anvin @ 2008-07-19  0:23 UTC (permalink / raw)
  To: venkatesh.pallipadi; +Cc: mingo, tglx, gregkh, linux-kernel

venkatesh.pallipadi@intel.com wrote:
> Patchset adds a new entry for dumping PAT memtype list under debugfs.
> I am adding a high level arch directory in debugfs to combine any other
> such debug info. Not sure whether this is the 'right' approach or there
> is anything else being planned for this. Hence the tag RFC.

Look good to me; I have added this to x86/pat.

	-hpa

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-19  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-18 23:08 [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list venkatesh.pallipadi
2008-07-18 23:08 ` [RFC patch 1/2] x86: Add a arch directory for x86 under debugfs venkatesh.pallipadi
2008-07-18 23:08 ` [RFC patch 2/2] x86: Add a debugfs interface to dump PAT memtype venkatesh.pallipadi
2008-07-19  0:23 ` [RFC patch 0/2] x86: Add debugfs entry for PAT memtype list H. Peter Anvin

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).