Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm: introduce per-VMA lock statistics

Add a new CONFIG_PER_VMA_LOCK_STATS config option to dump extra statistics
about handling page fault under VMA lock.

Link: https://lkml.kernel.org/r/20230227173632.3292573-29-surenb@google.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Suren Baghdasaryan and committed by
Andrew Morton
52f23865 444eeb17

+26
+6
include/linux/vm_event_item.h
··· 150 150 DIRECT_MAP_LEVEL2_SPLIT, 151 151 DIRECT_MAP_LEVEL3_SPLIT, 152 152 #endif 153 + #ifdef CONFIG_PER_VMA_LOCK_STATS 154 + VMA_LOCK_SUCCESS, 155 + VMA_LOCK_ABORT, 156 + VMA_LOCK_RETRY, 157 + VMA_LOCK_MISS, 158 + #endif 153 159 NR_VM_EVENT_ITEMS 154 160 }; 155 161
+6
include/linux/vmstat.h
··· 125 125 #define count_vm_tlb_events(x, y) do { (void)(y); } while (0) 126 126 #endif 127 127 128 + #ifdef CONFIG_PER_VMA_LOCK_STATS 129 + #define count_vm_vma_lock_event(x) count_vm_event(x) 130 + #else 131 + #define count_vm_vma_lock_event(x) do {} while (0) 132 + #endif 133 + 128 134 #define __count_zid_vm_events(item, zid, delta) \ 129 135 __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta) 130 136
+6
mm/Kconfig.debug
··· 279 279 280 280 If unsure, say Y. 281 281 282 + config PER_VMA_LOCK_STATS 283 + bool "Statistics for per-vma locks" 284 + depends on PER_VMA_LOCK 285 + default y 286 + help 287 + Statistics for per-vma locks.
+2
mm/memory.c
··· 5284 5284 /* Check if the VMA got isolated after we found it */ 5285 5285 if (vma->detached) { 5286 5286 vma_end_read(vma); 5287 + count_vm_vma_lock_event(VMA_LOCK_MISS); 5287 5288 /* The area was replaced with another one */ 5288 5289 goto retry; 5289 5290 } ··· 5293 5292 return vma; 5294 5293 inval: 5295 5294 rcu_read_unlock(); 5295 + count_vm_vma_lock_event(VMA_LOCK_ABORT); 5296 5296 return NULL; 5297 5297 } 5298 5298 #endif /* CONFIG_PER_VMA_LOCK */
+6
mm/vmstat.c
··· 1399 1399 "direct_map_level2_splits", 1400 1400 "direct_map_level3_splits", 1401 1401 #endif 1402 + #ifdef CONFIG_PER_VMA_LOCK_STATS 1403 + "vma_lock_success", 1404 + "vma_lock_abort", 1405 + "vma_lock_retry", 1406 + "vma_lock_miss", 1407 + #endif 1402 1408 #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */ 1403 1409 }; 1404 1410 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */