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>
Этот коммит содержится в:

коммит произвёл
Linus Torvalds

родитель
df858fa827
Коммит
44de9d0cad
@@ -943,6 +943,8 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
|
||||
const unsigned long stack_flags
|
||||
= VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
|
||||
|
||||
mm->total_vm += pages;
|
||||
|
||||
if (file) {
|
||||
mm->shared_vm += pages;
|
||||
if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
|
||||
@@ -1347,7 +1349,6 @@ munmap_back:
|
||||
out:
|
||||
perf_event_mmap(vma);
|
||||
|
||||
mm->total_vm += len >> PAGE_SHIFT;
|
||||
vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
|
||||
if (vm_flags & VM_LOCKED) {
|
||||
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;
|
||||
|
||||
/* Ok, everything looks good - let it rip */
|
||||
mm->total_vm += grow;
|
||||
if (vma->vm_flags & VM_LOCKED)
|
||||
mm->locked_vm += 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)
|
||||
nr_accounted += nrpages;
|
||||
mm->total_vm -= nrpages;
|
||||
vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
|
||||
vma = remove_vma(vma);
|
||||
} while (vma);
|
||||
|
Ссылка в новой задаче
Block a user