From 3a825e76ea99833476b6eccd098f5948c9657da0 Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Tue, 6 Jan 2009 12:06:05 +0000 Subject: [PATCH] This interface is primarily useful for doing memory profiling and not much use on deployed embedded boxes. Make it optional. Together with /proc/pid/smaps, this save a few K. Signed-off-by: Matt Mackall Cc: Jeremy Fitzhardinge Acked-by: David Rientjes Signed-off-by: Andrew Morton --- fs/proc/base.c | 4 ++++ fs/proc/task_mmu.c | 2 ++ init/Kconfig | 9 +++++++++ 3 files changed, 15 insertions(+) --- fs/proc/base.c | 10 ++++++++++ fs/proc/task_mmu.c | 2 ++ init/Kconfig | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/fs/proc/base.c b/fs/proc/base.c index 387cdc42..084724a6 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -118,7 +118,9 @@ enum pid_directory_inos { PROC_TGID_MOUNTSTATS, PROC_TGID_WCHAN, #ifdef CONFIG_MMU +#ifdef CONFIG_PROC_CLEAR_REFS PROC_TGID_CLEAR_REFS, +#endif #ifdef CONFIG_PROC_SMAPS PROC_TGID_SMAPS, #endif @@ -167,7 +169,9 @@ enum pid_directory_inos { PROC_TID_MOUNTSTATS, PROC_TID_WCHAN, #ifdef CONFIG_MMU +#ifdef CONFIG_PROC_CLEAR_REFS PROC_TID_CLEAR_REFS, +#endif #ifdef CONFIG_PROC_SMAPS PROC_TID_SMAPS, #endif @@ -233,7 +237,9 @@ static struct pid_entry tgid_base_stuff[] = { E(PROC_TGID_MOUNTS, "mounts", S_IFREG|S_IRUGO), E(PROC_TGID_MOUNTSTATS, "mountstats", S_IFREG|S_IRUSR), #ifdef CONFIG_MMU +#ifdef CONFIG_PROC_CLEAR_REFS E(PROC_TGID_CLEAR_REFS, "clear_refs", S_IFREG|S_IWUSR), +#endif #ifdef CONFIG_PROC_SMAPS E(PROC_TGID_SMAPS, "smaps", S_IFREG|S_IRUSR), #endif @@ -285,7 +291,9 @@ static struct pid_entry tid_base_stuff[] = { E(PROC_TID_EXE, "exe", S_IFLNK|S_IRWXUGO), E(PROC_TID_MOUNTS, "mounts", S_IFREG|S_IRUGO), #ifdef CONFIG_MMU +#ifdef CONFIG_PROC_CLEAR_REFS E(PROC_TID_CLEAR_REFS, "clear_refs", S_IFREG|S_IWUSR), +#endif #ifdef CONFIG_PROC_SMAPS E(PROC_TID_SMAPS, "smaps", S_IFREG|S_IRUSR), #endif @@ -1981,10 +1989,12 @@ static struct dentry *proc_pident_lookup(struct inode *dir, inode->i_fop = &proc_mounts_operations; break; #ifdef CONFIG_MMU +#ifdef CONFIG_PROC_CLEAR_REFS case PROC_TID_CLEAR_REFS: case PROC_TGID_CLEAR_REFS: inode->i_fop = &proc_clear_refs_operations; break; +#endif #ifdef CONFIG_PROC_SMAPS case PROC_TID_SMAPS: case PROC_TGID_SMAPS: diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 6a88625d..55a29799 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -447,6 +447,7 @@ struct file_operations proc_smaps_operations = { }; #endif +#ifdef CONFIG_PROC_CLEAR_REFS static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, void *private) { @@ -515,6 +516,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, struct file_operations proc_clear_refs_operations = { .write = clear_refs_write, }; +#endif #ifdef CONFIG_NUMA extern int show_numa_map(struct seq_file *m, void *v); diff --git a/init/Kconfig b/init/Kconfig index 35503135..a4d0c126 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -417,6 +417,15 @@ config PROC_SMAPS shared memory per mapping. Disabling this interface will reduce the size of the kernel for small machines. +config PROC_CLEAR_REFS + default y + bool "Enable /proc/pid/clear_refs support" if EMBEDDED && PROC_FS && MMU + help + The /proc/pid/clear_refs interface allows clearing the + referenced bits on a process's memory maps to allow monitoring + working set size. Disabling this interface will reduce + the size of the kernel for small machines. + endmenu # General setup config RT_MUTEXES -- 2.39.5