aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/mm/asids-debugfs.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2008-12-10 04:06:36 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-12-22 04:44:03 -0500
commita99d6fde69dd9c73ac0b4e42a77ed1ebc714e56a (patch)
tree96d0136b37139a696265b7218e7037ce09a19873 /arch/sh/mm/asids-debugfs.c
parent4d1f3bbec49a080cae753aaa44dc1fc7277b3e50 (diff)
sh: Convert sh64 /proc/asids to debugfs and generic sh.
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>
Diffstat (limited to 'arch/sh/mm/asids-debugfs.c')
-rw-r--r--arch/sh/mm/asids-debugfs.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/arch/sh/mm/asids-debugfs.c b/arch/sh/mm/asids-debugfs.c
new file mode 100644
index 000000000000..0678a1044a9a
--- /dev/null
+++ b/arch/sh/mm/asids-debugfs.c
@@ -0,0 +1,79 @@
1/*
2 * debugfs ops for process ASIDs
3 *
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2003 - 2008 Paul Mundt
6 * Copyright (C) 2003, 2004 Richard Curnow
7 *
8 * Provides a debugfs file that lists out the ASIDs currently associated
9 * with the processes.
10 *
11 * In the SH-5 case, if the DM.PC register is examined through the debug
12 * link, this shows ASID + PC. To make use of this, the PID->ASID
13 * relationship needs to be known. This is primarily for debugging.
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
18 */
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/debugfs.h>
22#include <linux/seq_file.h>
23#include <linux/spinlock.h>
24#include <asm/processor.h>
25#include <asm/mmu_context.h>
26
27static int asids_seq_show(struct seq_file *file, void *iter)
28{
29 struct task_struct *p;
30
31 read_lock(&tasklist_lock);
32
33 for_each_process(p) {
34 int pid = p->pid;
35
36 if (unlikely(!pid))
37 continue;
38
39 if (p->mm)
40 seq_printf(file, "%5d : %02x\n", pid,
41 cpu_asid(smp_processor_id(), p->mm));
42 else
43 seq_printf(file, "%5d : (none)\n", pid);
44 }
45
46 read_unlock(&tasklist_lock);
47
48 return 0;
49}
50
51static int asids_debugfs_open(struct inode *inode, struct file *file)
52{
53 return single_open(file, asids_seq_show, inode->i_private);
54}
55
56static const struct file_operations asids_debugfs_fops = {
57 .owner = THIS_MODULE,
58 .open = asids_debugfs_open,
59 .read = seq_read,
60 .llseek = seq_lseek,
61 .release = single_release,
62};
63
64static int __init asids_debugfs_init(void)
65{
66 struct dentry *asids_dentry;
67
68 asids_dentry = debugfs_create_file("asids", S_IRUSR, sh_debugfs_root,
69 NULL, &asids_debugfs_fops);
70 if (!asids_dentry)
71 return -ENOMEM;
72 if (IS_ERR(asids_dentry))
73 return PTR_ERR(asids_dentry);
74
75 return 0;
76}
77module_init(asids_debugfs_init);
78
79MODULE_LICENSE("GPL v2");