Skip to content

Commit 3cd14fc

Browse files
kiryltorvalds
authored andcommitted
thp: account anon transparent huge pages into NR_ANON_PAGES
We use NR_ANON_PAGES as base for reporting AnonPages to user. There's not much sense in not accounting transparent huge pages there, but add them on printing to user. Let's account transparent huge pages in NR_ANON_PAGES in the first place. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Hugh Dickins <hughd@google.com> Cc: Wu Fengguang <fengguang.wu@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Mel Gorman <mgorman@suse.de> Cc: Andi Kleen <ak@linux.intel.com> Cc: Matthew Wilcox <willy@linux.intel.com> Cc: Hillf Danton <dhillf@gmail.com> Cc: Ning Qu <quning@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7caef26 commit 3cd14fc

4 files changed

Lines changed: 9 additions & 22 deletions

File tree

‎drivers/base/node.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ static ssize_t node_read_meminfo(struct device *dev,
125125
nid, K(node_page_state(nid, NR_WRITEBACK)),
126126
nid, K(node_page_state(nid, NR_FILE_PAGES)),
127127
nid, K(node_page_state(nid, NR_FILE_MAPPED)),
128-
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
129-
nid, K(node_page_state(nid, NR_ANON_PAGES)
130-
+ node_page_state(nid, NR_ANON_TRANSPARENT_HUGEPAGES) *
131-
HPAGE_PMD_NR),
132-
#else
133128
nid, K(node_page_state(nid, NR_ANON_PAGES)),
134-
#endif
135129
nid, K(node_page_state(nid, NR_SHMEM)),
136130
nid, node_page_state(nid, NR_KERNEL_STACK) *
137131
THREAD_SIZE / 1024,

‎fs/proc/meminfo.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
132132
K(i.freeswap),
133133
K(global_page_state(NR_FILE_DIRTY)),
134134
K(global_page_state(NR_WRITEBACK)),
135-
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
136-
K(global_page_state(NR_ANON_PAGES)
137-
+ global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
138-
HPAGE_PMD_NR),
139-
#else
140135
K(global_page_state(NR_ANON_PAGES)),
141-
#endif
142136
K(global_page_state(NR_FILE_MAPPED)),
143137
K(global_page_state(NR_SHMEM)),
144138
K(global_page_state(NR_SLAB_RECLAIMABLE) +

‎mm/huge_memory.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,6 @@ static void __split_huge_page_refcount(struct page *page,
16611661
BUG_ON(atomic_read(&page->_count) <= 0);
16621662

16631663
__mod_zone_page_state(zone, NR_ANON_TRANSPARENT_HUGEPAGES, -1);
1664-
__mod_zone_page_state(zone, NR_ANON_PAGES, HPAGE_PMD_NR);
16651664

16661665
ClearPageCompound(page);
16671666
compound_unlock(page);

‎mm/rmap.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,11 @@ void do_page_add_anon_rmap(struct page *page,
10521052
{
10531053
int first = atomic_inc_and_test(&page->_mapcount);
10541054
if (first) {
1055-
if (!PageTransHuge(page))
1056-
__inc_zone_page_state(page, NR_ANON_PAGES);
1057-
else
1055+
if (PageTransHuge(page))
10581056
__inc_zone_page_state(page,
10591057
NR_ANON_TRANSPARENT_HUGEPAGES);
1058+
__mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1059+
hpage_nr_pages(page));
10601060
}
10611061
if (unlikely(PageKsm(page)))
10621062
return;
@@ -1085,10 +1085,10 @@ void page_add_new_anon_rmap(struct page *page,
10851085
VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
10861086
SetPageSwapBacked(page);
10871087
atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
1088-
if (!PageTransHuge(page))
1089-
__inc_zone_page_state(page, NR_ANON_PAGES);
1090-
else
1088+
if (PageTransHuge(page))
10911089
__inc_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
1090+
__mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1091+
hpage_nr_pages(page));
10921092
__page_set_anon_rmap(page, vma, address, 1);
10931093
if (!mlocked_vma_newpage(vma, page)) {
10941094
SetPageActive(page);
@@ -1148,11 +1148,11 @@ void page_remove_rmap(struct page *page)
11481148
goto out;
11491149
if (anon) {
11501150
mem_cgroup_uncharge_page(page);
1151-
if (!PageTransHuge(page))
1152-
__dec_zone_page_state(page, NR_ANON_PAGES);
1153-
else
1151+
if (PageTransHuge(page))
11541152
__dec_zone_page_state(page,
11551153
NR_ANON_TRANSPARENT_HUGEPAGES);
1154+
__mod_zone_page_state(page_zone(page), NR_ANON_PAGES,
1155+
-hpage_nr_pages(page));
11561156
} else {
11571157
__dec_zone_page_state(page, NR_FILE_MAPPED);
11581158
mem_cgroup_dec_page_stat(page, MEM_CGROUP_STAT_FILE_MAPPED);

0 commit comments

Comments
 (0)