From patchwork Mon Jul 5 10:32:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WWVlIExlZSAo5p2O5bu66Kq8KQ==?= X-Patchwork-Id: 12358779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B97A5C07E9B for ; Mon, 5 Jul 2021 10:33:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 458D5613F3 for ; Mon, 5 Jul 2021 10:33:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 458D5613F3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EA8D46B0011; Mon, 5 Jul 2021 06:33:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E316A6B0036; Mon, 5 Jul 2021 06:33:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD2466B005D; Mon, 5 Jul 2021 06:33:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id A2C256B0011 for ; Mon, 5 Jul 2021 06:33:34 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1A8AD1801668F for ; Mon, 5 Jul 2021 10:33:34 +0000 (UTC) X-FDA: 78328172748.15.6DF3858 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf27.hostedemail.com (Postfix) with ESMTP id 805207000091 for ; Mon, 5 Jul 2021 10:33:32 +0000 (UTC) X-UUID: 0f23347964fc4840a0c5f7fb6ba7c001-20210705 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=natBv6bjlendt8Mb35/LbpmkSFKSCys35LqsTZpd4qo=; b=C5+o24QuLb6yeJXjvM4sNcd4sF2ZXKYOTbxkJU70ixBtQYY9Wh+SNLmgXw0taxizRkh4TGOQFM6qK7YfBxp/c08t39mZIPtD+fujwOCsPX4kxoP+Syv4RIBjm0KD3VbN8iVilBFJl96Ftp/lBZOXyxLH1W3+pn6LmPNqwjzMpXA=; X-UUID: 0f23347964fc4840a0c5f7fb6ba7c001-20210705 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 693258614; Mon, 05 Jul 2021 03:33:28 -0700 Received: from MTKMBS02N1.mediatek.inc (172.21.101.77) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Jul 2021 03:33:27 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Jul 2021 18:33:25 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 5 Jul 2021 18:33:25 +0800 From: To: CC: , , , Marco Elver , Yee Lee , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Matthias Brugger , "open list:SLAB ALLOCATOR" , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: [PATCH v6 1/2] mm: move helper to check slub_debug_enabled Date: Mon, 5 Jul 2021 18:32:26 +0800 Message-ID: <20210705103229.8505-2-yee.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210705103229.8505-1-yee.lee@mediatek.com> References: <20210705103229.8505-1-yee.lee@mediatek.com> MIME-Version: 1.0 X-MTK: N Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=C5+o24Qu; spf=pass (imf27.hostedemail.com: domain of yee.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=yee.lee@mediatek.com; dmarc=pass (policy=none) header.from=mediatek.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 805207000091 X-Stat-Signature: 4ixbfjhjorr74936pkxoe3886ndc8kxf X-HE-Tag: 1625481212-598134 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Marco Elver Move the helper to check slub_debug_enabled, so that we can confine the use of #ifdef outside slub.c as well. Suggested-by: Matthew Wilcox Signed-off-by: Marco Elver Signed-off-by: Yee Lee --- mm/slab.h | 15 +++++++++++---- mm/slub.c | 14 -------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 7b60ef2f32c3..67d3272f3368 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -216,10 +216,18 @@ DECLARE_STATIC_KEY_FALSE(slub_debug_enabled); #endif extern void print_tracking(struct kmem_cache *s, void *object); long validate_slab_cache(struct kmem_cache *s); +static inline bool __slub_debug_enabled(void) +{ + return static_branch_unlikely(&slub_debug_enabled); +} #else static inline void print_tracking(struct kmem_cache *s, void *object) { } +static inline bool __slub_debug_enabled(void) +{ + return false; +} #endif /* @@ -229,11 +237,10 @@ static inline void print_tracking(struct kmem_cache *s, void *object) */ static inline bool kmem_cache_debug_flags(struct kmem_cache *s, slab_flags_t flags) { -#ifdef CONFIG_SLUB_DEBUG - VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS)); - if (static_branch_unlikely(&slub_debug_enabled)) + if (IS_ENABLED(CONFIG_SLUB_DEBUG)) + VM_WARN_ON_ONCE(!(flags & SLAB_DEBUG_FLAGS)); + if (__slub_debug_enabled()) return s->flags & flags; -#endif return false; } diff --git a/mm/slub.c b/mm/slub.c index 3bc8b940c933..71515c484d1c 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -119,25 +119,11 @@ */ #ifdef CONFIG_SLUB_DEBUG - #ifdef CONFIG_SLUB_DEBUG_ON DEFINE_STATIC_KEY_TRUE(slub_debug_enabled); #else DEFINE_STATIC_KEY_FALSE(slub_debug_enabled); #endif - -static inline bool __slub_debug_enabled(void) -{ - return static_branch_unlikely(&slub_debug_enabled); -} - -#else /* CONFIG_SLUB_DEBUG */ - -static inline bool __slub_debug_enabled(void) -{ - return false; -} - #endif /* CONFIG_SLUB_DEBUG */ static inline bool kmem_cache_debug(struct kmem_cache *s)