Commit 384aabda authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] task_vsize() locking cleanup

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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 64bb92da
...@@ -299,7 +299,6 @@ int proc_pid_status(struct task_struct *task, char * buffer) ...@@ -299,7 +299,6 @@ int proc_pid_status(struct task_struct *task, char * buffer)
return buffer - orig; return buffer - orig;
} }
extern unsigned long task_vsize(struct mm_struct *);
int proc_pid_stat(struct task_struct *task, char * buffer) int proc_pid_stat(struct task_struct *task, char * buffer)
{ {
unsigned long vsize, eip, esp, wchan; unsigned long vsize, eip, esp, wchan;
...@@ -318,11 +317,9 @@ int proc_pid_stat(struct task_struct *task, char * buffer) ...@@ -318,11 +317,9 @@ int proc_pid_stat(struct task_struct *task, char * buffer)
vsize = eip = esp = 0; vsize = eip = esp = 0;
mm = get_task_mm(task); mm = get_task_mm(task);
if (mm) { if (mm) {
down_read(&mm->mmap_sem);
vsize = task_vsize(mm); vsize = task_vsize(mm);
eip = KSTK_EIP(task); eip = KSTK_EIP(task);
esp = KSTK_ESP(task); esp = KSTK_ESP(task);
up_read(&mm->mmap_sem);
} }
get_task_comm(tcomm, task); get_task_comm(tcomm, task);
......
...@@ -68,11 +68,12 @@ unsigned long task_vsize(struct mm_struct *mm) ...@@ -68,11 +68,12 @@ unsigned long task_vsize(struct mm_struct *mm)
struct mm_tblock_struct *tbp; struct mm_tblock_struct *tbp;
unsigned long vsize = 0; unsigned long vsize = 0;
down_read(&mm->mmap_sem);
for (tbp = &mm->context.tblock; tbp; tbp = tbp->next) { for (tbp = &mm->context.tblock; tbp; tbp = tbp->next) {
if (tbp->rblock) if (tbp->rblock)
vsize += kobjsize(tbp->rblock->kblock); vsize += kobjsize(tbp->rblock->kblock);
} }
up_read(&mm->mmap_sem);
return vsize; return vsize;
} }
......
...@@ -86,10 +86,13 @@ extern struct proc_dir_entry *proc_root_kcore; ...@@ -86,10 +86,13 @@ extern struct proc_dir_entry *proc_root_kcore;
extern void proc_root_init(void); extern void proc_root_init(void);
extern void proc_misc_init(void); extern void proc_misc_init(void);
struct mm_struct;
struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *); struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
struct dentry *proc_pid_unhash(struct task_struct *p); struct dentry *proc_pid_unhash(struct task_struct *p);
void proc_pid_flush(struct dentry *proc_dentry); void proc_pid_flush(struct dentry *proc_dentry);
int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir); 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, extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
struct proc_dir_entry *parent); struct proc_dir_entry *parent);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment