mm: Rework the RSS accounting functions
Subsystems (7)
Commit-ID: 9e7b0f30b17bacb7ed2904cb3fee514208b5b42e Gitweb: http://git.kernel.org/tip/9e7b0f30b17bacb7ed2904cb3fee514208b5b42e Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 8 Mar 2012 23:03:20 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 18 May 2012 08:16:26 +0200
mm: Rework the RSS accounting functions
Rework the RSS accounting functions so we could do per vma RSS accounting. This replaces the mm_struct argument with a vm_area_struct and renames them from *mm_counter* to *rss_counter*.
Signed-off-by Peter Zijlstra <[email protected]>
Cc Suresh Siddha <[email protected]>
Cc Paul Turner <[email protected]>
Cc Dan Smith <[email protected]>
Cc Bharata B Rao <[email protected]>
Cc Lee Schermerhorn <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Linus Torvalds <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- fs/exec.c | 2 +- include/linux/mm.h | 12 ++++++------ mm/filemap_xip.c | 2 +- mm/fremap.c | 2 +- mm/huge_memory.c | 8 ++++---- mm/memory.c | 51 +++++++++++++++++++++++++++------------------------ mm/rmap.c | 12 ++++++------ mm/swapfile.c | 4 ++-- 8 files changed, 48 insertions(+), 45 deletions(-)
fs/exec.c +1 -1
@@ -184,7 +184,7 @@ static void acct_arg_size(struct linux_binprm *bprm, unsigned long pages)return ; bprm->vma_pages = pages; -add_mm_counter (mm,MM_ANONPAGES , diff); +add_rss_counter (bprm->vma,MM_ANONPAGES , diff); } static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
include/linux/mm.h +6 -6
@@ -1076,19 +1076,19 @@ static inline unsigned long get_mm_counter(struct mm_struct *mm, int member)return (unsigned long )val; } -static inline void add_mm_counter (struct mm_struct *mm,int member,long value) +static inline void add_rss_counter (struct vm_area_struct *vma,int member,long value) { -atomic_long_add (value, &mm->rss_stat.count[member]); +atomic_long_add (value, &vma->vm_mm->rss_stat.count[member]); } -static inline void inc_mm_counter (struct mm_struct *mm,int member) +static inline void inc_rss_counter (struct vm_area_struct *vma,int member) { -atomic_long_inc (&mm->rss_stat.count[member]); +atomic_long_inc (&vma->vm_mm->rss_stat.count[member]); } -static inline void dec_mm_counter (struct mm_struct *mm,int member) +static inline void dec_rss_counter (struct vm_area_struct *vma,int member) { -atomic_long_dec (&mm->rss_stat.count[member]); +atomic_long_dec (&vma->vm_mm->rss_stat.count[member]); }static inline unsigned long get_mm_rss (struct mm_struct *mm)
mm/filemap_xip.c +1 -1
@@ -195,7 +195,7 @@ retry:flush_cache_page (vma, address,pte_pfn (*pte)); pteval =ptep_clear_flush_notify (vma, address, pte);page_remove_rmap (page); -dec_mm_counter (mm,MM_FILEPAGES ); +dec_rss_counter (vma,MM_FILEPAGES );BUG_ON (pte_dirty (pteval));pte_unmap_unlock (pte, ptl);page_cache_release (page);
mm/fremap.c +1 -1
@@ -39,7 +39,7 @@ static void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,page_remove_rmap (page);page_cache_release (page);update_hiwater_rss (mm); -dec_mm_counter (mm,MM_FILEPAGES ); +dec_rss_counter (vma,MM_FILEPAGES ); } }else {if (!pte_file (pte))
mm/huge_memory.c +4 -4
@@ -670,7 +670,7 @@ static int __do_huge_pmd_anonymous_page(struct mm_struct *mm,page_add_new_anon_rmap (page, vma, haddr);set_pmd_at (mm, haddr, pmd, entry);prepare_pmd_huge_pte (pgtable, mm); -add_mm_counter (mm,MM_ANONPAGES ,HPAGE_PMD_NR ); +add_rss_counter (vma,MM_ANONPAGES ,HPAGE_PMD_NR ); mm->nr_ptes++;spin_unlock (&mm->page_table_lock); }
@@ -784,7 +784,7 @@ int copy_huge_pmd(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vmaVM_BUG_ON (!PageHead (src_page));get_page (src_page);page_dup_rmap (src_page); -add_mm_counter (dst_mm,MM_ANONPAGES ,HPAGE_PMD_NR ); +add_rss_counter (dst_vma,MM_ANONPAGES ,HPAGE_PMD_NR );pmdp_set_wrprotect (src_mm, addr, src_pmd); pmd =pmd_mkold (pmd_wrprotect (pmd));
@@ -1040,7 +1040,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,tlb_remove_pmd_tlb_entry (tlb, pmd, addr);page_remove_rmap (page);VM_BUG_ON (page_mapcount (page) <0 ); -add_mm_counter (tlb->mm,MM_ANONPAGES , -HPAGE_PMD_NR ); +add_rss_counter (vma,MM_ANONPAGES , -HPAGE_PMD_NR );VM_BUG_ON (!PageHead (page)); tlb->mm->nr_ptes--;spin_unlock (&tlb->mm->page_table_lock);
@@ -1797,7 +1797,7 @@ static void __collapse_huge_page_copy(pte_t *pte, struct page *page,if (pte_none (pteval)) {clear_user_highpage (page, address); -add_mm_counter (vma->vm_mm,MM_ANONPAGES ,1 ); +add_rss_counter (vma,MM_ANONPAGES ,1 ); }else { src_page =pte_page (pteval);copy_user_highpage (page, src_page, address, vma);
mm/memory.c +27 -24
131 lines not on this page · raw message
mm/rmap.c +6 -6
@@ -1273,9 +1273,9 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,if (PageHWPoison (page) && !(flags &TTU_IGNORE_HWPOISON )) {if (PageAnon (page)) -dec_mm_counter (mm,MM_ANONPAGES ); +dec_rss_counter (vma,MM_ANONPAGES );else -dec_mm_counter (mm,MM_FILEPAGES ); +dec_rss_counter (vma,MM_FILEPAGES );set_pte_at (mm, address, pte,swp_entry_to_pte (make_hwpoison_entry (page))); }else if (PageAnon (page)) {
@@ -1297,8 +1297,8 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,list_add (&mm->mmlist, &init_mm.mmlist);spin_unlock (&mmlist_lock); } -dec_mm_counter (mm,MM_ANONPAGES ); -inc_mm_counter (mm,MM_SWAPENTS ); +dec_rss_counter (vma,MM_ANONPAGES ); +inc_rss_counter (vma,MM_SWAPENTS ); }else if (IS_ENABLED (CONFIG_MIGRATION )) {/* * Store the pfn of the page in a special migration
@@ -1317,7 +1317,7 @@ int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, entry =make_migration_entry (page,pte_write (pteval));set_pte_at (mm, address, pte,swp_entry_to_pte (entry)); }else -dec_mm_counter (mm,MM_FILEPAGES ); +dec_rss_counter (vma,MM_FILEPAGES );page_remove_rmap (page);page_cache_release (page);
@@ -1456,7 +1456,7 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,page_remove_rmap (page);page_cache_release (page); -dec_mm_counter (mm,MM_FILEPAGES ); +dec_rss_counter (vma,MM_FILEPAGES ); (*mapcount)--; }pte_unmap_unlock (pte -1 , ptl);
mm/swapfile.c +2 -2
@@ -879,8 +879,8 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, goto out; } -dec_mm_counter (vma->vm_mm,MM_SWAPENTS ); -inc_mm_counter (vma->vm_mm,MM_ANONPAGES ); +dec_rss_counter (vma,MM_SWAPENTS ); +inc_rss_counter (vma,MM_ANONPAGES );get_page (page);set_pte_at (vma->vm_mm, addr, pte,pte_mkold (mk_pte (page, vma->vm_page_prot)));