Skip to content

Commit 7913417

Browse files
aagittorvalds
authored andcommitted
thp: transparent hugepage vmstat
Add hugepage stat information to /proc/vmstat and /proc/meminfo. Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b9bbfbe commit 7913417

File tree

5 files changed

+34
-5
lines changed

5 files changed

+34
-5
lines changed

fs/proc/meminfo.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
100100
"VmallocChunk: %8lu kB\n"
101101
#ifdef CONFIG_MEMORY_FAILURE
102102
"HardwareCorrupted: %5lu kB\n"
103+
#endif
104+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
105+
"AnonHugePages: %8lu kB\n"
103106
#endif
104107
,
105108
K(i.totalram),
@@ -128,7 +131,12 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
128131
K(i.freeswap),
129132
K(global_page_state(NR_FILE_DIRTY)),
130133
K(global_page_state(NR_WRITEBACK)),
131-
K(global_page_state(NR_ANON_PAGES)),
134+
K(global_page_state(NR_ANON_PAGES)
135+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
136+
+ global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
137+
HPAGE_PMD_NR
138+
#endif
139+
),
132140
K(global_page_state(NR_FILE_MAPPED)),
133141
K(global_page_state(NR_SHMEM)),
134142
K(global_page_state(NR_SLAB_RECLAIMABLE) +
@@ -150,6 +158,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
150158
vmi.largest_chunk >> 10
151159
#ifdef CONFIG_MEMORY_FAILURE
152160
,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
161+
#endif
162+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
163+
,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
164+
HPAGE_PMD_NR)
153165
#endif
154166
);
155167

include/linux/mmzone.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ enum zone_stat_item {
114114
NUMA_LOCAL, /* allocation from local node */
115115
NUMA_OTHER, /* allocation from other node */
116116
#endif
117+
NR_ANON_TRANSPARENT_HUGEPAGES,
117118
NR_VM_ZONE_STAT_ITEMS };
118119

119120
/*

mm/huge_memory.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ static void __split_huge_page_refcount(struct page *page)
751751
lru_add_page_tail(zone, page, page_tail);
752752
}
753753

754+
__dec_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
755+
__mod_zone_page_state(zone, NR_ANON_PAGES, HPAGE_PMD_NR);
756+
754757
ClearPageCompound(page);
755758
compound_unlock(page);
756759
spin_unlock_irq(&zone->lru_lock);

mm/rmap.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,8 +882,13 @@ void do_page_add_anon_rmap(struct page *page,
882882
struct vm_area_struct *vma, unsigned long address, int exclusive)
883883
{
884884
int first = atomic_inc_and_test(&page->_mapcount);
885-
if (first)
886-
__inc_zone_page_state(page, NR_ANON_PAGES);
885+
if (first) {
886+
if (!PageTransHuge(page))
887+
__inc_zone_page_state(page, NR_ANON_PAGES);
888+
else
889+
__inc_zone_page_state(page,
890+
NR_ANON_TRANSPARENT_HUGEPAGES);
891+
}
887892
if (unlikely(PageKsm(page)))
888893
return;
889894

@@ -911,7 +916,10 @@ void page_add_new_anon_rmap(struct page *page,
911916
VM_BUG_ON(address < vma->vm_start || address >= vma->vm_end);
912917
SetPageSwapBacked(page);
913918
atomic_set(&page->_mapcount, 0); /* increment count (starts at -1) */
914-
__inc_zone_page_state(page, NR_ANON_PAGES);
919+
if (!PageTransHuge(page))
920+
__inc_zone_page_state(page, NR_ANON_PAGES);
921+
else
922+
__inc_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
915923
__page_set_anon_rmap(page, vma, address, 1);
916924
if (page_evictable(page, vma))
917925
lru_cache_add_lru(page, LRU_ACTIVE_ANON);
@@ -964,7 +972,11 @@ void page_remove_rmap(struct page *page)
964972
return;
965973
if (PageAnon(page)) {
966974
mem_cgroup_uncharge_page(page);
967-
__dec_zone_page_state(page, NR_ANON_PAGES);
975+
if (!PageTransHuge(page))
976+
__dec_zone_page_state(page, NR_ANON_PAGES);
977+
else
978+
__dec_zone_page_state(page,
979+
NR_ANON_TRANSPARENT_HUGEPAGES);
968980
} else {
969981
__dec_zone_page_state(page, NR_FILE_MAPPED);
970982
mem_cgroup_update_file_mapped(page, -1);

mm/vmstat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ static const char * const vmstat_text[] = {
880880
"numa_local",
881881
"numa_other",
882882
#endif
883+
"nr_anon_transparent_hugepages",
883884
"nr_dirty_threshold",
884885
"nr_dirty_background_threshold",
885886

0 commit comments

Comments
 (0)