linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Christopher Lameter <cl@linux.com>
Cc: linux-mm@kvack.org, Matthew Wilcox <mawilcox@microsoft.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Jeff Layton <jlayton@redhat.com>,
	Mel Gorman <mgorman@techsingularity.net>
Subject: Re: [PATCH v2 2/2] slab: __GFP_ZERO is incompatible with a constructor
Date: Wed, 11 Apr 2018 16:56:52 -0700	[thread overview]
Message-ID: <20180411235652.GA28279@bombadil.infradead.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1804111601090.7458@nuc-kabylake>

On Wed, Apr 11, 2018 at 04:11:17PM -0500, Christopher Lameter wrote:
> On Wed, 11 Apr 2018, Matthew Wilcox wrote:
> > > Please put this in a code path that is enabled by specifying
> > >
> > > slub_debug
> > >
> > > on the kernel command line.
> >
> > I don't understand.  First, I had:
> >
> > 	if (unlikely(gfpflags & __GFP_ZERO) && object && !WARN_ON_ONCE(s->ctor))
> >
> > and you didn't like that because it was putting checking into a (semi)fast
> > path.  Now you want me to add a check for slub_debug somewhere?  I dont
> > see an existing one I can leverage that will hit on every allocation.
> > Perhaps I'm missing something.
> 
> The WARN_ON is only enabled when you configure and build the kernel with
> debugging enabled (CONFIG_VM_DEBUG). That is a compile time debugging
> feature like supported by SLAB.

Yes.  I want to have an option to check *every single* allocation.

> "slub_debug" enables kmem_cache->flags & SLAB_DEBUG and that forces all
> fastpath processing to be disabled. Thus you can check reliably in the
> slow path only for the GFP_ZERO problem.
> 
> Add the check to the other debug stuff already there. F.e. in
> alloc_debug_processing() or after
> 
> if (kmem_cache_debug(s) ...
> 
> in ____slab_alloc()

I don't see how that works ... can you explain a little more?

I see ___slab_alloc() is called from __slab_alloc().  And I see
slab_alloc_node does this:

        object = c->freelist;
        page = c->page;
        if (unlikely(!object || !node_match(page, node))) {
                object = __slab_alloc(s, gfpflags, node, addr, c);
                stat(s, ALLOC_SLOWPATH);

But I don't see how slub_debug leads to c->freelist always being NULL.
It looks like it gets repopulated from page->freelist in ___slab_alloc()
at the load_freelist label.

  reply	other threads:[~2018-04-11 23:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-11  6:03 [PATCH v2 0/2] Fix __GFP_ZERO vs constructor Matthew Wilcox
2018-04-11  6:03 ` [PATCH v2 1/2] Fix NULL pointer in page_cache_tree_insert Matthew Wilcox
2018-04-11  6:03 ` [PATCH v2 2/2] slab: __GFP_ZERO is incompatible with a constructor Matthew Wilcox
2018-04-11  6:35   ` Michal Hocko
2018-04-11 13:44   ` Christopher Lameter
2018-04-11 19:24     ` Matthew Wilcox
2018-04-11 21:11       ` Christopher Lameter
2018-04-11 23:56         ` Matthew Wilcox [this message]
2018-04-12 14:10           ` Christopher Lameter
2018-04-12 14:27             ` Matthew Wilcox
2018-04-12 15:15               ` Christopher Lameter
2018-04-12 19:13               ` [PATCH v3 " Matthew Wilcox
2018-04-16 15:10                 ` Christopher Lameter
2018-08-03 21:22                 ` Guenter Roeck
2018-08-03 22:33                   ` Matthew Wilcox
2018-08-04  9:28                     ` Geert Uytterhoeven
2018-08-04 14:00                       ` Guenter Roeck
2018-04-12  0:54 ` [PATCH v2 0/2] Fix __GFP_ZERO vs constructor Minchan Kim
2018-04-12 19:24   ` Matthew Wilcox
2018-04-13 12:44     ` Michal Hocko

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=20180411235652.GA28279@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jack@suse.cz \
    --cc=jlayton@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mawilcox@microsoft.com \
    --cc=mgorman@techsingularity.net \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /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).