Skip to content

Commit ab50b8e

Browse files
Hugh DickinsLinus Torvalds
authored andcommitted
[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>
1 parent 72866f6 commit ab50b8e

7 files changed

Lines changed: 20 additions & 31 deletions

File tree

‎arch/ia64/kernel/perfmon.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,8 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
23522352
insert_vm_struct(mm, vma);
23532353

23542354
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));
23562357
up_write(&task->mm->mmap_sem);
23572358

23582359
/*

‎arch/ia64/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ expand_backing_store (struct vm_area_struct *vma, unsigned long address)
4141
vma->vm_mm->total_vm += grow;
4242
if (vma->vm_flags & VM_LOCKED)
4343
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);
4545
return 0;
4646
}
4747

‎include/linux/mm.h‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -928,26 +928,14 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long,
928928
unsigned long, unsigned long, pgprot_t);
929929

930930
#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);
932932
#else
933-
static inline void __vm_stat_account(struct mm_struct *mm,
933+
static inline void vm_stat_account(struct mm_struct *mm,
934934
unsigned long flags, struct file *file, long pages)
935935
{
936936
}
937937
#endif /* CONFIG_PROC_FS */
938938

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-
951939
/* update per process rss and vm hiwater data */
952940
extern void update_mem_hiwater(struct task_struct *tsk);
953941

‎kernel/fork.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
212212
if (mpnt->vm_flags & VM_DONTCOPY) {
213213
long pages = vma_pages(mpnt);
214214
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,
216216
-pages);
217217
continue;
218218
}

‎mm/mmap.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma)
832832
}
833833

834834
#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,
836836
struct file *file, long pages)
837837
{
838838
const unsigned long stack_flags
@@ -1110,7 +1110,7 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
11101110
}
11111111
out:
11121112
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);
11141114
if (vm_flags & VM_LOCKED) {
11151115
mm->locked_vm += len >> PAGE_SHIFT;
11161116
make_pages_present(addr, addr + len);
@@ -1475,7 +1475,7 @@ static int acct_stack_growth(struct vm_area_struct * vma, unsigned long size, un
14751475
mm->total_vm += grow;
14761476
if (vma->vm_flags & VM_LOCKED)
14771477
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);
14791479
return 0;
14801480
}
14811481

@@ -1610,15 +1610,15 @@ find_extend_vma(struct mm_struct * mm, unsigned long addr)
16101610
* By the time this function is called, the area struct has been
16111611
* removed from the process mapping list.
16121612
*/
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)
16141614
{
1615-
size_t len = area->vm_end - area->vm_start;
1615+
long nrpages = vma_pages(vma);
16161616

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);
16221622
}
16231623

16241624
/*

‎mm/mprotect.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
168168
vma->vm_flags = newflags;
169169
vma->vm_page_prot = newprot;
170170
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);
173173
return 0;
174174

175175
fail:

‎mm/mremap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
233233
* since do_munmap() will decrement it by old_len == new_len
234234
*/
235235
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);
237237

238238
if (do_munmap(mm, old_addr, old_len) < 0) {
239239
/* OOM: unable to split vma, just get accounts right */
@@ -384,7 +384,7 @@ unsigned long do_mremap(unsigned long addr,
384384
addr + new_len, vma->vm_pgoff, NULL);
385385

386386
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,
388388
vma->vm_file, pages);
389389
if (vma->vm_flags & VM_LOCKED) {
390390
current->mm->locked_vm += pages;

0 commit comments

Comments
 (0)