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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22778C4167D for ; Tue, 7 Nov 2023 10:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233818AbjKGKRj (ORCPT ); Tue, 7 Nov 2023 05:17:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232303AbjKGKRi (ORCPT ); Tue, 7 Nov 2023 05:17:38 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D28DB7 for ; Tue, 7 Nov 2023 02:17:35 -0800 (PST) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SPkZD3HvzzPnlj; Tue, 7 Nov 2023 18:13:24 +0800 (CST) Received: from [10.174.176.88] (10.174.176.88) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 7 Nov 2023 18:17:02 +0800 Message-ID: <029f5c1c-6251-4112-8ce0-ef3d46596089@huawei.com> Date: Tue, 7 Nov 2023 18:17:02 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH -next,V2] cachefiles: support to disable assert macro To: CC: , , , References: <20231101163431.2108688-1-wozizhi@huawei.com> From: Zizhi Wo In-Reply-To: <20231101163431.2108688-1-wozizhi@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.88] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500020.china.huawei.com (7.185.36.49) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org friendly ping 在 2023/11/2 0:34, WoZ1zh1 写道: > In fs/cachefiles/internal.h, ASSERT macro is enabled by default and can > not be disabled, then assert failure will crash the kernel as the BUG() > is included in the ASSERT macro. Therefore, add CACHEFILES_ASSERT to > control it. > > Signed-off-by: WoZ1zh1 > --- > fs/cachefiles/Kconfig | 11 +++++++++++ > fs/cachefiles/internal.h | 2 +- > 2 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/fs/cachefiles/Kconfig b/fs/cachefiles/Kconfig > index 8df715640a48..83d8ec3ba2d8 100644 > --- a/fs/cachefiles/Kconfig > +++ b/fs/cachefiles/Kconfig > @@ -38,3 +38,14 @@ config CACHEFILES_ONDEMAND > and is delegated to userspace. > > If unsure, say N. > + > +config CACHEFILES_ASSERT > + bool "CACHEFILES asserts" > + default n > + depends on CACHEFILES > + help > + Support the ASSERT mode for failure behavior. > + Say N here to disable the ASSERT by default. > + Say Y to add assertion checks in some places. But the assertion > + failure will result in fatal errors that BUG() the kernel. > + > diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h > index 2ad58c465208..263b1f13e943 100644 > --- a/fs/cachefiles/internal.h > +++ b/fs/cachefiles/internal.h > @@ -425,7 +425,7 @@ do { \ > #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__) > #endif > > -#if 1 /* defined(__KDEBUGALL) */ > +#ifdef CONFIG_CACHEFILES_ASSERT > > #define ASSERT(X) \ > do { \