Skip to content

Commit 85b9f46

Browse files
rientjestorvalds
authored andcommitted
mm, thp: track fallbacks due to failed memcg charges separately
The thp_fault_fallback and thp_file_fallback vmstats are incremented if either the hugepage allocation fails through the page allocator or the hugepage charge fails through mem cgroup. This patch leaves this field untouched but adds two new fields, thp_{fault,file}_fallback_charge, which is incremented only when the mem cgroup charge fails. This distinguishes between attempted hugepage allocations that fail due to fragmentation (or low memory conditions) and those that fail due to mem cgroup limits. That can be used to determine the impact of fragmentation on the system by excluding faults that failed due to memcg usage. Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Yang Shi <yang.shi@linux.alibaba.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Mike Rapoport <rppt@linux.ibm.com> Cc: Jeremy Cline <jcline@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Michal Hocko <mhocko@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Link: http://lkml.kernel.org/r/alpine.DEB.2.21.2003061422070.7412@chino.kir.corp.google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dcdf11e commit 85b9f46

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ thp_fault_fallback
310310
is incremented if a page fault fails to allocate
311311
a huge page and instead falls back to using small pages.
312312

313+
thp_fault_fallback_charge
314+
is incremented if a page fault fails to charge a huge page and
315+
instead falls back to using small pages even though the
316+
allocation was successful.
317+
313318
thp_collapse_alloc_failed
314319
is incremented if khugepaged found a range
315320
of pages that should be collapsed into one huge page but failed
@@ -323,6 +328,11 @@ thp_file_fallback
323328
is incremented if a file huge page is attempted to be allocated
324329
but fails and instead falls back to using small pages.
325330

331+
thp_file_fallback_charge
332+
is incremented if a file huge page cannot be charged and instead
333+
falls back to using small pages even though the allocation was
334+
successful.
335+
326336
thp_file_mapped
327337
is incremented every time a file huge page is mapped into
328338
user address space.

include/linux/vm_event_item.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
7373
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
7474
THP_FAULT_ALLOC,
7575
THP_FAULT_FALLBACK,
76+
THP_FAULT_FALLBACK_CHARGE,
7677
THP_COLLAPSE_ALLOC,
7778
THP_COLLAPSE_ALLOC_FAILED,
7879
THP_FILE_ALLOC,
7980
THP_FILE_FALLBACK,
81+
THP_FILE_FALLBACK_CHARGE,
8082
THP_FILE_MAPPED,
8183
THP_SPLIT_PAGE,
8284
THP_SPLIT_PAGE_FAILED,
@@ -117,6 +119,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
117119
#ifndef CONFIG_TRANSPARENT_HUGEPAGE
118120
#define THP_FILE_ALLOC ({ BUILD_BUG(); 0; })
119121
#define THP_FILE_FALLBACK ({ BUILD_BUG(); 0; })
122+
#define THP_FILE_FALLBACK_CHARGE ({ BUILD_BUG(); 0; })
120123
#define THP_FILE_MAPPED ({ BUILD_BUG(); 0; })
121124
#endif
122125

mm/huge_memory.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf,
597597
if (mem_cgroup_try_charge_delay(page, vma->vm_mm, gfp, &memcg, true)) {
598598
put_page(page);
599599
count_vm_event(THP_FAULT_FALLBACK);
600+
count_vm_event(THP_FAULT_FALLBACK_CHARGE);
600601
return VM_FAULT_FALLBACK;
601602
}
602603

@@ -1446,6 +1447,7 @@ vm_fault_t do_huge_pmd_wp_page(struct vm_fault *vmf, pmd_t orig_pmd)
14461447
put_page(page);
14471448
ret |= VM_FAULT_FALLBACK;
14481449
count_vm_event(THP_FAULT_FALLBACK);
1450+
count_vm_event(THP_FAULT_FALLBACK_CHARGE);
14491451
goto out;
14501452
}
14511453

mm/shmem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,10 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
18711871
error = mem_cgroup_try_charge_delay(page, charge_mm, gfp, &memcg,
18721872
PageTransHuge(page));
18731873
if (error) {
1874-
if (PageTransHuge(page))
1874+
if (PageTransHuge(page)) {
18751875
count_vm_event(THP_FILE_FALLBACK);
1876+
count_vm_event(THP_FILE_FALLBACK_CHARGE);
1877+
}
18761878
goto unacct;
18771879
}
18781880
error = shmem_add_to_page_cache(page, mapping, hindex,

mm/vmstat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,10 +1256,12 @@ const char * const vmstat_text[] = {
12561256
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
12571257
"thp_fault_alloc",
12581258
"thp_fault_fallback",
1259+
"thp_fault_fallback_charge",
12591260
"thp_collapse_alloc",
12601261
"thp_collapse_alloc_failed",
12611262
"thp_file_alloc",
12621263
"thp_file_fallback",
1264+
"thp_file_fallback_charge",
12631265
"thp_file_mapped",
12641266
"thp_split_page",
12651267
"thp_split_page_failed",

0 commit comments

Comments
 (0)