On Fri, Jul 01, 2022 at 06:29:20PM +0900, Hyeonggon Yoo wrote: > On Fri, Jul 01, 2022 at 10:23:30AM +0800, Feng Tang wrote: [snip] > > > > > And then it has overhead of 'waste' field for every non-kmalloc objects > > > because track is saved per object. Also the field is not used at free. > > > (Maybe that would be okay as it's only for debugging, just noting.) > > > > Yes, the field itself is a 'waste' for non-kmalloc objects :) I do > > have another patch to add an option for this > > > > +config SLUB_DEBUG_KMALLOC_WASTE > > + bool "Enable kmalloc memory waste debug" > > + depends on SLUB_DEBUG && DEBUG_FS > > ... > > > > And didn't post it due to the same debugging thought as you. And I can > > add it back if it's really necessary. > > Let's see how others think :) > I'm okay with current patch. Okay. > > > > mm/slub.c | 45 ++++++++++++++++++++++++++++++--------------- > > > > 1 file changed, 30 insertions(+), 15 deletions(-) [snip] > > > > > > > > l->min_pid = track->pid; > > > > l->max_pid = track->pid; > > > > l->handle = handle; > > > > + l->waste = track->waste; > > > > > > I think this may be fooled when there are different wastes values > > > from same caller (i.e. when a kmalloc_track_caller() is used.) > > > > Yes, with the patch, we found quite some cases that the same caller > > requests different sizes. > > > > > because the array is sorted by caller address, but not sorted by waste. > > > > In the patch we have in add_location(): > > > > + if ((track->addr == caddr) && (handle == chandle) && > > + (track->waste == l->waste)) { > > > > Do you mean the following is missed? > > > > --- a/mm/slub.c > > +++ b/mm/slub.c > > @@ -5176,6 +5176,8 @@ static int add_location(struct loc_track *t, struct kmem_cache *s, > > end = pos; > > else if (track->addr == caddr && handle < chandle) > > end = pos; > > + else if (track->addr == caddr && handle == chandle && track->waste < l->waste) > > + end = pos; > > else > > start = pos; > > > > Yes. Exactly. :) Great, will add it in the next version. Thanks for cathing the errors! - Feng > Thanks, > Hyeonggon