Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1012033yba; Thu, 4 Apr 2019 02:23:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyd27b9gUHmPM0O/7CooK5WZN3pJ0Dfdh41v+3zai9h4gijImd2KQwMUmOG2lJQa8BKm8Ff X-Received: by 2002:a63:c104:: with SMTP id w4mr4751821pgf.409.1554369830636; Thu, 04 Apr 2019 02:23:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369830; cv=none; d=google.com; s=arc-20160816; b=tsH1GnJb03WZHfSYx2n12/oy3dgxpXQ4tS689Bgd3FN4dC0gADdM5VCTvTjOuL2bFh xW019xnKLj0L/OrTIYd2SCon/tjvJvVvAnqKucXOUwe35WwKyxPtRnqzZr/L74NONUJx dKE1SQ+dFWC34vpTFXCaMRikJZFbQjuuDV1InSbc4q936f9gsrHSSH8ToglG/89O3qci 9k60NjmQFeL71gay4vzKRQ890cCzWZzA1+kfo5f+s2h1znirljJ2WUjHlntNV3n9qKzn WH4GA9XkQETOw99pL1D42TbafZMVxtoHZ/ZUudnOwOGiJkJEfL2O+xCWzhJJhQ8xMfGK D80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=klHFaZb/PmM3tzZdGJEsXoGjeT4WytdPJzzCxt2gpy8=; b=ihuQORUpmizdriPoO6YBj2zpGOw50pKSYvsOhlt2E7A3O9YpDuzxVG7F8CrxBlP/30 W3+bqFjlNC2K/jMkqApewQ79WfSr6388n0NH/Itqj9gSqp2PieFSJlDs/uH1sFkkmNEx gNgBwfZvdLrAUUSoS8NBGHTZefuhg+A6Zy8KENQ6bqCcyGsGiBTFUUJ2Y+xztCaXbQke BLDn80tc7QxWAWxz6usvYeSH+2TMGagJkWSk+nWquZI1nXYL5nRPu2jjvpb+qZCEedcC 1rnGLxUFhZvoJnPzw6+gfZwsRaXaR+irUNr/e6Ph5Cn7vHZ7SOf+nKfeTkWWLOKUSWJ4 Fong== 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 t186si15582876pgd.221.2019.04.04.02.23.35; Thu, 04 Apr 2019 02:23:50 -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 S2387733AbfDDJPu (ORCPT + 99 others); Thu, 4 Apr 2019 05:15:50 -0400 Received: from mx2.suse.de ([195.135.220.15]:35644 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387523AbfDDJPo (ORCPT ); Thu, 4 Apr 2019 05:15:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 49E73ACFA; Thu, 4 Apr 2019 09:15:43 +0000 (UTC) From: Vlastimil Babka To: linux-mm@kvack.org Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Mel Gorman , linux-kernel@vger.kernel.org, Vlastimil Babka Subject: [RFC 2/2] mm, slub: add missing kmem_cache_debug() checks Date: Thu, 4 Apr 2019 11:15:31 +0200 Message-Id: <20190404091531.9815-3-vbabka@suse.cz> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404091531.9815-1-vbabka@suse.cz> References: <20190404091531.9815-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some debugging checks in SLUB are not hidden behind kmem_cache_debug() check. Add the check so that those places can also benefit from reduced overhead thanks to the the static key added by the previous patch. Signed-off-by: Vlastimil Babka --- mm/slub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 398e53e16e2e..9d1b0e5e8593 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1086,6 +1086,13 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node, int objects) static void setup_object_debug(struct kmem_cache *s, struct page *page, void *object) { + /* + * __OBJECT_POISON implies SLAB_POISON which is covered by + * kmem_cache_debug() + */ + if (!kmem_cache_debug(s)) + return; + if (!(s->flags & (SLAB_STORE_USER|SLAB_RED_ZONE|__OBJECT_POISON))) return; @@ -1095,6 +1102,9 @@ static void setup_object_debug(struct kmem_cache *s, struct page *page, static void setup_page_debug(struct kmem_cache *s, void *addr, int order) { + if (!kmem_cache_debug(s)) + return; + if (!(s->flags & SLAB_POISON)) return; @@ -1734,7 +1744,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page) int order = compound_order(page); int pages = 1 << order; - if (s->flags & SLAB_CONSISTENCY_CHECKS) { + if (kmem_cache_debug(s) && s->flags & SLAB_CONSISTENCY_CHECKS) { void *p; slab_pad_check(s, page); -- 2.21.0