sh: Convert sh64 /proc/asids to debugfs and generic sh.
authorPaul Mundt <lethal@linux-sh.org>
Wed, 10 Dec 2008 09:06:36 +0000 (18:06 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 22 Dec 2008 09:44:03 +0000 (18:44 +0900)
This converts the sh64 /proc/asids entry to debugfs and enables it for
all SH parts that have debugfs enabled.

On MMU systems this can be used to determine which processes are using
which ASIDs which in turn can be used for finer grained cache tag
analysis.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/Kconfig.debug
arch/sh/kernel/process_64.c
arch/sh/mm/Makefile_32
arch/sh/mm/Makefile_64
arch/sh/mm/asids-debugfs.c [new file with mode: 0644]

index e6d2c8b11abdaea5490fe00e83d750d7d141017b..8f0c1fbd51a69d957b08061acf9f5c084a3c59fe 100644 (file)
@@ -180,10 +180,6 @@ endmenu
 
 if SUPERH64
 
-config SH64_PROC_ASIDS
-       bool "Debug: report ASIDs through /proc/asids"
-       depends on PROC_FS && MMU
-
 config SH64_SR_WATCH
        bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
 
index e9bf2548d6d447c1aecaf3f560d4971689126cfd..a7e5f2e74bacd20fd9bced8573715bcc5b8301dd 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/proc_fs.h>
 #include <linux/io.h>
 #include <asm/syscalls.h>
 #include <asm/uaccess.h>
@@ -590,41 +589,3 @@ unsigned long get_wchan(struct task_struct *p)
 #endif
        return pc;
 }
-
-/* Provide a /proc/asids file that lists out the
-   ASIDs currently associated with the processes.  (If the DM.PC register is
-   examined through the debug link, this shows ASID + PC.  To make use of this,
-   the PID->ASID relationship needs to be known.  This is primarily for
-   debugging.)
-   */
-
-#if defined(CONFIG_SH64_PROC_ASIDS)
-static int
-asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
-{
-       int len=0;
-       struct task_struct *p;
-       read_lock(&tasklist_lock);
-       for_each_process(p) {
-               int pid = p->pid;
-
-               if (!pid)
-                       continue;
-               if (p->mm)
-                       len += sprintf(buf+len, "%5d : %02lx\n", pid,
-                                      asid_cache(smp_processor_id()));
-               else
-                       len += sprintf(buf+len, "%5d : (none)\n", pid);
-       }
-       read_unlock(&tasklist_lock);
-       *eof = 1;
-       return len;
-}
-
-static int __init register_proc_asids(void)
-{
-       create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL);
-       return 0;
-}
-__initcall(register_proc_asids);
-#endif
index f066e76da2044fb9430c80ec2481546ad963c275..cb2f3f2995914003c5f1966362be9b325df9a90f 100644 (file)
@@ -18,6 +18,7 @@ mmu-y                 := tlb-nommu.o pg-nommu.o
 mmu-$(CONFIG_MMU)      := fault_32.o tlbflush_32.o ioremap_32.o
 
 obj-y                  += $(mmu-y)
+obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o
 
 ifdef CONFIG_DEBUG_FS
 obj-$(CONFIG_CPU_SH4)  += cache-debugfs.o
index 9481d0f54efdd8a5fd6e76b86c72f12be906604f..2863ffb7006d12408e5e070621eb8f7b3af0ec4f 100644 (file)
@@ -13,6 +13,7 @@ obj-y                 += cache-sh5.o
 endif
 
 obj-y                  += $(mmu-y)
+obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o
 
 obj-$(CONFIG_HUGETLB_PAGE)     += hugetlbpage.o
 obj-$(CONFIG_NUMA)             += numa.o
diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c
new file mode 100644 (file)
index 0000000..0678a10
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * debugfs ops for process ASIDs
+ *
+ *  Copyright (C) 2000, 2001  Paolo Alberelli
+ *  Copyright (C) 2003 - 2008  Paul Mundt
+ *  Copyright (C) 2003, 2004  Richard Curnow
+ *
+ * Provides a debugfs file that lists out the ASIDs currently associated
+ * with the processes.
+ *
+ * In the SH-5 case, if the DM.PC register is examined through the debug
+ * link, this shows ASID + PC. To make use of this, the PID->ASID
+ * relationship needs to be known. This is primarily for debugging.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
+#include <linux/spinlock.h>
+#include <asm/processor.h>
+#include <asm/mmu_context.h>
+
+static int asids_seq_show(struct seq_file *file, void *iter)
+{
+       struct task_struct *p;
+
+       read_lock(&tasklist_lock);
+
+       for_each_process(p) {
+               int pid = p->pid;
+
+               if (unlikely(!pid))
+                       continue;
+
+               if (p->mm)
+                       seq_printf(file, "%5d : %02x\n", pid,
+                                  cpu_asid(smp_processor_id(), p->mm));
+               else
+                       seq_printf(file, "%5d : (none)\n", pid);
+       }
+
+       read_unlock(&tasklist_lock);
+
+       return 0;
+}
+
+static int asids_debugfs_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, asids_seq_show, inode->i_private);
+}
+
+static const struct file_operations asids_debugfs_fops = {
+       .owner          = THIS_MODULE,
+       .open           = asids_debugfs_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int __init asids_debugfs_init(void)
+{
+       struct dentry *asids_dentry;
+
+       asids_dentry = debugfs_create_file("asids", S_IRUSR, sh_debugfs_root,
+                                          NULL, &asids_debugfs_fops);
+       if (!asids_dentry)
+               return -ENOMEM;
+       if (IS_ERR(asids_dentry))
+               return PTR_ERR(asids_dentry);
+
+       return 0;
+}
+module_init(asids_debugfs_init);
+
+MODULE_LICENSE("GPL v2");