]> Gentwo Git Trees - linux/.git/commitdiff
ARM64: Add TLB counter diagnostics
authorChristoph Lameter (Ampere) <cl@linux.com>
Thu, 7 Dec 2023 04:11:49 +0000 (20:11 -0800)
committerChristoph Lameter (Ampere) <cl@linux.com>
Wed, 20 Dec 2023 15:20:52 +0000 (07:20 -0800)
x86 uses vmstat counters to display tlb statistics.

Use these statistics also on ARM64 and add some new variations
that we need for the new TLB handling.

We add a hacky variant of count_vm_tlb_event() here that
we remove later after the tlb handling functions have
been moved. After this patch we can see numbers on
how the existing tlb flushing operations work.

Signed-off-by: Christoph Lameter (Ampere) <cl@linux.com>
arch/arm64/Kconfig.debug
arch/arm64/include/asm/tlbflush.h
arch/arm64/mm/context.c
include/linux/vm_event_item.h
mm/vmstat.c

index 265c4461031f4df457eb782eac820070710c8d06..b6ce24db2a6a5e1a8c741808de0343db538f8133 100644 (file)
@@ -20,4 +20,11 @@ config ARM64_RELOC_TEST
        depends on m
        tristate "Relocation testing module"
 
+config DEBUG_TLBFLUSH
+        bool "Add vmstat counters to analyze TLB handling"
+        depends on DEBUG_KERNEL
+        help
+          This option allows the user to see the TLB flushing behavior in
+         /proc/vmstat.
+
 source "drivers/hwtracing/coresight/Kconfig"
index bb2c2833a98722640f27c78d67a3a1a5bdc557c7..65144b8d88d4490907770e6f2cf56457709508ae 100644 (file)
 #include <asm/cputype.h>
 #include <asm/mmu.h>
 
+/* vmstat.h cannot be include here. We will remove this soon */
+#include <linux/vm_event_item.h>
+extern void _count_vm_tlb_event(enum vm_event_item);
+
 /*
  * Raw TLBI operations.
  *
@@ -234,6 +238,7 @@ static inline void local_flush_tlb_all(void)
        __tlbi(vmalle1);
        dsb(nsh);
        isb();
+       _count_vm_tlb_event(NR_TLB_LOCAL_FLUSH_ALL);
 }
 
 static inline void flush_tlb_all(void)
@@ -242,6 +247,7 @@ static inline void flush_tlb_all(void)
        __tlbi(vmalle1is);
        dsb(ish);
        isb();
+       _count_vm_tlb_event(NR_TLB_FLUSH_ALL);
 }
 
 static inline void flush_tlb_mm(struct mm_struct *mm)
@@ -254,6 +260,7 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
        __tlbi_user(aside1is, asid);
        dsb(ish);
        mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL);
+       _count_vm_tlb_event(NR_TLB_FLUSH_ALL);
 }
 
 static inline void __flush_tlb_page_nosync(struct mm_struct *mm,
@@ -267,6 +274,7 @@ static inline void __flush_tlb_page_nosync(struct mm_struct *mm,
        __tlbi_user(vale1is, addr);
        mmu_notifier_arch_invalidate_secondary_tlbs(mm, uaddr & PAGE_MASK,
                                                (uaddr & PAGE_MASK) + PAGE_SIZE);
+       _count_vm_tlb_event(NR_TLB_FLUSH_ONE);
 }
 
 static inline void flush_tlb_page_nosync(struct vm_area_struct *vma,
@@ -433,6 +441,7 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma,
 
        dsb(ish);
        mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, start, end);
+       _count_vm_tlb_event(NR_TLB_FLUSH_RANGE);
 }
 
 static inline void flush_tlb_range(struct vm_area_struct *vma,
index 188197590fc9ce44da04246455571fc9ee47c57c..5a06d05251ebf4aecca186c9f3ea5ccdf9716828 100644 (file)
@@ -420,3 +420,9 @@ static int asids_init(void)
        return 0;
 }
 early_initcall(asids_init);
+
+void _count_vm_tlb_event(enum vm_event_item x)
+{
+       count_vm_tlb_event(x);
+}
+
index 8abfa124004003cb14d83083306cca68ab070086..a490c5f0720abcec8b9c6dae289ecad5e52c7f55 100644 (file)
@@ -130,7 +130,12 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                NR_TLB_REMOTE_FLUSH,    /* cpu tried to flush others' tlbs */
                NR_TLB_REMOTE_FLUSH_RECEIVED,/* cpu received ipi for flush */
                NR_TLB_LOCAL_FLUSH_ALL,
+               NR_TLB_LOCAL_FLUSH_RANGE,
                NR_TLB_LOCAL_FLUSH_ONE,
+               NR_TLB_FLUSH_ALL,
+               NR_TLB_FLUSH_RANGE,
+               NR_TLB_FLUSH_ONE,
+               NR_TLB_SKIPPED,
 #endif /* CONFIG_DEBUG_TLBFLUSH */
 #ifdef CONFIG_SWAP
                SWAP_RA,
index 359460deb37776d1425846967bee27dee33cbacd..8fc2943c69bc7c3da1ae6054a60736c2e60ca7e0 100644 (file)
@@ -1385,7 +1385,12 @@ const char * const vmstat_text[] = {
        "nr_tlb_remote_flush",
        "nr_tlb_remote_flush_received",
        "nr_tlb_local_flush_all",
+       "nr_tlb_local_flush_range",
        "nr_tlb_local_flush_one",
+       "nr_tlb_flush_all",
+       "nr_tlb_flush_range",
+       "nr_tlb_flush_one",
+       "nr_tlb_skipped",
 #endif /* CONFIG_DEBUG_TLBFLUSH */
 
 #ifdef CONFIG_SWAP