Received: by 10.192.165.156 with SMTP id m28csp358282imm; Tue, 10 Apr 2018 23:39:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+HFGx/9rTaLbyQqaEQ7JrN7R1zqlqSy3gw8bTjLjLGLGDmZ5p+5zPpZ6z4Ou90nqVHuULF X-Received: by 10.99.176.71 with SMTP id z7mr2452147pgo.74.1523428753663; Tue, 10 Apr 2018 23:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523428753; cv=none; d=google.com; s=arc-20160816; b=R29UGc+0JeJ6SJ+ALPIUW5Rsx0s3aAgfAQl7mCPRpE+BppZPXv7xTfVksQDQApUqOy 7dDDg22jDkIgpMgMYzN9IrGXg6easiPPHfDnHSen9atflxCSsEOc9lgvk5MbyEj/ufwv OF3YZi7Hv37DBdIw3fDcJnyOqc3aaAZlBoktPx4kbPhZMTVdnwSpl8pNVq1vgN5iJo8G guMCSa6UQRhoaTrjCoNMSnOi1NpmUaO0hCCX0dgvhEihvvLg6kuPacCAcJ1MdNFyHXev csePw5j70/+xxD7mGvY52XQypSQVf0YqTeIGJ2j/Fvqhq4Y/4hMlC2fa4f6lxsjX8iCi yhsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=vbSe5FNtGbR9hVn5Lr+hdVbB4uXc5z+Qq0hy92rGdQ4=; b=ofwtYNUYt/XCJBzis1ZfGQNatTHPvlr/AkE4En1omrEstkPKlr0aph6pxR2tudLnPY 2V81OA9LAW8fQ69279ZPLGs7TcGD7b6TumCKINLhBSSNry+c9A61Xima1+lIDaYPKkPZ SaDl1JyWygc7n4CoXJ2kNexsQkJQ8q312YAyOod6p2L1AlekDIUi3ytvifC07yIV0Xuy sOC44pSppNGbdFdiY5bRIzKWM7a89QSCdvyiZRmsQdAPwYQLHEuklepqDKFjOzyP8UNr Jl9sjCAyg3WS5Jb8t68ScNIbPNERSSL4ZUidThVZURongbD5cuMyua7xMgXnaN1qW7NX s+sQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si344653pfn.386.2018.04.10.23.38.35; Tue, 10 Apr 2018 23:39:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752174AbeDKGf6 (ORCPT + 99 others); Wed, 11 Apr 2018 02:35:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:44552 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbeDKGf5 (ORCPT ); Wed, 11 Apr 2018 02:35:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6FC7FAE8B; Wed, 11 Apr 2018 06:35:56 +0000 (UTC) Date: Wed, 11 Apr 2018 08:35:54 +0200 From: Michal Hocko To: Matthew Wilcox Cc: linux-mm@kvack.org, Matthew Wilcox , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , linux-kernel@vger.kernel.org, Jan Kara , Jeff Layton , Mel Gorman Subject: Re: [PATCH v2 2/2] slab: __GFP_ZERO is incompatible with a constructor Message-ID: <20180411063554.GB30893@dhcp22.suse.cz> References: <20180411060320.14458-1-willy@infradead.org> <20180411060320.14458-3-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180411060320.14458-3-willy@infradead.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 10-04-18 23:03:20, Matthew Wilcox wrote: > diff --git a/mm/slab.c b/mm/slab.c > index 58c8cecc26ab..9ad85fd9fca8 100644 > --- a/mm/slab.c > +++ b/mm/slab.c > @@ -2661,6 +2661,7 @@ static struct page *cache_grow_begin(struct kmem_cache *cachep, > invalid_mask, &invalid_mask, flags, &flags); > dump_stack(); > } > + BUG_ON(cachep->ctor && (flags & __GFP_ZERO)); NAK. We really do not want to blow the whole kernel just because somebody is doing something stupid. Make it WARN_ON_ONCE and fix up the flag. > +static inline bool slab_no_ctor(struct kmem_cache *s) > +{ > + if (IS_ENABLED(CONFIG_DEBUG_VM)) > + return !WARN_ON_ONCE(s->ctor); > + return true; > +} I do realize that you want to keep the hotpath without additional checks but if for nothing else this is a really bad misnomer. debug_slab_no_ctor()? I can clearly see how somebody uses this blindly for a different purpose. [...] > diff --git a/mm/slub.c b/mm/slub.c > index a28488643603..9f8f38a552e5 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1576,6 +1576,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) > > if (gfpflags_allow_blocking(flags)) > local_irq_enable(); > + BUG_ON(s->ctor && (flags & __GFP_ZERO)); No no on this as well. Othe than that. Once those are fixed, feel free to add Acked-by: Michal Hocko -- Michal Hocko SUSE Labs