Commit dcdf11ee authored by David Rientjes's avatar David Rientjes Committed by Linus Torvalds

mm, shmem: add vmstat for hugepage fallback

The existing thp_fault_fallback indicates when thp attempts to allocate a
hugepage but fails, or if the hugepage cannot be charged to the mem cgroup
hierarchy.

Extend this to shmem as well.  Adds a new thp_file_fallback to complement
thp_file_alloc that gets incremented when a hugepage is attempted to be
allocated but fails, or if it cannot be charged to the mem cgroup
hierarchy.

Additionally, remove the check for CONFIG_TRANSPARENT_HUGE_PAGECACHE from
shmem_alloc_hugepage() since it is only called with this configuration
option.
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
Acked-by: default avatarKirill 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.2003061421240.7412@chino.kir.corp.google.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6aeff241
...@@ -319,6 +319,10 @@ thp_file_alloc ...@@ -319,6 +319,10 @@ thp_file_alloc
is incremented every time a file huge page is successfully is incremented every time a file huge page is successfully
allocated. allocated.
thp_file_fallback
is incremented if a file huge page is attempted to be allocated
but fails and instead falls back to using small pages.
thp_file_mapped thp_file_mapped
is incremented every time a file huge page is mapped into is incremented every time a file huge page is mapped into
user address space. user address space.
......
...@@ -76,6 +76,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, ...@@ -76,6 +76,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
THP_COLLAPSE_ALLOC, THP_COLLAPSE_ALLOC,
THP_COLLAPSE_ALLOC_FAILED, THP_COLLAPSE_ALLOC_FAILED,
THP_FILE_ALLOC, THP_FILE_ALLOC,
THP_FILE_FALLBACK,
THP_FILE_MAPPED, THP_FILE_MAPPED,
THP_SPLIT_PAGE, THP_SPLIT_PAGE,
THP_SPLIT_PAGE_FAILED, THP_SPLIT_PAGE_FAILED,
...@@ -115,6 +116,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, ...@@ -115,6 +116,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
#ifndef CONFIG_TRANSPARENT_HUGEPAGE #ifndef CONFIG_TRANSPARENT_HUGEPAGE
#define THP_FILE_ALLOC ({ BUILD_BUG(); 0; }) #define THP_FILE_ALLOC ({ BUILD_BUG(); 0; })
#define THP_FILE_FALLBACK ({ BUILD_BUG(); 0; })
#define THP_FILE_MAPPED ({ BUILD_BUG(); 0; }) #define THP_FILE_MAPPED ({ BUILD_BUG(); 0; })
#endif #endif
......
...@@ -1472,9 +1472,6 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, ...@@ -1472,9 +1472,6 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp,
pgoff_t hindex; pgoff_t hindex;
struct page *page; struct page *page;
if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE))
return NULL;
hindex = round_down(index, HPAGE_PMD_NR); hindex = round_down(index, HPAGE_PMD_NR);
if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1, if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1,
XA_PRESENT)) XA_PRESENT))
...@@ -1486,6 +1483,8 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, ...@@ -1486,6 +1483,8 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp,
shmem_pseudo_vma_destroy(&pvma); shmem_pseudo_vma_destroy(&pvma);
if (page) if (page)
prep_transhuge_page(page); prep_transhuge_page(page);
else
count_vm_event(THP_FILE_FALLBACK);
return page; return page;
} }
...@@ -1871,8 +1870,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, ...@@ -1871,8 +1870,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index,
error = mem_cgroup_try_charge_delay(page, charge_mm, gfp, &memcg, error = mem_cgroup_try_charge_delay(page, charge_mm, gfp, &memcg,
PageTransHuge(page)); PageTransHuge(page));
if (error) if (error) {
if (PageTransHuge(page))
count_vm_event(THP_FILE_FALLBACK);
goto unacct; goto unacct;
}
error = shmem_add_to_page_cache(page, mapping, hindex, error = shmem_add_to_page_cache(page, mapping, hindex,
NULL, gfp & GFP_RECLAIM_MASK); NULL, gfp & GFP_RECLAIM_MASK);
if (error) { if (error) {
......
...@@ -1259,6 +1259,7 @@ const char * const vmstat_text[] = { ...@@ -1259,6 +1259,7 @@ const char * const vmstat_text[] = {
"thp_collapse_alloc", "thp_collapse_alloc",
"thp_collapse_alloc_failed", "thp_collapse_alloc_failed",
"thp_file_alloc", "thp_file_alloc",
"thp_file_fallback",
"thp_file_mapped", "thp_file_mapped",
"thp_split_page", "thp_split_page",
"thp_split_page_failed", "thp_split_page_failed",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment