From: task_vsize() doesn't need mm->mmap_sem for the CONFIG_MMU case; the semaphore doesn't prevent mm->total_vm from going stale or getting inconsistent with other numbers regardless. Also, KSTK_EIP() and KSTK_ESP() don't want or need protection from mm->mmap_sem either. So this pushes mm->mmap_sem to task_vsize() in the CONFIG_MMU=n task_vsize(). Also, hoist the prototype of task_vsize() into proc_fs.h The net result of this is a small speedup of procps for CONFIG_MMU. Signed-off-by: Andrew Morton --- 25-akpm/fs/proc/array.c | 3 --- 25-akpm/fs/proc/task_nommu.c | 3 ++- 25-akpm/include/linux/proc_fs.h | 1 + 3 files changed, 3 insertions(+), 4 deletions(-) diff -puN fs/proc/array.c~task_vsize-locking-cleanup fs/proc/array.c --- 25/fs/proc/array.c~task_vsize-locking-cleanup 2004-08-23 23:09:42.900281536 -0700 +++ 25-akpm/fs/proc/array.c 2004-08-23 23:09:42.922278192 -0700 @@ -300,7 +300,6 @@ int proc_pid_status(struct task_struct * return buffer - orig; } -extern unsigned long task_vsize(struct mm_struct *); int proc_pid_stat(struct task_struct *task, char * buffer) { unsigned long vsize, eip, esp, wchan; @@ -320,11 +319,9 @@ int proc_pid_stat(struct task_struct *ta vsize = eip = esp = 0; mm = get_task_mm(task); if (mm) { - down_read(&mm->mmap_sem); vsize = task_vsize(mm); eip = KSTK_EIP(task); esp = KSTK_ESP(task); - up_read(&mm->mmap_sem); } get_task_comm(tcomm, task); diff -puN fs/proc/task_nommu.c~task_vsize-locking-cleanup fs/proc/task_nommu.c --- 25/fs/proc/task_nommu.c~task_vsize-locking-cleanup 2004-08-23 23:09:42.901281384 -0700 +++ 25-akpm/fs/proc/task_nommu.c 2004-08-23 23:09:42.922278192 -0700 @@ -68,11 +68,12 @@ unsigned long task_vsize(struct mm_struc struct mm_tblock_struct *tbp; unsigned long vsize = 0; + down_read(&mm->mmap_sem); for (tbp = &mm->context.tblock; tbp; tbp = tbp->next) { if (tbp->rblock) vsize += kobjsize(tbp->rblock->kblock); } - + up_read(&mm->mmap_sem); return vsize; } diff -puN include/linux/proc_fs.h~task_vsize-locking-cleanup include/linux/proc_fs.h --- 25/include/linux/proc_fs.h~task_vsize-locking-cleanup 2004-08-23 23:09:42.918278800 -0700 +++ 25-akpm/include/linux/proc_fs.h 2004-08-23 23:09:42.923278040 -0700 @@ -90,6 +90,7 @@ struct dentry *proc_pid_lookup(struct in struct dentry *proc_pid_unhash(struct task_struct *p); void proc_pid_flush(struct dentry *proc_dentry); int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir); +unsigned long task_vsize(struct mm_struct *); extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode, struct proc_dir_entry *parent); _