linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Faiyaz Mohammed <faiyazm@codeaurora.org>,
	cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	glittao@gmail.com, vinmenon@codeaurora.org
Subject: Re: [PATCH v7] mm: slub: move sysfs slab alloc/free interfaces to debugfs
Date: Wed, 26 May 2021 13:48:08 +0200	[thread overview]
Message-ID: <YK41eFeL5j4qqSnV@kroah.com> (raw)
In-Reply-To: <86d843f0-bbef-7c3b-6b6a-5d6b32434bee@suse.cz>

On Wed, May 26, 2021 at 01:38:55PM +0200, Vlastimil Babka wrote:
> On 5/25/21 9:38 AM, Faiyaz Mohammed wrote:
> > alloc_calls and free_calls implementation in sysfs have two issues,
> > one is PAGE_SIZE limitiation of sysfs and other is it does not adhere
> > to "one value per file" rule.
> > 
> > To overcome this issues, move the alloc_calls and free_calls implemeation
> > to debugfs.
> > 
> > Rename the alloc_calls/free_calls to alloc_traces/free_traces,
> > to be inline with what it does.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> These were IIRC bot reports for some bugs in the previous versions, so keeping
> the Reported-by: for the whole patch is misleading - these were not reports for
> the sysfs issues this patch fixes by moving the files to debugfs.
> 
> > Signed-off-by: Faiyaz Mohammed <faiyazm@codeaurora.org>
> > ---
> > changes in V7:
> >         - Drop the older alloc_calls and free_calls interface.
> > changes in v6:
> >         - https://lore.kernel.org/linux-mm/1621341949-26762-1-git-send-email-faiyazm@codeaurora.org/
> > 
> > changes in v5:
> >         - https://lore.kernel.org/linux-mm/1620296523-21922-1-git-send-email-faiyazm@codeaurora.org/
> > 
> > changes in v4:
> >         - https://lore.kernel.org/linux-mm/1618583239-18124-1-git-send-email-faiyazm@codeaurora.org/
> > 
> > changes in v3:
> >         - https://lore.kernel.org/linux-mm/1617712064-12264-1-git-send-email-faiyazm@codeaurora.org/
> > 
> > changes in v2:
> >         - https://lore.kernel.org/linux-mm/3ac1d3e6-6207-96ad-16a1-0f5139d8b2b5@codeaurora.org/
> > 
> > changes in v1:
> >         - https://lore.kernel.org/linux-mm/1610443287-23933-1-git-send-email-faiyazm@codeaurora.org/
> > 
> >  include/linux/slub_def.h |   8 ++
> >  mm/slab_common.c         |   9 ++
> >  mm/slub.c                | 353 ++++++++++++++++++++++++++++++++++-------------
> >  3 files changed, 276 insertions(+), 94 deletions(-)
> 
> I don't see any of the symlinks under /sys/kernel/debug/slab/, so I think the
> aliases handling code is wrong, and I can see at least two reasons why it could be:
> 
> > @@ -4525,6 +4535,8 @@ __kmem_cache_alias(const char *name, unsigned int size, unsigned int align,
> >  			s->refcount--;
> >  			s = NULL;
> >  		}
> > +
> > +		debugfs_slab_alias(s, name);
> 
> Here you might be calling debugfs_slab_alias() with NULL if the
> sysfs_slab_alias() above returned true.
> 
> >  	}
> >  
> >  	return s;
> 
> ...
> 
> > +static int __init slab_debugfs_init(void)
> > +{
> > +	struct kmem_cache *s;
> > +
> > +	slab_debugfs_root = debugfs_create_dir("slab", NULL);
> > +
> > +	slab_state = FULL;
> > +
> > +	list_for_each_entry(s, &slab_caches, list)
> > +		debugfs_slab_add(s);
> > +
> > +	while (alias_list) {
> > +		struct saved_alias *al = alias_list;
> 
> alias_list a single list and both slab_sysfs_init() and slab_debugfs_init()
> flush it. So only the init call that happens to be called first, does actually
> find an unflushed list. I think you
> need to use a separate list for debugfs (simpler) or a shared list with both
> sysfs and debugfs processing (probably more complicated).
> 
> And finally a question, perhaps also for Greg. With sysfs, we hand out the
> lifecycle of struct kmem_cache to sysfs, to ensure we are not reading sysfs
> files of a cache that has been removed.
> 
> But with debugfs, what are the guarantees that things won't blow up when a
> debugfs file is being read while somebody calls kmem_cache_destroy() on the cache?

It's much harder, but usually the default debugfs_file_create() will
handle this for you.  See the debugfs_file_create_unsafe() for the
"other" variant where you know you can tear things down "safely".

That being said, yes there are still issues in this area, be careful
about what tools you expect to be constantly hitting debugfs files.

thanks,

greg k-h

  reply	other threads:[~2021-05-26 11:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  7:38 [PATCH v7] mm: slub: move sysfs slab alloc/free interfaces to debugfs Faiyaz Mohammed
2021-05-25  7:53 ` Greg KH
2021-05-25  8:57   ` Faiyaz Mohammed
2021-05-25 11:54     ` Greg KH
2021-05-26 11:03       ` Vlastimil Babka
2021-05-26 15:06         ` Faiyaz Mohammed
2021-05-26 15:07           ` Vlastimil Babka
2021-05-26 11:38 ` Vlastimil Babka
2021-05-26 11:48   ` Greg KH [this message]
2021-05-26 12:13     ` Vlastimil Babka
2021-05-31  7:11       ` Faiyaz Mohammed
2021-05-31  8:19         ` Vlastimil Babka
2021-05-31  9:50           ` Faiyaz Mohammed
2021-05-31  6:55   ` Faiyaz Mohammed
2021-05-31  9:55     ` Vlastimil Babka
2021-05-31 11:07       ` Faiyaz Mohammed

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=YK41eFeL5j4qqSnV@kroah.com \
    --to=greg@kroah.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=faiyazm@codeaurora.org \
    --cc=glittao@gmail.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=vbabka@suse.cz \
    --cc=vinmenon@codeaurora.org \
    /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;
as well as URLs for NNTP newsgroup(s).