]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: introduce per-VMA lock statistics
authorSuren Baghdasaryan <surenb@google.com>
Mon, 27 Feb 2023 17:36:27 +0000 (09:36 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 5 Apr 2023 23:02:11 +0000 (16:02 -0700)
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>
include/linux/vm_event_item.h
include/linux/vmstat.h
mm/Kconfig.debug
mm/memory.c
mm/vmstat.c

index 7f5d1caf5890e4c0cc97058640ff9e92bdc113aa..8abfa124004003cb14d83083306cca68ab070086 100644 (file)
@@ -149,6 +149,12 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 #ifdef CONFIG_X86
                DIRECT_MAP_LEVEL2_SPLIT,
                DIRECT_MAP_LEVEL3_SPLIT,
+#endif
+#ifdef CONFIG_PER_VMA_LOCK_STATS
+               VMA_LOCK_SUCCESS,
+               VMA_LOCK_ABORT,
+               VMA_LOCK_RETRY,
+               VMA_LOCK_MISS,
 #endif
                NR_VM_EVENT_ITEMS
 };
index 19cf5b6892ceba12c9f8acfa0a7910b4a2e726d4..fed855bae6d8e88956064f85f1260bca522bb5fb 100644 (file)
@@ -125,6 +125,12 @@ static inline void vm_events_fold_cpu(int cpu)
 #define count_vm_tlb_events(x, y) do { (void)(y); } while (0)
 #endif
 
+#ifdef CONFIG_PER_VMA_LOCK_STATS
+#define count_vm_vma_lock_event(x) count_vm_event(x)
+#else
+#define count_vm_vma_lock_event(x) do {} while (0)
+#endif
+
 #define __count_zid_vm_events(item, zid, delta) \
        __count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)
 
index c3547a373c9cafdc73e5c7b2353600c23a8f5a2c..4965a7333a3f44666e2d52d1cecce552ecaf2d6b 100644 (file)
@@ -279,3 +279,9 @@ config DEBUG_KMEMLEAK_AUTO_SCAN
 
          If unsure, say Y.
 
+config PER_VMA_LOCK_STATS
+       bool "Statistics for per-vma locks"
+       depends on PER_VMA_LOCK
+       default y
+       help
+         Statistics for per-vma locks.
index e37ce64c646ed9aa2b73fea5611b3662b492096f..d561e98383ecacd52c24a4c0e6d05da72842e7c1 100644 (file)
@@ -5288,6 +5288,7 @@ retry:
        /* Check if the VMA got isolated after we found it */
        if (vma->detached) {
                vma_end_read(vma);
+               count_vm_vma_lock_event(VMA_LOCK_MISS);
                /* The area was replaced with another one */
                goto retry;
        }
@@ -5296,6 +5297,7 @@ retry:
        return vma;
 inval:
        rcu_read_unlock();
+       count_vm_vma_lock_event(VMA_LOCK_ABORT);
        return NULL;
 }
 #endif /* CONFIG_PER_VMA_LOCK */
index 1ea6a5ce1c4161b5f41387a82e64c2446ad93a50..4f1089a1860e4806e044084b56680cb4684ee073 100644 (file)
@@ -1399,6 +1399,12 @@ const char * const vmstat_text[] = {
        "direct_map_level2_splits",
        "direct_map_level3_splits",
 #endif
+#ifdef CONFIG_PER_VMA_LOCK_STATS
+       "vma_lock_success",
+       "vma_lock_abort",
+       "vma_lock_retry",
+       "vma_lock_miss",
+#endif
 #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */