@@ -119,6 +119,13 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
THP_SWPOUT,
THP_SWPOUT_FALLBACK,
#endif
+#ifdef CONFIG_MCPAGE
+ MCPAGE_ANON_FAULT_ALLOC,
+ MCPAGE_ANON_FAULT_FALLBACK,
+ MCPAGE_ANON_FAULT_CHARGE_FAILED,
+ MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED,
+ MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE,
+#endif
#ifdef CONFIG_MEMORY_BALLOON
BALLOON_INFLATE,
BALLOON_DEFLATE,
@@ -159,5 +166,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
#define THP_FILE_FALLBACK_CHARGE ({ BUILD_BUG(); 0; })
#define THP_FILE_MAPPED ({ BUILD_BUG(); 0; })
#endif
+#ifndef CONFIG_MCPAGE
+#define MCPAGE_ANON_FAULT_FALLBACK ({ BUILD_BUG(); 0; })
+#endif
#endif /* VM_EVENT_ITEM_H_INCLUDED */
@@ -55,6 +55,7 @@ static vm_fault_t do_anonymous_mcpage(struct vm_fault *vmf,
if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) {
ret = VM_FAULT_OOM;
+ count_vm_event(MCPAGE_ANON_FAULT_CHARGE_FAILED);
goto oom;
}
@@ -71,12 +72,14 @@ static vm_fault_t do_anonymous_mcpage(struct vm_fault *vmf,
if (!pte_none(*vmf->pte)) {
ret = VM_FAULT_FALLBACK;
update_mmu_cache(vma, addr, vmf->pte);
+ count_vm_event(MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED);
goto release;
}
ret = check_stable_address_space(vma->vm_mm);
if (ret) {
ret = VM_FAULT_FALLBACK;
+ count_vm_event(MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE);
goto release;
}
@@ -120,6 +123,9 @@ vm_fault_t do_anonymous_mcpages(struct vm_fault *vmf, unsigned int order)
break;
}
+ if (i == nr)
+ count_vm_event(MCPAGE_ANON_FAULT_ALLOC);
+
while (i < nr)
put_page(&page[i++]);
@@ -4079,6 +4079,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf)
if (!(ret & VM_FAULT_FALLBACK))
return ret;
+ count_vm_event(MCPAGE_ANON_FAULT_FALLBACK);
ret = 0;
}
@@ -1367,6 +1367,13 @@ const char * const vmstat_text[] = {
"thp_swpout",
"thp_swpout_fallback",
#endif
+#ifdef CONFIG_MCPAGE
+ "mcpage_anon_fault_alloc",
+ "mcpage_anon_fault_fallback",
+ "mcpage_anon_fault_charge_failed",
+ "mcpage_anon_fault_page_table_populated",
+ "mcpage_anon_fault_instable_address_space",
+#endif
#ifdef CONFIG_MEMORY_BALLOON
"balloon_inflate",
"balloon_deflate",
MCPAGE_ANON_FAULT_ALLOC: how many times mcpage is used for anonymous mapping. MCPAGE_ANON_FAULT_FALLBACK: how many times fallback to normal page for anonymous mapping. MCPAGE_ANON_FAULT_CHARGE_FAILED: how many times fallback because of memcg charge failure. MCPAGE_ANON_FAULT_PAGE_TABLE_POPULATED: how many times fallback because page table already populated. MCPAGE_ANON_FAULT_INSTABLE_ADDRESS_SPACE: how many times fallback because of unstable address space. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> --- include/linux/vm_event_item.h | 10 ++++++++++ mm/mcpage_memory.c | 6 ++++++ mm/memory.c | 1 + mm/vmstat.c | 7 +++++++ 4 files changed, 24 insertions(+)