mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	debugobjects: Export max loops counter
__debug_check_no_obj_freed() can be an expensive operation depending on the size of memory freed. It already exports the maximum chain walk length via debugfs, but this only records the maximum of a single memory chunk. Though there is no information about the total number of objects inspected for a __debug_check_no_obj_freed() operation, which might be significantly larger when a huge memory region is freed. Aggregate the number of objects inspected for a single invocation of __debug_check_no_obj_freed() and export it via sysfs. The resulting output of /sys/kernel/debug/debug_objects/stats looks like: max_chain :121 max_checked :543267 warnings :0 fixups :0 pool_free :1764 pool_min_free :341 pool_used :86438 pool_max_used :268887 objs_allocated:6068254 objs_freed :5981076 [ tglx: Renamed the variable to max_checked and adjusted changelog ] Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: longman@redhat.com Link: https://lkml.kernel.org/r/1517872708-24207-2-git-send-email-yang.shi@linux.alibaba.com
This commit is contained in:
		
							parent
							
								
									7928b2cbe5
								
							
						
					
					
						commit
						bd9dcd0465
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
					@ -50,6 +50,7 @@ static int			obj_pool_max_used;
 | 
				
			||||||
static struct kmem_cache	*obj_cache;
 | 
					static struct kmem_cache	*obj_cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int			debug_objects_maxchain __read_mostly;
 | 
					static int			debug_objects_maxchain __read_mostly;
 | 
				
			||||||
 | 
					static int			debug_objects_maxchecked __read_mostly;
 | 
				
			||||||
static int			debug_objects_fixups __read_mostly;
 | 
					static int			debug_objects_fixups __read_mostly;
 | 
				
			||||||
static int			debug_objects_warnings __read_mostly;
 | 
					static int			debug_objects_warnings __read_mostly;
 | 
				
			||||||
static int			debug_objects_enabled __read_mostly
 | 
					static int			debug_objects_enabled __read_mostly
 | 
				
			||||||
| 
						 | 
					@ -720,7 +721,7 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size)
 | 
				
			||||||
	enum debug_obj_state state;
 | 
						enum debug_obj_state state;
 | 
				
			||||||
	struct debug_bucket *db;
 | 
						struct debug_bucket *db;
 | 
				
			||||||
	struct debug_obj *obj;
 | 
						struct debug_obj *obj;
 | 
				
			||||||
	int cnt;
 | 
						int cnt, objs_checked = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	saddr = (unsigned long) address;
 | 
						saddr = (unsigned long) address;
 | 
				
			||||||
	eaddr = saddr + size;
 | 
						eaddr = saddr + size;
 | 
				
			||||||
| 
						 | 
					@ -765,7 +766,12 @@ static void __debug_check_no_obj_freed(const void *address, unsigned long size)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (cnt > debug_objects_maxchain)
 | 
							if (cnt > debug_objects_maxchain)
 | 
				
			||||||
			debug_objects_maxchain = cnt;
 | 
								debug_objects_maxchain = cnt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							objs_checked += cnt;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (objs_checked > debug_objects_maxchecked)
 | 
				
			||||||
 | 
							debug_objects_maxchecked = objs_checked;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void debug_check_no_obj_freed(const void *address, unsigned long size)
 | 
					void debug_check_no_obj_freed(const void *address, unsigned long size)
 | 
				
			||||||
| 
						 | 
					@ -780,6 +786,7 @@ void debug_check_no_obj_freed(const void *address, unsigned long size)
 | 
				
			||||||
static int debug_stats_show(struct seq_file *m, void *v)
 | 
					static int debug_stats_show(struct seq_file *m, void *v)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	seq_printf(m, "max_chain     :%d\n", debug_objects_maxchain);
 | 
						seq_printf(m, "max_chain     :%d\n", debug_objects_maxchain);
 | 
				
			||||||
 | 
						seq_printf(m, "max_checked   :%d\n", debug_objects_maxchecked);
 | 
				
			||||||
	seq_printf(m, "warnings      :%d\n", debug_objects_warnings);
 | 
						seq_printf(m, "warnings      :%d\n", debug_objects_warnings);
 | 
				
			||||||
	seq_printf(m, "fixups        :%d\n", debug_objects_fixups);
 | 
						seq_printf(m, "fixups        :%d\n", debug_objects_fixups);
 | 
				
			||||||
	seq_printf(m, "pool_free     :%d\n", obj_pool_free);
 | 
						seq_printf(m, "pool_free     :%d\n", obj_pool_free);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue