Commit a2ade7b6 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Linus Torvalds

proc: use unsigned long inside /proc/*/statm

/proc/*/statm code needlessly truncates data from unsigned long to int.
One needs only 8+ TB of RAM to make truncation visible.
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Reviewed-by: default avatarWANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 34e49d4f
...@@ -535,15 +535,15 @@ int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, ...@@ -535,15 +535,15 @@ int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task) struct pid *pid, struct task_struct *task)
{ {
int size = 0, resident = 0, shared = 0, text = 0, lib = 0, data = 0; unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
struct mm_struct *mm = get_task_mm(task); struct mm_struct *mm = get_task_mm(task);
if (mm) { if (mm) {
size = task_statm(mm, &shared, &text, &data, &resident); size = task_statm(mm, &shared, &text, &data, &resident);
mmput(mm); mmput(mm);
} }
seq_printf(m, "%d %d %d %d %d %d %d\n", seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
size, resident, shared, text, lib, data, 0); size, resident, shared, text, data);
return 0; return 0;
} }
...@@ -96,7 +96,8 @@ extern spinlock_t proc_subdir_lock; ...@@ -96,7 +96,8 @@ extern spinlock_t proc_subdir_lock;
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 *);
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 *); unsigned long task_vsize(struct mm_struct *);
int task_statm(struct mm_struct *, int *, int *, int *, int *); unsigned long task_statm(struct mm_struct *,
unsigned long *, unsigned long *, unsigned long *, unsigned long *);
void task_mem(struct seq_file *, struct mm_struct *); void task_mem(struct seq_file *, struct mm_struct *);
static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde) static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde)
......
...@@ -66,8 +66,9 @@ unsigned long task_vsize(struct mm_struct *mm) ...@@ -66,8 +66,9 @@ unsigned long task_vsize(struct mm_struct *mm)
return PAGE_SIZE * mm->total_vm; return PAGE_SIZE * mm->total_vm;
} }
int task_statm(struct mm_struct *mm, int *shared, int *text, unsigned long task_statm(struct mm_struct *mm,
int *data, int *resident) unsigned long *shared, unsigned long *text,
unsigned long *data, unsigned long *resident)
{ {
*shared = get_mm_counter(mm, MM_FILEPAGES); *shared = get_mm_counter(mm, MM_FILEPAGES);
*text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
......
...@@ -92,13 +92,14 @@ unsigned long task_vsize(struct mm_struct *mm) ...@@ -92,13 +92,14 @@ unsigned long task_vsize(struct mm_struct *mm)
return vsize; return vsize;
} }
int task_statm(struct mm_struct *mm, int *shared, int *text, unsigned long task_statm(struct mm_struct *mm,
int *data, int *resident) unsigned long *shared, unsigned long *text,
unsigned long *data, unsigned long *resident)
{ {
struct vm_area_struct *vma; struct vm_area_struct *vma;
struct vm_region *region; struct vm_region *region;
struct rb_node *p; struct rb_node *p;
int size = kobjsize(mm); unsigned long size = kobjsize(mm);
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) { for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) {
......
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