From patchwork Fri Jul 2 08:53:31 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: 12355655 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,URIBL_BLOCKED,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 BDCEAC11F68 for ; Fri, 2 Jul 2021 08:54:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5F9D96141E for ; Fri, 2 Jul 2021 08:54:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F9D96141E 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 B7E536B0011; Fri, 2 Jul 2021 04:54:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2D946B0036; Fri, 2 Jul 2021 04:54:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CEFC6B005D; Fri, 2 Jul 2021 04:54:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0103.hostedemail.com [216.40.44.103]) by kanga.kvack.org (Postfix) with ESMTP id 7AD0E6B0011 for ; Fri, 2 Jul 2021 04:54:21 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2A31980E4C98 for ; Fri, 2 Jul 2021 08:54:21 +0000 (UTC) X-FDA: 78317036322.08.9C694EF Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf13.hostedemail.com (Postfix) with ESMTP id 9F453100017B for ; Fri, 2 Jul 2021 08:54:16 +0000 (UTC) X-UUID: b78da6c95bca463eb6cd1a1e5fd5f212-20210702 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:Message-ID:Date:Subject:CC:To:From; bh=c4UgKqcAv83mx7vfnDYDkN7HdQr8nRTSVbN5uJSg+MA=; b=kHLNcEMU/7m05VjiCP0+reuWw1IpybGBAdZwWJ7SNn1jIWwyL6NRwIl+cWa5rC0o/aKZDeqAglAzaTOGKF551tVEXGJ+gjJRk57VQYOSgs9Y/Gb+ZEscKvS11uqtv/PysRNrXY3PMndmAc7Mj52yqm54bydILM8BEVA/kCu+A88=; X-UUID: b78da6c95bca463eb6cd1a1e5fd5f212-20210702 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 240433748; Fri, 02 Jul 2021 01:54:00 -0700 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 01:53:59 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 16:53:57 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 2 Jul 2021 16:53:57 +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" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" Subject: [PATCH v4 1/2] mm: introduce helper to check slub_debug_enabled Date: Fri, 2 Jul 2021 16:53:31 +0800 Message-ID: <20210702085332.10035-1-yee.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=kHLNcEMU; dmarc=pass (policy=none) header.from=mediatek.com; spf=pass (imf13.hostedemail.com: domain of yee.lee@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=yee.lee@mediatek.com X-Stat-Signature: 33wmqjaqnh6j8p1xk5geja5h1pu1obs3 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9F453100017B X-HE-Tag: 1625216056-154322 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 Introduce a helper to check slub_debug_enabled, so that we can confine the use of #ifdef to the definition of the slub_debug_enabled_unlikely() helper. --- Signed-off-by: Marco Elver Signed-off-by: Yee Lee --- mm/slab.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mm/slab.h b/mm/slab.h index 7b60ef2f32c3..a11126afe24c 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_unlikely(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_unlikely(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_unlikely()) return s->flags & flags; -#endif return false; }