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

mm,vmacache: add debug data

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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Davidlohr Bueso and committed by
Linus Torvalds
4f115147 6f04f48d

+34 -2
+4
include/linux/vm_event_item.h
··· 80 80 NR_TLB_LOCAL_FLUSH_ALL, 81 81 NR_TLB_LOCAL_FLUSH_ONE, 82 82 #endif /* CONFIG_DEBUG_TLBFLUSH */ 83 + #ifdef CONFIG_DEBUG_VM_VMACACHE 84 + VMACACHE_FIND_CALLS, 85 + VMACACHE_FIND_HITS, 86 + #endif 83 87 NR_VM_EVENT_ITEMS 84 88 }; 85 89
+6
include/linux/vmstat.h
··· 95 95 #define count_vm_tlb_events(x, y) do { (void)(y); } while (0) 96 96 #endif 97 97 98 + #ifdef CONFIG_DEBUG_VM_VMACACHE 99 + #define count_vm_vmacache_event(x) count_vm_event(x) 100 + #else 101 + #define count_vm_vmacache_event(x) do {} while (0) 102 + #endif 103 + 98 104 #define __count_zone_vm_events(item, zone, delta) \ 99 105 __count_vm_events(item##_NORMAL - ZONE_NORMAL + \ 100 106 zone_idx(zone), delta)
+10
lib/Kconfig.debug
··· 501 501 502 502 If unsure, say N. 503 503 504 + config DEBUG_VM_VMACACHE 505 + bool "Debug VMA caching" 506 + depends on DEBUG_VM 507 + help 508 + Enable this to turn on VMA caching debug information. Doing so 509 + can cause significant overhead, so only enable it in non-production 510 + environments. 511 + 512 + If unsure, say N. 513 + 504 514 config DEBUG_VM_RB 505 515 bool "Debug VM red-black trees" 506 516 depends on DEBUG_VM
+10 -2
mm/vmacache.c
··· 78 78 if (!vmacache_valid(mm)) 79 79 return NULL; 80 80 81 + count_vm_vmacache_event(VMACACHE_FIND_CALLS); 82 + 81 83 for (i = 0; i < VMACACHE_SIZE; i++) { 82 84 struct vm_area_struct *vma = current->vmacache[i]; 83 85 ··· 87 85 continue; 88 86 if (WARN_ON_ONCE(vma->vm_mm != mm)) 89 87 break; 90 - if (vma->vm_start <= addr && vma->vm_end > addr) 88 + if (vma->vm_start <= addr && vma->vm_end > addr) { 89 + count_vm_vmacache_event(VMACACHE_FIND_HITS); 91 90 return vma; 91 + } 92 92 } 93 93 94 94 return NULL; ··· 106 102 if (!vmacache_valid(mm)) 107 103 return NULL; 108 104 105 + count_vm_vmacache_event(VMACACHE_FIND_CALLS); 106 + 109 107 for (i = 0; i < VMACACHE_SIZE; i++) { 110 108 struct vm_area_struct *vma = current->vmacache[i]; 111 109 112 - if (vma && vma->vm_start == start && vma->vm_end == end) 110 + if (vma && vma->vm_start == start && vma->vm_end == end) { 111 + count_vm_vmacache_event(VMACACHE_FIND_HITS); 113 112 return vma; 113 + } 114 114 } 115 115 116 116 return NULL;
+4
mm/vmstat.c
··· 866 866 "nr_tlb_local_flush_one", 867 867 #endif /* CONFIG_DEBUG_TLBFLUSH */ 868 868 869 + #ifdef CONFIG_DEBUG_VM_VMACACHE 870 + "vmacache_find_calls", 871 + "vmacache_find_hits", 872 + #endif 869 873 #endif /* CONFIG_VM_EVENTS_COUNTERS */ 870 874 }; 871 875 #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */