forked from mirrors/linux
		
	mm: introduce per-VMA lock statistics
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>
This commit is contained in:
		
							parent
							
								
									444eeb1743
								
							
						
					
					
						commit
						52f238653e
					
				
					 5 changed files with 26 additions and 0 deletions
				
			
		| 
						 | 
					@ -149,6 +149,12 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
 | 
				
			||||||
#ifdef CONFIG_X86
 | 
					#ifdef CONFIG_X86
 | 
				
			||||||
		DIRECT_MAP_LEVEL2_SPLIT,
 | 
							DIRECT_MAP_LEVEL2_SPLIT,
 | 
				
			||||||
		DIRECT_MAP_LEVEL3_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
 | 
					#endif
 | 
				
			||||||
		NR_VM_EVENT_ITEMS
 | 
							NR_VM_EVENT_ITEMS
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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)
 | 
					#define count_vm_tlb_events(x, y) do { (void)(y); } while (0)
 | 
				
			||||||
#endif
 | 
					#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) \
 | 
					#define __count_zid_vm_events(item, zid, delta) \
 | 
				
			||||||
	__count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)
 | 
						__count_vm_events(item##_NORMAL - ZONE_NORMAL + zid, delta)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -279,3 +279,9 @@ config DEBUG_KMEMLEAK_AUTO_SCAN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  If unsure, say Y.
 | 
						  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.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5284,6 +5284,7 @@ struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm,
 | 
				
			||||||
	/* Check if the VMA got isolated after we found it */
 | 
						/* Check if the VMA got isolated after we found it */
 | 
				
			||||||
	if (vma->detached) {
 | 
						if (vma->detached) {
 | 
				
			||||||
		vma_end_read(vma);
 | 
							vma_end_read(vma);
 | 
				
			||||||
 | 
							count_vm_vma_lock_event(VMA_LOCK_MISS);
 | 
				
			||||||
		/* The area was replaced with another one */
 | 
							/* The area was replaced with another one */
 | 
				
			||||||
		goto retry;
 | 
							goto retry;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -5292,6 +5293,7 @@ struct vm_area_struct *lock_vma_under_rcu(struct mm_struct *mm,
 | 
				
			||||||
	return vma;
 | 
						return vma;
 | 
				
			||||||
inval:
 | 
					inval:
 | 
				
			||||||
	rcu_read_unlock();
 | 
						rcu_read_unlock();
 | 
				
			||||||
 | 
						count_vm_vma_lock_event(VMA_LOCK_ABORT);
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif /* CONFIG_PER_VMA_LOCK */
 | 
					#endif /* CONFIG_PER_VMA_LOCK */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1399,6 +1399,12 @@ const char * const vmstat_text[] = {
 | 
				
			||||||
	"direct_map_level2_splits",
 | 
						"direct_map_level2_splits",
 | 
				
			||||||
	"direct_map_level3_splits",
 | 
						"direct_map_level3_splits",
 | 
				
			||||||
#endif
 | 
					#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_VM_EVENT_COUNTERS || CONFIG_MEMCG */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
 | 
					#endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA || CONFIG_MEMCG */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue