Commit ab50b8ed818016cfecd747d6d4bb9139986bc029

Authored by Hugh Dickins
Committed by Linus Torvalds
1 parent 72866f6f27

[PATCH] mm: vm_stat_account unshackled

The original vm_stat_account has fallen into disuse, with only one user, and
only one user of vm_stat_unaccount.  It's easier to keep track if we convert
them all to __vm_stat_account, then free it from its __shackles.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 7 changed files with 20 additions and 31 deletions Side-by-side Diff

arch/ia64/kernel/perfmon.c
... ... @@ -2352,7 +2352,8 @@
2352 2352 insert_vm_struct(mm, vma);
2353 2353  
2354 2354 mm->total_vm += size >> PAGE_SHIFT;
2355   - vm_stat_account(vma);
  2355 + vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
  2356 + vma_pages(vma));
2356 2357 up_write(&task->mm->mmap_sem);
2357 2358  
2358 2359 /*
arch/ia64/mm/fault.c
... ... @@ -41,7 +41,7 @@
41 41 vma->vm_mm->total_vm += grow;
42 42 if (vma->vm_flags & VM_LOCKED)
43 43 vma->vm_mm->locked_vm += grow;
44   - __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
  44 + vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
45 45 return 0;
46 46 }
47 47  
... ... @@ -928,25 +928,13 @@
928 928 unsigned long, unsigned long, pgprot_t);
929 929  
930 930 #ifdef CONFIG_PROC_FS
931   -void __vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
  931 +void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
932 932 #else
933   -static inline void __vm_stat_account(struct mm_struct *mm,
  933 +static inline void vm_stat_account(struct mm_struct *mm,
934 934 unsigned long flags, struct file *file, long pages)
935 935 {
936 936 }
937 937 #endif /* CONFIG_PROC_FS */
938   -
939   -static inline void vm_stat_account(struct vm_area_struct *vma)
940   -{
941   - __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
942   - vma_pages(vma));
943   -}
944   -
945   -static inline void vm_stat_unaccount(struct vm_area_struct *vma)
946   -{
947   - __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file,
948   - -vma_pages(vma));
949   -}
950 938  
951 939 /* update per process rss and vm hiwater data */
952 940 extern void update_mem_hiwater(struct task_struct *tsk);
... ... @@ -212,7 +212,7 @@
212 212 if (mpnt->vm_flags & VM_DONTCOPY) {
213 213 long pages = vma_pages(mpnt);
214 214 mm->total_vm -= pages;
215   - __vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
  215 + vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
216 216 -pages);
217 217 continue;
218 218 }
... ... @@ -832,7 +832,7 @@
832 832 }
833 833  
834 834 #ifdef CONFIG_PROC_FS
835   -void __vm_stat_account(struct mm_struct *mm, unsigned long flags,
  835 +void vm_stat_account(struct mm_struct *mm, unsigned long flags,
836 836 struct file *file, long pages)
837 837 {
838 838 const unsigned long stack_flags
... ... @@ -1110,7 +1110,7 @@
1110 1110 }
1111 1111 out:
1112 1112 mm->total_vm += len >> PAGE_SHIFT;
1113   - __vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
  1113 + vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
1114 1114 if (vm_flags & VM_LOCKED) {
1115 1115 mm->locked_vm += len >> PAGE_SHIFT;
1116 1116 make_pages_present(addr, addr + len);
... ... @@ -1475,7 +1475,7 @@
1475 1475 mm->total_vm += grow;
1476 1476 if (vma->vm_flags & VM_LOCKED)
1477 1477 mm->locked_vm += grow;
1478   - __vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
  1478 + vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow);
1479 1479 return 0;
1480 1480 }
1481 1481  
1482 1482  
1483 1483  
... ... @@ -1610,15 +1610,15 @@
1610 1610 * By the time this function is called, the area struct has been
1611 1611 * removed from the process mapping list.
1612 1612 */
1613   -static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *area)
  1613 +static void unmap_vma(struct mm_struct *mm, struct vm_area_struct *vma)
1614 1614 {
1615   - size_t len = area->vm_end - area->vm_start;
  1615 + long nrpages = vma_pages(vma);
1616 1616  
1617   - area->vm_mm->total_vm -= len >> PAGE_SHIFT;
1618   - if (area->vm_flags & VM_LOCKED)
1619   - area->vm_mm->locked_vm -= len >> PAGE_SHIFT;
1620   - vm_stat_unaccount(area);
1621   - remove_vm_struct(area);
  1617 + mm->total_vm -= nrpages;
  1618 + if (vma->vm_flags & VM_LOCKED)
  1619 + mm->locked_vm -= nrpages;
  1620 + vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
  1621 + remove_vm_struct(vma);
1622 1622 }
1623 1623  
1624 1624 /*
... ... @@ -168,8 +168,8 @@
168 168 vma->vm_flags = newflags;
169 169 vma->vm_page_prot = newprot;
170 170 change_protection(vma, start, end, newprot);
171   - __vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
172   - __vm_stat_account(mm, newflags, vma->vm_file, nrpages);
  171 + vm_stat_account(mm, oldflags, vma->vm_file, -nrpages);
  172 + vm_stat_account(mm, newflags, vma->vm_file, nrpages);
173 173 return 0;
174 174  
175 175 fail:
... ... @@ -233,7 +233,7 @@
233 233 * since do_munmap() will decrement it by old_len == new_len
234 234 */
235 235 mm->total_vm += new_len >> PAGE_SHIFT;
236   - __vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
  236 + vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT);
237 237  
238 238 if (do_munmap(mm, old_addr, old_len) < 0) {
239 239 /* OOM: unable to split vma, just get accounts right */
... ... @@ -384,7 +384,7 @@
384 384 addr + new_len, vma->vm_pgoff, NULL);
385 385  
386 386 current->mm->total_vm += pages;
387   - __vm_stat_account(vma->vm_mm, vma->vm_flags,
  387 + vm_stat_account(vma->vm_mm, vma->vm_flags,
388 388 vma->vm_file, pages);
389 389 if (vma->vm_flags & VM_LOCKED) {
390 390 current->mm->locked_vm += pages;