Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp448030rwe; Thu, 25 Aug 2022 03:26:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR4pRZ9T7iNDpOqA+dpqb8CKWrZfpy/x1jH9L4ox+WzdQFPZmEnrfe+AhrE+VEqKbVjNmsGc X-Received: by 2002:a63:88c1:0:b0:42b:49b3:3a7f with SMTP id l184-20020a6388c1000000b0042b49b33a7fmr2418731pgd.64.1661423207036; Thu, 25 Aug 2022 03:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661423207; cv=none; d=google.com; s=arc-20160816; b=vNwgkOvyx5wBQGee9jYHjpLCm8iXsXQww5z1oPF92Gso7FI8qN+JAFBe9ryrsHl0qi Ik7ETitf9QPLvbksxQoq5NTwUrQIzQmEsyGQh+fGbFsNcvkaK0b0tsHOE0RGphU2U91C vX4ABDIK+Hc2fc/M+OivCXlKlgzxUPfKC4QLcsQPwJtVKVJSEpeeR4YuduwuGW+t8SGQ GmSvyRzhGPPaZdb3blzt7QABoyQ/72j3Yt5+i3h/fC5XfKxfks2/FF36033dqgFL2Vh/ gUKQBj1OegyeVGfeiLcuAnMkqd3DaxBq94wLnXh2/rg2eM3s54ztPQYnHDoTLb/d65Uh 4VBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=sXEuh/C7EhMT4N5IVCTMgJSlHVPtxpuWjvzgdztQOwA=; b=jqiy0/GzDceIXFilOo3MJ+swj15zvNMvkWlpFVC/YKowJMXHWxEeM4aHrqUKP+eJmD KfuK+S/4w3npndRlDlxD3lma1oCG797sidyWM2v0WCiIwB2BmRxF6P+DDiq8GDaxjTAg N9xjAkxBNmQ4+e8DSCWCVvOI6uYZBGnGKCwlhQneenzSBUyYEvRJ5WsGDzpLLkkB+EVR LtiuM+IeJV2up/iiaPfENG0NhXGt185/eE5t0I2N6FTSXg1+9gyso0hBGydTewz+cN6R 3DgUgz5t2wHEHvXOL1JY+txLtCplvoZHcpflV+YxJdDUUA8kdIouGVefE5PGdVHgYK/F 4Kgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FyYafbFk; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a62a108000000b0052543a673a0si19640479pff.93.2022.08.25.03.26.35; Thu, 25 Aug 2022 03:26:47 -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=@redhat.com header.s=mimecast20190719 header.b=FyYafbFk; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239156AbiHYJ65 (ORCPT + 99 others); Thu, 25 Aug 2022 05:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230072AbiHYJ6z (ORCPT ); Thu, 25 Aug 2022 05:58:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE2463DF37 for ; Thu, 25 Aug 2022 02:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661421532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sXEuh/C7EhMT4N5IVCTMgJSlHVPtxpuWjvzgdztQOwA=; b=FyYafbFkTwL/yGrlVFUCKT4YjfwfnI7ZlkozTJ2e2AFuQQ9kdkSEIcovrum9Rq4hthtpiJ dDWKpP0h9SlzziymOCHgTfyAZHgQJzPquw55v/oaYuhXHa+0NP+WJErOOIWkI9eDQF/y5V +I4kDsOmkwpyKuPhNfX65drDz3NJnKo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-637-oLL8MPS-PyeJQhcHJ1VbNQ-1; Thu, 25 Aug 2022 05:58:51 -0400 X-MC-Unique: oLL8MPS-PyeJQhcHJ1VbNQ-1 Received: by mail-wm1-f72.google.com with SMTP id i7-20020a1c3b07000000b003a534ec2570so2244169wma.7 for ; Thu, 25 Aug 2022 02:58:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=sXEuh/C7EhMT4N5IVCTMgJSlHVPtxpuWjvzgdztQOwA=; b=oyDsxYaLmWu7W9phdZr8pKHZot1XuA/9VY9u9ihik+KbWsw2754EIq/uKVTlMvOy3+ HOGbd1N+g3jWj8Reb44oQuzLctbvI/euY7hfDTU9wVctFambeSpD6tAZdl+weoSbqDBP P02Za2NKTQuIx9mQ2PFt8CwouBOBVls5FZCBwjGalwEIR10iBWikE4YQO0GuyOWxGuoU aVYbhiqGSAQp6CAPgURQpKXAFdQ3RPKdcxBvRcaLIy7ktr+O+35tDw4X+nVl0FKRaHiF lBGi1w2QjoD4NID4oihGLcBJbJIbchENOS4bRz4u0WiQUD+d3Bk77RfempjPdFkQm2uc Fhcg== X-Gm-Message-State: ACgBeo21nStEhYMjGwsWiuT8VBl5R3HSzzFN2Qk56JVWltR1edN3dwwO hOPPBNKHX59Cv3oe4gt35yhedz3oHdhZdZpHJ6AVNpswGKSDLijwdubKXjw7P882aafVMBFg5UT unuFwhbU5EA+IKUlfWCkrRJlQ X-Received: by 2002:adf:fe09:0:b0:225:6c9a:1925 with SMTP id n9-20020adffe09000000b002256c9a1925mr1689589wrr.546.1661421530147; Thu, 25 Aug 2022 02:58:50 -0700 (PDT) X-Received: by 2002:adf:fe09:0:b0:225:6c9a:1925 with SMTP id n9-20020adffe09000000b002256c9a1925mr1689579wrr.546.1661421529892; Thu, 25 Aug 2022 02:58:49 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:20af:34be:985b:b6c8? ([2a09:80c0:192:0:20af:34be:985b:b6c8]) by smtp.gmail.com with ESMTPSA id e20-20020a5d5954000000b0021e42e7c7dbsm19557923wri.83.2022.08.25.02.58.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 02:58:49 -0700 (PDT) Message-ID: Date: Thu, 25 Aug 2022 11:58:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US To: Joe Perches , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, kexec@lists.infradead.org, Linus Torvalds , Andrew Morton , Ingo Molnar , David Laight , Jonathan Corbet , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn , Baoquan He , Vivek Goyal , Dave Young References: <20220824163100.224449-1-david@redhat.com> <20220824163100.224449-3-david@redhat.com> <3c250aa26020b2f336fd575a58d06ba26faf1f14.camel@perches.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH RFC 2/2] checkpatch: warn on usage of VM_BUG_ON() and friends In-Reply-To: <3c250aa26020b2f336fd575a58d06ba26faf1f14.camel@perches.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 24.08.22 18:52, Joe Perches wrote: > On Wed, 2022-08-24 at 18:31 +0200, 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 friends as well. While at it, make it >> clearer that the kernel really shouldn't be crashed. >> >> Note that there are some other *_BUG_ON flavors, but they are not all >> bad: for example, KVM_BUG_ON() only triggers a WARN_ON_ONCE and then >> flags KVM as being buggy, so we'll not care about them for now here. > [] >> diff --git 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(), BUG_ON(), VM_BUG_ON() and friends. >> + if ($line =~ /\b(?:BUG|BUG_ON|VM_BUG_ON|VM_BUG_ON_[A-Z]+)\b/) { > > Perhaps better as something like the below to pick up more variants > Trying to find more possible variants and exceptions $ git grep -h -o -E "\b[a-zA-Z]+_BUG(_ON(_[a-zA-Z]+)*)?\(" | sort | uniq AA_BUG( -> Ok, no BUG() ASM_BUG( -> Bad BUILD_BUG( BUILD_BUG_ON( BUILD_BUG_ON_INVALID( BUILD_BUG_ON_MSG( BUILD_BUG_ON_ZERO( -> Ok CI_BUG_ON( -> Bad with CONFIG_DRM_I915_DEBUG DCCP_BUG( DCCP_BUG_ON( -> Ok, no BUG() do_BUG( -> BUG implementation, ok. GEM_BUG_ON( -> Bad with CONFIG_DRM_I915_DEBUG_GEM_ONCE GLOCK_BUG_ON( -> Bad handle_BUG( -> BUG implementation, ok. IDA_BUG_ON( KVM_BUG( KVM_BUG_ON( -> Ok, no BUG() lkdtm_BUG( paravirt_BUG( -> bad PROM_BUG( -> unused, will remove RWLOCK_BUG_ON( -> Ok, no BUG() snd_BUG( snd_BUG_ON( -> Ok, no BUG() SNIC_BUG_ON( -> Bad SPIN_BUG_ON( -> Ok, no BUG() UNWINDER_BUG( UNWINDER_BUG_ON( VIRTUAL_BUG_ON( VM_BUG_ON( VM_BUG_ON_FOLIO( VM_BUG_ON_MM( VM_BUG_ON_PAGE( VM_BUG_ON_PGFLAGS( VM_BUG_ON_VMA( XA_BUG_ON( -> Bad So an extended versions of your proposal like (ignoring do_BUG and handle_BUG, people are smart enough to figure that out) if ($line =~ /\b(?!AA_|BUILD_|DCCP_|IDA_|KVM_|RWLOCK_|snd_|SPIN_)(?:[a-zA-Z_]*_)?BUG(?:_ON)?(?:_[A-Z_]+)?\s*\(/ ? -- Thanks, David / dhildenb