Skip to content

Commit a99d6fd

Browse files
committed
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>
1 parent 4d1f3bb commit a99d6fd

File tree

5 files changed

+81
-43
lines changed

5 files changed

+81
-43
lines changed

arch/sh/Kconfig.debug

-4
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ endmenu
180180

181181
if SUPERH64
182182

183-
config SH64_PROC_ASIDS
184-
bool "Debug: report ASIDs through /proc/asids"
185-
depends on PROC_FS && MMU
186-
187183
config SH64_SR_WATCH
188184
bool "Debug: set SR.WATCH to enable hardware watchpoints and trace"
189185

arch/sh/kernel/process_64.c

-39
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <linux/reboot.h>
2424
#include <linux/init.h>
2525
#include <linux/module.h>
26-
#include <linux/proc_fs.h>
2726
#include <linux/io.h>
2827
#include <asm/syscalls.h>
2928
#include <asm/uaccess.h>
@@ -590,41 +589,3 @@ unsigned long get_wchan(struct task_struct *p)
590589
#endif
591590
return pc;
592591
}
593-
594-
/* Provide a /proc/asids file that lists out the
595-
ASIDs currently associated with the processes. (If the DM.PC register is
596-
examined through the debug link, this shows ASID + PC. To make use of this,
597-
the PID->ASID relationship needs to be known. This is primarily for
598-
debugging.)
599-
*/
600-
601-
#if defined(CONFIG_SH64_PROC_ASIDS)
602-
static int
603-
asids_proc_info(char *buf, char **start, off_t fpos, int length, int *eof, void *data)
604-
{
605-
int len=0;
606-
struct task_struct *p;
607-
read_lock(&tasklist_lock);
608-
for_each_process(p) {
609-
int pid = p->pid;
610-
611-
if (!pid)
612-
continue;
613-
if (p->mm)
614-
len += sprintf(buf+len, "%5d : %02lx\n", pid,
615-
asid_cache(smp_processor_id()));
616-
else
617-
len += sprintf(buf+len, "%5d : (none)\n", pid);
618-
}
619-
read_unlock(&tasklist_lock);
620-
*eof = 1;
621-
return len;
622-
}
623-
624-
static int __init register_proc_asids(void)
625-
{
626-
create_proc_read_entry("asids", 0, NULL, asids_proc_info, NULL);
627-
return 0;
628-
}
629-
__initcall(register_proc_asids);
630-
#endif

arch/sh/mm/Makefile_32

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mmu-y := tlb-nommu.o pg-nommu.o
1818
mmu-$(CONFIG_MMU) := fault_32.o tlbflush_32.o ioremap_32.o
1919

2020
obj-y += $(mmu-y)
21+
obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o
2122

2223
ifdef CONFIG_DEBUG_FS
2324
obj-$(CONFIG_CPU_SH4) += cache-debugfs.o

arch/sh/mm/Makefile_64

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-y += cache-sh5.o
1313
endif
1414

1515
obj-y += $(mmu-y)
16+
obj-$(CONFIG_DEBUG_FS) += asids-debugfs.o
1617

1718
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
1819
obj-$(CONFIG_NUMA) += numa.o

arch/sh/mm/asids-debugfs.c

+79
Original file line numberDiff line numberDiff line change
@@ -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+
27+
static 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+
51+
static int asids_debugfs_open(struct inode *inode, struct file *file)
52+
{
53+
return single_open(file, asids_seq_show, inode->i_private);
54+
}
55+
56+
static 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+
64+
static 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+
}
77+
module_init(asids_debugfs_init);
78+
79+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)