Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp353257rwb; Thu, 22 Sep 2022 19:42:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7+YcHgJUXm4Zc0nCdxyEEG4d8VbSqGQ6+DWY6ME/aiOf0iRnXQKjLwNw76PFFMhPaRUEIg X-Received: by 2002:a17:907:2cd5:b0:77c:b9cb:bdac with SMTP id hg21-20020a1709072cd500b0077cb9cbbdacmr5381644ejc.265.1663900948550; Thu, 22 Sep 2022 19:42:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1663900948; cv=pass; d=google.com; s=arc-20160816; b=SmnaaOPNHMXRdBRkykql2NDUvOh3vqYx9avfaBpcdrVtfZo8GyZnApHLvYM0ePLld9 zZpHZhmNw6HHtDyZsB7ZiJhmX38iunvMg80g0z8UitRqN3R/gp7D29Hl3PjxOO2uNO9S 5b82jTku+EZL2jnYwaDH8VhA+GAyhwtEM7zUDj9d+zYjg954r1tqrno774R9Z72FT9CY 43SmEaWzXN5j2Ifz7wUs9sVf68T+c7qsj97Gb+YlrmRlgTHvCGKbo9gIxFybd/oylYK5 tSqQCPdM20ghzMWy4nRFc0ECMtRLWFcj9ul5bcpG8PEH8LhUss6dtvXNkqswOvC/JdIb XP2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=buFa+WQw/q1/AAhXQgBnAGV7XGvGJ0obkpDaCo/dQzE=; b=Pq0cMVh88nuzIvGeOcEagpnkpwgBDb4lWjry286JcwBf6Ds5moSYG5Yx1XSpC3xzPY UXFT8Se8e0m3HxG8s8uSFB7979P1qfFtvAV5Luf3KE6EmiE1MX+NYxVkDV0a7llQ3+q0 yTqrSMAYhWTd1PdcMEN4Mz23M402fTEzP/dXcZYzjEuLcGeEyXrvy6QmVmZ3PkwZ8TWk QirCdKeupQw9RvPpyppqjKlLq5UfJ2WyWQIsPIosEJBOejSWf4Hxb/pOjV1vOVb4iUgR 94ReUHwEJQwtS3MNPMPQCkIIvoUu5/XsItxFgV2SA1SkYkGlxJOmAir7w58nbcu7IZJe piTg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=GNpVZe1+; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm10-20020a170907948a00b007700c3ad033si6951772ejc.565.2022.09.22.19.42.03; Thu, 22 Sep 2022 19:42:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=GNpVZe1+; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbiIWCGF (ORCPT + 99 others); Thu, 22 Sep 2022 22:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbiIWCGD (ORCPT ); Thu, 22 Sep 2022 22:06:03 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBE128E2C; Thu, 22 Sep 2022 19:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mBjtxg6G1ROgl/bBfr9AMut/Ym5TJ8WslHhKTzUtBWOJB9Rn4M+Q+Rs47qQcU0KVJliNZME/PQum+KL1XAEOlrYBuFtlBXQWIRG6f8NO5Of3YBUwOHMrNTcuN5/gsZeuUhalambHkFKvkcJmiP5xLZZiwJY4gH25CnDzGRzHVTX6W/3tEIyM/oYTvr/wLCkRTzFRWlOnIQUAox1lbTSqkrg1C3HqYDFp9DNxCyUjfoieEnCgkZhiPGBoWYDv7HBkKe//aTU3pMtu7I1nSnkrFCeLluyrY2MHbR4+aV/YeV/OWMgMjx9PvmRGDT9VjkKBy0pb+XYgjmqo7o+yBQFh+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=buFa+WQw/q1/AAhXQgBnAGV7XGvGJ0obkpDaCo/dQzE=; b=ZGQ7sA0x1mxeC79SG8AsukL7biP+Aeo2NTVVckixUZRqPukIoSbV+LVnI75toY8KAzW8EeftEJ5GJnGPwgnypaGZ2DZriOF6qLbWWBKgEpzvNdfKGqZ0Bnb90Y6xStaSiBU3yIKIA8dJmfGfyIB6g/YVGHU3D00TqdcLdGZ+XoGSt2YVVVidlOEidcucDWYc9XzAJRJIhWsecd7nNG3MqMT0ALFoEhNODX3rT1EYqjTWQI2V+x4hrboRva8lfJOIAqp3FNRiKZfLUDRNsn16bjPyC9Uw1nmUJ6zx2c0n0UZ+f3/bEEV0+HOtYZ7TlaF2ICNdbZNyuzZmXz4L0LjW5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=buFa+WQw/q1/AAhXQgBnAGV7XGvGJ0obkpDaCo/dQzE=; b=GNpVZe1+kdSaOc1GCTMZ+Px6lsg13hcNIy/iQ0Ywcld9ftIH8bNldDZx1qV3MaWmCrrFJVKoiVgug4f8M3KUKvICMz0Kb53i4kf+i6XKHNY/MelO4qSgxgLvxGK8YBVdxeg1hhc9wwsijL4cXF48bjLz2XI2Pf5WbC0a4AugfTiTPAAsWvq1l7A8LvminW+cNkOSYVc4yci8VZzF6HwqzBRo3sJynCqeylqfXs2TLowWEkcjODteFvxh82V5KSPt4RAFx2s6kFSCCsGjrQcMBrDSKtoL64rvEpSQBmqb7dCUA6wUvqb6P1tDVy03LVMmuzFm9W27GRrqV0LZ8nKdsA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4140.namprd12.prod.outlook.com (2603:10b6:5:221::13) by PH7PR12MB6612.namprd12.prod.outlook.com (2603:10b6:510:210::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 02:06:00 +0000 Received: from DM6PR12MB4140.namprd12.prod.outlook.com ([fe80::e0c5:bb15:a743:7ddb]) by DM6PR12MB4140.namprd12.prod.outlook.com ([fe80::e0c5:bb15:a743:7ddb%3]) with mapi id 15.20.5654.020; Fri, 23 Sep 2022 02:05:59 +0000 Message-ID: Date: Thu, 22 Sep 2022 19:05:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v1 3/3] checkpatch: warn on usage of VM_BUG_ON() and other BUG variants Content-Language: en-US To: David Hildenbrand , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Linus Torvalds , Andrew Morton , Ingo Molnar , David Laight , Jonathan Corbet , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Baoquan He , Vivek Goyal , Dave Young , Jani Nikula , Michael Ellerman , Nicholas Piggin , Christophe Leroy References: <20220920122302.99195-1-david@redhat.com> <20220920122302.99195-4-david@redhat.com> From: John Hubbard In-Reply-To: <20220920122302.99195-4-david@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BY3PR05CA0024.namprd05.prod.outlook.com (2603:10b6:a03:254::29) To DM6PR12MB4140.namprd12.prod.outlook.com (2603:10b6:5:221::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB4140:EE_|PH7PR12MB6612:EE_ X-MS-Office365-Filtering-Correlation-Id: 271e93ad-9713-47b8-75f2-08da9d082846 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gsXoAKb7vTen1Jf/hlXxUgxLTOYkLbE+2OS3EIo8Dwd0NKUy2xPNHJ7h4JS3Cvngi3YrJ2FKqD1kaXDzB18XWaccEdBlKBpyib5JYUSjLHzY23Ww5MWQUeLeAPFsEJosTNgzdpXpj4rdC/+JOvawtqnnnq4CA8ZrCDPMOiQUVYLqWQmW4pmCDdsS/5S+PBAjk0msNcjlslYLGil9A05iCVm8c+taXRga/tSLFw8Ezscot/0dl2ZEhLdlCVGw/kj6c0eDu3uYTFsEqGRs3HKDH4jHlxUHbOjPB83CIHd5UZ7g/+Dn0Ble+91ntK7lutf6Oi5iBsNl2WSPsBcX9nV+Bq+rNS+S2gZFOeXQgPDGn5jvuQYuO7YAM/gsuZaOcDznXIQFstbyJ3dpju3RZFVnHhveroXzZF1w56Hr8/Ij9mZjtXNlymGg2oZwL6YnMNr/mQLZVI1ME+lIOTE8TvifV8SgLonj1FqwWYKhxVAao//6QHyXDynPJJddLpupTozMZ1QCh0r3g8VFbhG1ae2vnO/WoCsk6XcPCyQ6M6CTFOnKD9NMpWq2iErE574Yy4IRcuF2egc1dFds3LlkNGnpHNErlTmyxKIUqGt9itC+Ewo7/eABXdXhvAXnVYuxBGXHciT37GXaKmqx5EAuDz+Ei+4BJ86wmHBiNfx+PGqPZQJD4es2q/u3nXTAu9wtd7IUXl2xLw41HdhKWGlRjxWGfEp9R+yo9mmm2M0xCOIABUmGFWAicS8PRsPaQ6YN5YYDhayQ724vACF3IgIYid/XEujgk4p+kv/biVMavwlA1iSe6aC0jptObAwkW9l4zmbM88s9jiYcabyD9uIXtd/OmXRi2qlgS08BLGWvi1KRRxsnhjCH5m4ZD3RMln7xxYYi X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4140.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199015)(31696002)(8676002)(66476007)(66556008)(86362001)(6512007)(66946007)(2906002)(8936002)(7416002)(5660300002)(4326008)(6666004)(41300700001)(53546011)(6506007)(2616005)(186003)(83380400001)(26005)(316002)(54906003)(478600001)(966005)(6486002)(38100700002)(36756003)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bVdUclBiaytLMW9OOXpmeXJkNjlRZ2FDZE1Uc1VPNVlNTFVsSXJwQVg0elBm?= =?utf-8?B?SDhHZjdub2dUNHVENnFTbm5yUDB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?= =?utf-8?B?QXNPdTZQb0xmUk10V1ROZGVOV2lQNFN5U0NteVVCdnQydUVrTmxwa2RYRVMx?= =?utf-8?B?QjNlRjAyVXQ1Tjhtd1RWc1J3OTJrdS9WYzI1S29iR2JGWmJycExIaUxlcXov?= =?utf-8?B?ZnB3WFBESU1JSUwyWmJ5b3lkcVJRR1pMNy9MSndjN09aUVdONm0vTHVTTWIz?= =?utf-8?B?NVBnU1NDWGFPS2kyWTVMcEtaN1VsT1F0MEZEOFp1eEVwSkhLbDNPNVArZmV3?= =?utf-8?Q?rd+0TaP8hN/lJ4qFBclYpb5GO?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 271e93ad-9713-47b8-75f2-08da9d082846 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4140.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 02:05:59.2363 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hd+k5PYSAZczENF704qH+V0VZcJDYABccKYxDp7B97yLDjnrEkwEjCn5n6+0RMLZL8EMQT273QVJ9xPEoAWg3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6612 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/20/22 05:23, David Hildenbrand wrote: > checkpatch does not point out that VM_BUG_ON() and friends should be > avoided, however, Linus notes: > > VM_BUG_ON() has the exact same semantics as BUG_ON. It is literally > no different, the only difference is "we can make the code smaller > because these are less important". [1] > > So let's warn on VM_BUG_ON() and other BUG variants as well. While at it, > make it clearer that the kernel really shouldn't be crashed. > > As there are some subsystem BUG macros that actually don't end up crashing > the kernel -- for example, KVM_BUG_ON() -- exclude these manually. > > [1] https://lore.kernel.org/r/CAHk-=wg40EAZofO16Eviaj7mfqDhZ2gVEbvfsMf6gYzspRjYvw@mail.gmail.com > > Signed-off-by: David Hildenbrand > --- > scripts/checkpatch.pl | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 79e759aac543..21f3a79aa46f 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -4695,12 +4695,12 @@ sub process { > } > } > > -# avoid BUG() or BUG_ON() > - if ($line =~ /\b(?:BUG|BUG_ON)\b/) { > +# do not use BUG() or variants > + if ($line =~ /\b(?!AA_|BUILD_|DCCP_|IDA_|KVM_|RWLOCK_|snd_|SPIN_)(?:[a-zA-Z_]*_)?BUG(?:_ON)?(?:_[A-Z_]+)?\s*\(/) { Should this be a separate patch? Adding a bunch of exceptions to the BUG() rules is a separate and distinct thing from adding VM_BUG_ON() and other *BUG*() variants to the mix. > my $msg_level = \&WARN; > $msg_level = \&CHK if ($file); > &{$msg_level}("AVOID_BUG", > - "Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()\n" . $herecurr); > + "Do not crash the kernel unless it is unavoidable - use WARN_ON_ONCE & recovery code (if reasonable) rather than BUG() or variants.\n" . $herecurr); Here's a requested tweak, to clean up the output and fix punctuation: "Avoid crashing the kernel--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants.\n" . $herecurr); thanks, -- John Hubbard NVIDIA