mm: account the total_vm in the vm_stat_account()
vm_stat_account() accounts the shared_vm, stack_vm and reserved_vm now. But we can also account for total_vm in the vm_stat_account() which makes the code tidy. Even for mprotect_fixup(), we can get the right result in the end. Signed-off-by: Huang Shijie <shijie8@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
df858fa827
commit
44de9d0cad
|
@ -2353,7 +2353,6 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
|
||||||
*/
|
*/
|
||||||
insert_vm_struct(mm, vma);
|
insert_vm_struct(mm, vma);
|
||||||
|
|
||||||
mm->total_vm += size >> PAGE_SHIFT;
|
|
||||||
vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
|
vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
|
||||||
vma_pages(vma));
|
vma_pages(vma));
|
||||||
up_write(&task->mm->mmap_sem);
|
up_write(&task->mm->mmap_sem);
|
||||||
|
|
|
@ -1528,6 +1528,7 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
|
||||||
static inline void vm_stat_account(struct mm_struct *mm,
|
static inline void vm_stat_account(struct mm_struct *mm,
|
||||||
unsigned long flags, struct file *file, long pages)
|
unsigned long flags, struct file *file, long pages)
|
||||||
{
|
{
|
||||||
|
mm->total_vm += pages;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
|
|
|
@ -381,10 +381,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
||||||
if (mpnt->vm_flags & VM_DONTCOPY) {
|
if (mpnt->vm_flags & VM_DONTCOPY) {
|
||||||
long pages = vma_pages(mpnt);
|
|
||||||
mm->total_vm -= pages;
|
|
||||||
vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
|
vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
|
||||||
-pages);
|
-vma_pages(mpnt));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
charge = 0;
|
charge = 0;
|
||||||
|
|
|
@ -943,6 +943,8 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
|
||||||
const unsigned long stack_flags
|
const unsigned long stack_flags
|
||||||
= VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
|
= VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
|
||||||
|
|
||||||
|
mm->total_vm += pages;
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
mm->shared_vm += pages;
|
mm->shared_vm += pages;
|
||||||
if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
|
if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
|
||||||
|
@ -1347,7 +1349,6 @@ munmap_back:
|
||||||
out:
|
out:
|
||||||
perf_event_mmap(vma);
|
perf_event_mmap(vma);
|
||||||
|
|
||||||
mm->total_vm += len >> PAGE_SHIFT;
|
|
||||||
vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
|
vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
|
||||||
if (vm_flags & VM_LOCKED) {
|
if (vm_flags & VM_LOCKED) {
|
||||||
if (!mlock_vma_pages_range(vma, addr, addr + len))
|
if (!mlock_vma_pages_range(vma, addr, addr + len))
|
||||||
|
@ -1707,7 +1708,6 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* Ok, everything looks good - let it rip */
|
/* Ok, everything looks good - let it rip */
|
||||||
mm->total_vm += grow;
|
|
||||||
if (vma->vm_flags & VM_LOCKED)
|
if (vma->vm_flags & VM_LOCKED)
|
||||||
mm->locked_vm += grow;
|
mm->locked_vm += grow;
|
||||||
vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
|
vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
|
||||||
|
@ -1889,7 +1889,6 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
|
||||||
|
|
||||||
if (vma->vm_flags & VM_ACCOUNT)
|
if (vma->vm_flags & VM_ACCOUNT)
|
||||||
nr_accounted += nrpages;
|
nr_accounted += nrpages;
|
||||||
mm->total_vm -= nrpages;
|
|
||||||
vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
|
vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
|
||||||
vma = remove_vma(vma);
|
vma = remove_vma(vma);
|
||||||
} while (vma);
|
} while (vma);
|
||||||
|
|
|
@ -260,7 +260,6 @@ static unsigned long move_vma(struct vm_area_struct *vma,
|
||||||
* If this were a serious issue, we'd add a flag to do_munmap().
|
* If this were a serious issue, we'd add a flag to do_munmap().
|
||||||
*/
|
*/
|
||||||
hiwater_vm = mm->hiwater_vm;
|
hiwater_vm = mm->hiwater_vm;
|
||||||
mm->total_vm += new_len >> PAGE_SHIFT;
|
|
||||||
vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
|
vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
|
||||||
|
|
||||||
if (do_munmap(mm, old_addr, old_len) < 0) {
|
if (do_munmap(mm, old_addr, old_len) < 0) {
|
||||||
|
@ -497,7 +496,6 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
mm->total_vm += pages;
|
|
||||||
vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
|
vm_stat_account(mm, vma->vm_flags, vma->vm_file, pages);
|
||||||
if (vma->vm_flags & VM_LOCKED) {
|
if (vma->vm_flags & VM_LOCKED) {
|
||||||
mm->locked_vm += pages;
|
mm->locked_vm += pages;
|
||||||
|
|
Loading…
Reference in New Issue