aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavidlohr Bueso <davidlohr@hp.com>2014-06-04 19:06:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 19:53:57 -0400
commit4f115147ff802267d0aa41e361c5aa5bd933d896 (patch)
tree27afdf3f60c21fde601df63d9e9998b0c758a3fe
parent6f04f48dc9c0433e2bb687f5f7f7af1aba97b04d (diff)
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>
-rw-r--r--include/linux/vm_event_item.h4
-rw-r--r--include/linux/vmstat.h6
-rw-r--r--lib/Kconfig.debug10
-rw-r--r--mm/vmacache.c12
-rw-r--r--mm/vmstat.c4
5 files changed, 34 insertions, 2 deletions
diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index 486c3972c0be..ced92345c963 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -80,6 +80,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
80 NR_TLB_LOCAL_FLUSH_ALL, 80 NR_TLB_LOCAL_FLUSH_ALL,
81 NR_TLB_LOCAL_FLUSH_ONE, 81 NR_TLB_LOCAL_FLUSH_ONE,
82#endif /* CONFIG_DEBUG_TLBFLUSH */ 82#endif /* CONFIG_DEBUG_TLBFLUSH */
83#ifdef CONFIG_DEBUG_VM_VMACACHE
84 VMACACHE_FIND_CALLS,
85 VMACACHE_FIND_HITS,
86#endif
83 NR_VM_EVENT_ITEMS 87 NR_VM_EVENT_ITEMS
84}; 88};
85 89
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 45c9cd1daf7a..82e7db7f7100 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -95,6 +95,12 @@ static inline void vm_events_fold_cpu(int cpu)
95#define count_vm_tlb_events(x, y) do { (void)(y); } while (0) 95#define count_vm_tlb_events(x, y) do { (void)(y); } while (0)
96#endif 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#define __count_zone_vm_events(item, zone, delta) \ 104#define __count_zone_vm_events(item, zone, delta) \
99 __count_vm_events(item##_NORMAL - ZONE_NORMAL + \ 105 __count_vm_events(item##_NORMAL - ZONE_NORMAL + \
100 zone_idx(zone), delta) 106 zone_idx(zone), delta)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 99c8bfee1b00..c2de65045a40 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -501,6 +501,16 @@ config DEBUG_VM
501 501
502 If unsure, say N. 502 If unsure, say N.
503 503
504config 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
504config DEBUG_VM_RB 514config DEBUG_VM_RB
505 bool "Debug VM red-black trees" 515 bool "Debug VM red-black trees"
506 depends on DEBUG_VM 516 depends on DEBUG_VM
diff --git a/mm/vmacache.c b/mm/vmacache.c
index 1037a3bab505..658ed3b3e38d 100644
--- a/mm/vmacache.c
+++ b/mm/vmacache.c
@@ -78,6 +78,8 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
78 if (!vmacache_valid(mm)) 78 if (!vmacache_valid(mm))
79 return NULL; 79 return NULL;
80 80
81 count_vm_vmacache_event(VMACACHE_FIND_CALLS);
82
81 for (i = 0; i < VMACACHE_SIZE; i++) { 83 for (i = 0; i < VMACACHE_SIZE; i++) {
82 struct vm_area_struct *vma = current->vmacache[i]; 84 struct vm_area_struct *vma = current->vmacache[i];
83 85
@@ -85,8 +87,10 @@ struct vm_area_struct *vmacache_find(struct mm_struct *mm, unsigned long addr)
85 continue; 87 continue;
86 if (WARN_ON_ONCE(vma->vm_mm != mm)) 88 if (WARN_ON_ONCE(vma->vm_mm != mm))
87 break; 89 break;
88 if (vma->vm_start <= addr && vma->vm_end > addr) 90 if (vma->vm_start <= addr && vma->vm_end > addr) {
91 count_vm_vmacache_event(VMACACHE_FIND_HITS);
89 return vma; 92 return vma;
93 }
90 } 94 }
91 95
92 return NULL; 96 return NULL;
@@ -102,11 +106,15 @@ struct vm_area_struct *vmacache_find_exact(struct mm_struct *mm,
102 if (!vmacache_valid(mm)) 106 if (!vmacache_valid(mm))
103 return NULL; 107 return NULL;
104 108
109 count_vm_vmacache_event(VMACACHE_FIND_CALLS);
110
105 for (i = 0; i < VMACACHE_SIZE; i++) { 111 for (i = 0; i < VMACACHE_SIZE; i++) {
106 struct vm_area_struct *vma = current->vmacache[i]; 112 struct vm_area_struct *vma = current->vmacache[i];
107 113
108 if (vma && vma->vm_start == start && vma->vm_end == end) 114 if (vma && vma->vm_start == start && vma->vm_end == end) {
115 count_vm_vmacache_event(VMACACHE_FIND_HITS);
109 return vma; 116 return vma;
117 }
110 } 118 }
111 119
112 return NULL; 120 return NULL;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 302dd076b8bf..82ce17ce58c4 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -866,6 +866,10 @@ const char * const vmstat_text[] = {
866 "nr_tlb_local_flush_one", 866 "nr_tlb_local_flush_one",
867#endif /* CONFIG_DEBUG_TLBFLUSH */ 867#endif /* CONFIG_DEBUG_TLBFLUSH */
868 868
869#ifdef CONFIG_DEBUG_VM_VMACACHE
870 "vmacache_find_calls",
871 "vmacache_find_hits",
872#endif
869#endif /* CONFIG_VM_EVENTS_COUNTERS */ 873#endif /* CONFIG_VM_EVENTS_COUNTERS */
870}; 874};
871#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */ 875#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */