From mboxrd@z Thu Jan 1 00:00:00 1970 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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 52155C4338F for ; Wed, 25 Aug 2021 09:20:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C161610CD for ; Wed, 25 Aug 2021 09:20:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1C161610CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C3ULQYMMIl5ILm3YM+PKh7aRyZMyp8GYIBVKGFx3Zjo=; b=UtWnKwHiRslgUb 5n+cajb219HMwplV3hDBNGxBuCKERgOckMYdJcBlmRBYgiJrTzyo7dDqO2r/KTOpvCpDqRue/hC6C wsj7na0tYsu2cmP3tjsjWH+pHIDUnyWWvNudbQJ5tKrr7xNPthBGTRLBgLShPs5MOkZlCPJbyv9F/ /7yISUuJE8sy8zRsySg65rA8d7bYCNCHBOWonlRFJkD2iJ0s0ZDX9QGrFyabx80DihtJhvK2qknG+ ffkf5Ncg2JDHXFp9iDHkieridXFZ5wasIDOQAPYN9c1yqM33SfISbthHaSCTpRFh5o+QM9CHw5qgY nMQAWvIB1uMIiPDpWWog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIp2o-0065yY-EH; Wed, 25 Aug 2021 09:18:02 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIp2C-0065eR-8J for linux-arm-kernel@lists.infradead.org; Wed, 25 Aug 2021 09:17:26 +0000 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GvgJD5blFzbhGf; Wed, 25 Aug 2021 17:13:32 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 25 Aug 2021 17:17:22 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 25 Aug 2021 17:17:22 +0800 From: Kefeng Wang To: Russell King , Alexander Potapenko , Marco Elver , Dmitry Vyukov , , , CC: Andrew Morton , Kefeng Wang Subject: [PATCH 4/4] mm: kfence: Only load kfence_test when kfence is enabled Date: Wed, 25 Aug 2021 17:21:16 +0800 Message-ID: <20210825092116.149975-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210825092116.149975-1-wangkefeng.wang@huawei.com> References: <20210825092116.149975-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210825_021724_490621_9DD1866D X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Provide kfence_is_enabled() helper, only load kfence_test module when kfence is enabled. Signed-off-by: Kefeng Wang --- include/linux/kfence.h | 2 ++ mm/kfence/core.c | 8 ++++++++ mm/kfence/kfence_test.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/include/linux/kfence.h b/include/linux/kfence.h index 3fe6dd8a18c1..f08f24e8a726 100644 --- a/include/linux/kfence.h +++ b/include/linux/kfence.h @@ -22,6 +22,8 @@ #define KFENCE_POOL_SIZE ((CONFIG_KFENCE_NUM_OBJECTS + 1) * 2 * PAGE_SIZE) extern char *__kfence_pool; +bool kfence_is_enabled(void); + #ifdef CONFIG_KFENCE_STATIC_KEYS #include DECLARE_STATIC_KEY_FALSE(kfence_allocation_key); diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 7a97db8bc8e7..f1aaa7ebdcad 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -51,6 +51,14 @@ static unsigned long kfence_sample_interval __read_mostly = CONFIG_KFENCE_SAMPLE #endif #define MODULE_PARAM_PREFIX "kfence." +bool kfence_is_enabled(void) +{ + if (!kfence_sample_interval || !READ_ONCE(kfence_enabled)) + return false; + return true; +} +EXPORT_SYMBOL_GPL(kfence_is_enabled); + static int param_set_sample_interval(const char *val, const struct kernel_param *kp) { unsigned long num; diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index eb6307c199ea..4087f9f1497e 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -847,6 +847,8 @@ static void unregister_tracepoints(struct tracepoint *tp, void *ignore) */ static int __init kfence_test_init(void) { + if (!kfence_is_enabled()) + return 0; /* * Because we want to be able to build the test as a module, we need to * iterate through all known tracepoints, since the static registration -- 2.26.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel