]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm,vmacache: add debug data
authorDavidlohr Bueso <davidlohr@hp.com>
Thu, 22 May 2014 00:42:45 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:42:45 +0000 (10:42 +1000)
Introduce a CONFIG_DEBUG_VM_VMACACHE option to enable counting the cache
hit rate -- exported in /proc/vmstat.

Any updates to the caching scheme needs this kind of data, thus it can
save some work re-implementing the counting all the time.

Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/vm_event_item.h
include/linux/vmstat.h
lib/Kconfig.debug
mm/vmacache.c
mm/vmstat.c

index 486c3972c0be2c698afd06d7ee0dcdb833aa21ff..ced92345c96307f559d165c56af092e520be3a06 100644 (file)
@@ -80,6 +80,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                NR_TLB_LOCAL_FLUSH_ALL,
                NR_TLB_LOCAL_FLUSH_ONE,
 #endif /* CONFIG_DEBUG_TLBFLUSH */
+#ifdef CONFIG_DEBUG_VM_VMACACHE
+               VMACACHE_FIND_CALLS,
+               VMACACHE_FIND_HITS,
+#endif
                NR_VM_EVENT_ITEMS
 };
 
index 45c9cd1daf7af5eb142e7d31ecc4389fdbd3daa6..82e7db7f7100f9e141de4a90196bffa24814ecc8 100644 (file)
@@ -95,6 +95,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_DEBUG_VM_VMACACHE
+#define count_vm_vmacache_event(x) count_vm_event(x)
+#else
+#define count_vm_vmacache_event(x) do {} while (0)
+#endif
+
 #define __count_zone_vm_events(item, zone, delta) \
                __count_vm_events(item##_NORMAL - ZONE_NORMAL + \
                zone_idx(zone), delta)
index 819ac51202c01006e105f91355d492db6bdd6eb6..9ed3d9b966cc6411b926ef0db6dfb649c534b6d5 100644 (file)
@@ -501,6 +501,16 @@ config DEBUG_VM
 
          If unsure, say N.
 
+config DEBUG_VM_VMACACHE
+       bool "Debug VMA caching"
+       depends on DEBUG_VM
+       help
+         Enable this to turn on VMA caching debug information. Doing so
+         can cause significant overhead, so only enable it in non-production
+         environments.
+
+         If unsure, say N.
+
 config DEBUG_VM_RB
        bool "Debug VM red-black trees"
        depends on DEBUG_VM
index 1037a3bab50529f84c9d81c383df07dbfbbda081..658ed3b3e38d32a2c210d43163554cb23e6ac173 100644 (file)
@@ -78,6 +78,8 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
        if (!vmacache_valid(mm))
                return NULL;
 
+       count_vm_vmacache_event(VMACACHE_FIND_CALLS);
+
        for (i = 0; i < VMACACHE_SIZE; i++) {
                struct vm_area_struct *vma = current->vmacache[i];
 
@@ -85,8 +87,10 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
                        continue;
                if (WARN_ON_ONCE(vma->vm_mm != mm))
                        break;
-               if (vma->vm_start <= addr && vma->vm_end > addr)
+               if (vma->vm_start <= addr && vma->vm_end > addr) {
+                       count_vm_vmacache_event(VMACACHE_FIND_HITS);
                        return vma;
+               }
        }
 
        return NULL;
@@ -102,11 +106,15 @@ struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
        if (!vmacache_valid(mm))
                return NULL;
 
+       count_vm_vmacache_event(VMACACHE_FIND_CALLS);
+
        for (i = 0; i < VMACACHE_SIZE; i++) {
                struct vm_area_struct *vma = current->vmacache[i];
 
-               if (vma && vma->vm_start == start && vma->vm_end == end)
+               if (vma && vma->vm_start == start && vma->vm_end == end) {
+                       count_vm_vmacache_event(VMACACHE_FIND_HITS);
                        return vma;
+               }
        }
 
        return NULL;
index 302dd076b8bf47bfb13a7925166b1b1f4e0dc5eb..82ce17ce58c4d6912a8b0e7189deb3f23891d8a0 100644 (file)
@@ -866,6 +866,10 @@ const char * const vmstat_text[] = {
        "nr_tlb_local_flush_one",
 #endif /* CONFIG_DEBUG_TLBFLUSH */
 
+#ifdef CONFIG_DEBUG_VM_VMACACHE
+       "vmacache_find_calls",
+       "vmacache_find_hits",
+#endif
 #endif /* CONFIG_VM_EVENTS_COUNTERS */
 };
 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */