diff mbox series

[RFC,3/4] mm: Add speculative numa fault stats

Message ID bb19a1a3997a2424d13da02c6e7297e624e09a4f.1639306956.git.baolin.wang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series Add speculative numa fault support | expand

Commit Message

Baolin Wang Dec. 12, 2021, 11:31 a.m. UTC
Add a new statistic to help to tune the speculative numa fault window.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 include/linux/vm_event_item.h | 1 +
 mm/memory.c                   | 2 ++
 mm/vmstat.c                   | 1 +
 3 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index a185cc75ff52..97cdc661b7da 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -62,6 +62,7 @@  enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 		THP_MIGRATION_SUCCESS,
 		THP_MIGRATION_FAIL,
 		THP_MIGRATION_SPLIT,
+		PGMIGRATE_SPECULATION,
 #endif
 #ifdef CONFIG_COMPACTION
 		COMPACTMIGRATE_SCANNED, COMPACTFREE_SCANNED,
diff --git a/mm/memory.c b/mm/memory.c
index a0f4a2a008cc..91122beb6e53 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4572,6 +4572,8 @@  static vm_fault_t do_numa_page(struct vm_fault *vmf)
 	if (migrate_misplaced_page(page, vma, target_nid)) {
 		page_nid = target_nid;
 		flags |= TNF_MIGRATED;
+		if (vmf->address != fault_address)
+			count_vm_events(PGMIGRATE_SPECULATION, 1);
 	} else {
 		flags |= TNF_MIGRATE_FAIL;
 		vmf->pte = pte_offset_map(vmf->pmd, fault_address);
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 787a012de3e2..c64700994786 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1314,6 +1314,7 @@  const char * const vmstat_text[] = {
 	"thp_migration_success",
 	"thp_migration_fail",
 	"thp_migration_split",
+	"pgmigrate_speculation",
 #endif
 #ifdef CONFIG_COMPACTION
 	"compact_migrate_scanned",