Skip to content

Commit fadae29

Browse files
Yang Shitorvalds
authored andcommitted
thp: use mm_file_counter to determine update which rss counter
Since commit eca56ff ("mm, shmem: add internal shmem resident memory accounting"), MM_SHMEMPAGES is added to separate the shmem accounting from regular files. So, all shmem pages should be accounted to MM_SHMEMPAGES instead of MM_FILEPAGES. And, normal 4K shmem pages have been accounted to MM_SHMEMPAGES, so shmem thp pages should be not treated differently. Account them to MM_SHMEMPAGES via mm_counter_file() since shmem pages are swap backed to keep consistent with normal 4K shmem pages. This will not change the rss counter of processes since shmem pages are still a part of it. The /proc/pid/status and /proc/pid/statm counters will however be more accurate wrt shmem usage, as originally intended. And as eca56ff ("mm, shmem: add internal shmem resident memory accounting") mentioned, oom also could report more accurate "shmem-rss". Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Yang Shi <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 720e14e commit fadae29

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

mm/huge_memory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
17401740
} else {
17411741
if (arch_needs_pgtable_deposit())
17421742
zap_deposited_table(tlb->mm, pmd);
1743-
add_mm_counter(tlb->mm, MM_FILEPAGES, -HPAGE_PMD_NR);
1743+
add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR);
17441744
}
17451745

17461746
spin_unlock(ptl);
@@ -2090,7 +2090,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
20902090
SetPageReferenced(page);
20912091
page_remove_rmap(page, true);
20922092
put_page(page);
2093-
add_mm_counter(mm, MM_FILEPAGES, -HPAGE_PMD_NR);
2093+
add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR);
20942094
return;
20952095
} else if (is_huge_zero_pmd(*pmd)) {
20962096
/*

mm/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3400,7 +3400,7 @@ static int do_set_pmd(struct vm_fault *vmf, struct page *page)
34003400
if (write)
34013401
entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma);
34023402

3403-
add_mm_counter(vma->vm_mm, MM_FILEPAGES, HPAGE_PMD_NR);
3403+
add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR);
34043404
page_add_file_rmap(page, true);
34053405
/*
34063406
* deposit and withdraw with pmd lock held

0 commit comments

Comments
 (0)