From: Feng Tang <feng.tang@intel.com>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Vlastimil Babka <vbabka@suse.cz>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
dave.hansen@intel.com
Subject: Re: [RFC PATCH] mm/slub: enable debugging memory wasting of kmalloc
Date: Fri, 1 Jul 2022 19:13:22 +0800 [thread overview]
Message-ID: <20220701111322.GC14806@shbuild999.sh.intel.com> (raw)
In-Reply-To: <Yr6+cHOmVnvcfFEa@hyeyoo>
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
prev parent reply other threads:[~2022-07-01 11:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-30 1:47 Feng Tang
2022-06-30 2:30 ` Andrew Morton
2022-06-30 2:38 ` Feng Tang
2022-06-30 2:47 ` Andrew Morton
2022-06-30 3:23 ` Feng Tang
2022-06-30 8:52 ` Robin Murphy
2022-06-30 14:38 ` Hyeonggon Yoo
2022-06-30 14:55 ` Hyeonggon Yoo
2022-07-01 2:23 ` Feng Tang
2022-07-01 9:29 ` Hyeonggon Yoo
2022-07-01 11:13 ` Feng Tang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220701111322.GC14806@shbuild999.sh.intel.com \
--to=feng.tang@intel.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dave.hansen@intel.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox