Received: by 10.192.165.156 with SMTP id m28csp752805imm; Wed, 11 Apr 2018 06:48:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+I9HZONxChwv/Gc1G0gjwPHj7hWthcmHMm5cahVT0VxmV6Vrd2seBYq/s10uKQzRy3ZEnJ X-Received: by 2002:a17:902:6807:: with SMTP id h7-v6mr5213726plk.90.1523454492593; Wed, 11 Apr 2018 06:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523454492; cv=none; d=google.com; s=arc-20160816; b=Wkhet3mCarpXjfOcPu4ZSE4Yn7R+S2DYW/VezwGqnGpMHncQ04JXUL33knTEsin8xg zssAfOq+FDyLvSHphXVmjEfS4vyFfH1HtQpKxRJgxbmgNLh2BcTZrBhe3UqYfDTAta7j Fy4NzAeqwIaYFGTxPDcAFB/GFDT42xOOaxO4b/1g4IqTSmUxedUPwn2t7x6GKDDzzVJB xER06BU4CPyHks1cYbcZXRShh6dLZ056KvOuEx/AsKUyGdwNg56bCHZZzSY0gVbAxJbP G+Xj31cBEKsQ8hca1uSJGVHu2y81HSzDhzDIcM2+NPZ8kEveUBTN7BFwso1NiAm38Uqp L4GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=cNOlEL/9oKBU2k43w5YvSnoJrfsJ7uLmSiWlerAXv14=; b=WCyxy8euBYw5mcc9siJGBUY/pwZn+TlTCs/0nOrrWHT7FFfgRdzmVYLmT/PM4kog2y G2jZ4FY94C4CwldQaJbv54kLP9G+Moosg98ur4lOxDUykV1SEFO7ADXVYIdUAJz1C92T QpugBJ4iucODuJPKRWrVrImE1c/hXwKIGTcU6Ww3DH69NXEcAHAvULW5L3ra81WyleYK iKaOZv7Dgr21a9ZCF5McOIcOA4TFaFqVw3/v/EvjFM8E5L75cbvU0DSnUzdNTRSjFEQr 2UEKTiha8jek8JpmZaAIFceEvkXEIoJiR2BRF4mDx69l2TiZr6W38dQoykSmLwyfIgUR M1qA== 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 v196si774265pgb.672.2018.04.11.06.47.35; Wed, 11 Apr 2018 06:48:12 -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 S1752906AbeDKNo1 (ORCPT + 99 others); Wed, 11 Apr 2018 09:44:27 -0400 Received: from resqmta-ch2-11v.sys.comcast.net ([69.252.207.43]:50904 "EHLO resqmta-ch2-11v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbeDKNo0 (ORCPT ); Wed, 11 Apr 2018 09:44:26 -0400 Received: from resomta-ch2-04v.sys.comcast.net ([69.252.207.100]) by resqmta-ch2-11v.sys.comcast.net with ESMTP id 6G30fliKOmUWH6G30f18VU; Wed, 11 Apr 2018 13:44:26 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-04v.sys.comcast.net with SMTP id 6G2yf4ofdibDC6G2yfkl4H; Wed, 11 Apr 2018 13:44:25 +0000 Received: by gentwo.org (Postfix, from userid 1001) id EE27E1160D58; Wed, 11 Apr 2018 08:44:23 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id EBB111160479; Wed, 11 Apr 2018 08:44:23 -0500 (CDT) Date: Wed, 11 Apr 2018 08:44:23 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Matthew Wilcox cc: linux-mm@kvack.org, Matthew Wilcox , 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 In-Reply-To: <20180411060320.14458-3-willy@infradead.org> Message-ID: References: <20180411060320.14458-1-willy@infradead.org> <20180411060320.14458-3-willy@infradead.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CMAE-Envelope: MS4wfPNKBrFjObshxqS//aSWnjYTjapkjqXPjJHi11+j75mF500KvhT9Dh7rWI7VMzRDuSrdaN0s+qDBlzuzEPEnh1gFWag2tzuBvsUbJ4bcPx0I2PSHcK2V 58RhoCNt/FJjErAAcX3AK815v6IH8Pfu5dU80elx8VtyRGjHsRBKezBSK1LjcmcPhQiGMvA3az2tERY9pTa7TR9Caxm2PC/+UKb+v3P7d7nvWcN47tCaIaKu oUJB2HP80+MGD6ANccv6pThH2PwaSCYX5xJLmxgxLIZCI0NxQP5imtv+m3Sa6Y89ibP8LtuSAD4zHt5qs9kKRoHm4PQZeJ62eP0VDsGAvvkzAvqSMr4sHGyz jOOFOtDYn0iaMd24PvWFMl2T7jhaayNOfNRWbmK3PB5tvxPhhqPEjajqHs7NgH0dH5NzYALHTPNAuy6BcA6uNZfKhRXX6nH0W682wUF+GZCsXLY6uD7wk2eh 77Skf0aQFQVWF1s8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Apr 2018, Matthew Wilcox wrote: > diff --git a/mm/slab.h b/mm/slab.h > index 3cd4677953c6..896818c7b30a 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -515,6 +515,13 @@ static inline void dump_unreclaimable_slab(void) > > void ___cache_free(struct kmem_cache *cache, void *x, unsigned long addr); > > +static inline bool slab_no_ctor(struct kmem_cache *s) > +{ > + if (IS_ENABLED(CONFIG_DEBUG_VM)) > + return !WARN_ON_ONCE(s->ctor); > + return true; > +} > + > #ifdef CONFIG_SLAB_FREELIST_RANDOM > int cache_random_seq_create(struct kmem_cache *cachep, unsigned int count, > gfp_t gfp); Move that to mm/slab.c? Debugging is runtime enabled with SLUB not compile time as with SLAB. > +++ b/mm/slub.c > @@ -2725,7 +2726,7 @@ static __always_inline void *slab_alloc_node(struct kmem_cache *s, > stat(s, ALLOC_FASTPATH); > } > > - if (unlikely(gfpflags & __GFP_ZERO) && object) > + if (unlikely(gfpflags & __GFP_ZERO) && object && slab_no_ctor(s)) > memset(object, 0, s->object_size); > > slab_post_alloc_hook(s, gfpflags, 1, &object); Please put this in a code path that is enabled by specifying slub_debug on the kernel command line.