aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorJay Lan <jlan@engr.sgi.com>2005-01-04 05:25:39 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-01-04 05:25:39 -0800
commitb6a6107abf22149c9cedc68149d3fd78a76f7e34 (patch)
treede3c6674a0693dbfce15bfee0e59ce4f66ffc879 /mm
parent9ca7d6f6cdc862fdebc72c4c15249cbb729a2f0f (diff)
downloadhistory-b6a6107abf22149c9cedc68149d3fd78a76f7e34.tar.gz
[PATCH] enhanced Memory accounting data collection
This patch is to offer common accounting data collection method at memory usage for various accounting packages including BSD accounting, ELSA, CSA and any other acct packages that use a common layer of data collection. New struct fields are added to mm_struct to save high watermarks of rss usage as well as virtual memory usage. New struct fields are added to task_struct to collect accumulated rss usage and vm usages. These data are collected on per process basis. Signed-off-by: Jay Lan <jlan@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c32
-rw-r--r--mm/mmap.c10
-rw-r--r--mm/mremap.c6
-rw-r--r--mm/rmap.c3
-rw-r--r--mm/swapfile.c3
5 files changed, 52 insertions, 2 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 3cf660bcb5a4e9..58ba5fe6660420 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -46,6 +46,7 @@
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/rmap.h>
+#include <linux/acct.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -738,6 +739,7 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long address,
tlb = tlb_gather_mmu(mm, 0);
unmap_vmas(&tlb, mm, vma, address, end, &nr_accounted, details);
tlb_finish_mmu(tlb, address, end);
+ acct_update_integrals();
spin_unlock(&mm->page_table_lock);
}
@@ -1316,9 +1318,11 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct * vma,
if (likely(pte_same(*page_table, pte))) {
if (PageAnon(old_page))
mm->anon_rss--;
- if (PageReserved(old_page))
+ if (PageReserved(old_page)) {
++mm->rss;
- else
+ acct_update_integrals();
+ update_mem_hiwater();
+ } else
page_remove_rmap(old_page);
break_cow(vma, new_page, address, page_table);
lru_cache_add_active(new_page);
@@ -1600,6 +1604,9 @@ static int do_swap_page(struct mm_struct * mm,
remove_exclusive_swap_page(page);
mm->rss++;
+ acct_update_integrals();
+ update_mem_hiwater();
+
pte = mk_pte(page, vma->vm_page_prot);
if (write_access && can_share_swap_page(page)) {
pte = maybe_mkwrite(pte_mkdirty(pte), vma);
@@ -1665,6 +1672,8 @@ do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
goto out;
}
mm->rss++;
+ acct_update_integrals();
+ update_mem_hiwater();
entry = maybe_mkwrite(pte_mkdirty(mk_pte(page,
vma->vm_page_prot)),
vma);
@@ -1774,6 +1783,9 @@ retry:
if (pte_none(*page_table)) {
if (!PageReserved(new_page))
++mm->rss;
+ acct_update_integrals();
+ update_mem_hiwater();
+
flush_icache_page(vma, new_page);
entry = mk_pte(new_page, vma->vm_page_prot);
if (write_access)
@@ -2092,6 +2104,22 @@ unsigned long vmalloc_to_pfn(void * vmalloc_addr)
EXPORT_SYMBOL(vmalloc_to_pfn);
+/*
+ * update_mem_hiwater
+ * - update per process rss and vm high water data
+ */
+void update_mem_hiwater(void)
+{
+ struct task_struct *tsk = current;
+
+ if (tsk->mm) {
+ if (tsk->mm->hiwater_rss < tsk->mm->rss)
+ tsk->mm->hiwater_rss = tsk->mm->rss;
+ if (tsk->mm->hiwater_vm < tsk->mm->total_vm)
+ tsk->mm->hiwater_vm = tsk->mm->total_vm;
+ }
+}
+
#if !defined(__HAVE_ARCH_GATE_AREA)
#if defined(AT_SYSINFO_EHDR)
diff --git a/mm/mmap.c b/mm/mmap.c
index a6cec51672f59b..25348d68fcb9fe 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -7,6 +7,7 @@
*/
#include <linux/slab.h>
+#include <linux/mm.h>
#include <linux/shm.h>
#include <linux/mman.h>
#include <linux/pagemap.h>
@@ -20,6 +21,7 @@
#include <linux/hugetlb.h>
#include <linux/profile.h>
#include <linux/module.h>
+#include <linux/acct.h>
#include <linux/mount.h>
#include <linux/mempolicy.h>
#include <linux/rmap.h>
@@ -1019,6 +1021,8 @@ out:
pgoff, flags & MAP_NONBLOCK);
down_write(&mm->mmap_sem);
}
+ acct_update_integrals();
+ update_mem_hiwater();
return addr;
unmap_and_free_vma:
@@ -1365,6 +1369,8 @@ int expand_stack(struct vm_area_struct * vma, unsigned long address)
if (vma->vm_flags & VM_LOCKED)
vma->vm_mm->locked_vm += grow;
__vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
+ acct_update_integrals();
+ update_mem_hiwater();
anon_vma_unlock(vma);
return 0;
}
@@ -1428,6 +1434,8 @@ int expand_stack(struct vm_area_struct *vma, unsigned long address)
if (vma->vm_flags & VM_LOCKED)
vma->vm_mm->locked_vm += grow;
__vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow);
+ acct_update_integrals();
+ update_mem_hiwater();
anon_vma_unlock(vma);
return 0;
}
@@ -1815,6 +1823,8 @@ out:
mm->locked_vm += len >> PAGE_SHIFT;
make_pages_present(addr, addr + len);
}
+ acct_update_integrals();
+ update_mem_hiwater();
return addr;
}
diff --git a/mm/mremap.c b/mm/mremap.c
index 37ffa19e278143..daf4ac4f1b2a77 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -16,6 +16,7 @@
#include <linux/fs.h>
#include <linux/highmem.h>
#include <linux/security.h>
+#include <linux/acct.h>
#include <linux/syscalls.h>
#include <asm/uaccess.h>
@@ -250,6 +251,9 @@ static unsigned long move_vma(struct vm_area_struct *vma,
new_addr + new_len);
}
+ acct_update_integrals();
+ update_mem_hiwater();
+
return new_addr;
}
@@ -386,6 +390,8 @@ unsigned long do_mremap(unsigned long addr,
make_pages_present(addr + old_len,
addr + new_len);
}
+ acct_update_integrals();
+ update_mem_hiwater();
ret = addr;
goto out;
}
diff --git a/mm/rmap.c b/mm/rmap.c
index a94cd4176a9f8a..8e198864146a44 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -51,6 +51,7 @@
#include <linux/swapops.h>
#include <linux/slab.h>
#include <linux/init.h>
+#include <linux/acct.h>
#include <linux/rmap.h>
#include <linux/rcupdate.h>
@@ -606,6 +607,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma)
}
mm->rss--;
+ acct_update_integrals();
page_remove_rmap(page);
page_cache_release(page);
@@ -710,6 +712,7 @@ static void try_to_unmap_cluster(unsigned long cursor,
page_remove_rmap(page);
page_cache_release(page);
+ acct_update_integrals();
mm->rss--;
(*mapcount)--;
}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d84bcc68909bbd..479015ed0b2f65 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/rmap.h>
#include <linux/security.h>
+#include <linux/acct.h>
#include <linux/backing-dev.h>
#include <linux/syscalls.h>
@@ -436,6 +437,8 @@ unuse_pte(struct vm_area_struct *vma, unsigned long address, pte_t *dir,
set_pte(dir, pte_mkold(mk_pte(page, vma->vm_page_prot)));
page_add_anon_rmap(page, vma, address);
swap_free(entry);
+ acct_update_integrals();
+ update_mem_hiwater();
}
/* vma->vm_mm->page_table_lock is held */