Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp527026rwe; Thu, 25 Aug 2022 05:00:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7B0gVya3X9nyEL/VfyaNbnR5QVZ1EcRiwvZWJ3fwqLAQlh3dg1CSnJIXEQuTEX1W4tBwew X-Received: by 2002:a17:907:6091:b0:731:37fb:bd9 with SMTP id ht17-20020a170907609100b0073137fb0bd9mr2203472ejc.219.1661428803366; Thu, 25 Aug 2022 05:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661428803; cv=none; d=google.com; s=arc-20160816; b=Qfo+VlU+sStEW2e3RH0IiPH0jqJOAbao+41Y50Q7P+SJTQDXesIbeM5wZmruVQz33A PCLUEphsXhrU3DxYms0kTYWhAqDjD+MWs2j49K4Djs+OU3ZSpb0DE/nRlhEGGfcR8JX+ /TVrn0dI9RdCXgcaqUKhbFbKATRiEUX0+XOtPBlAPTtgvk7A9YVDdIv3FAvHO9cRsMR9 LOlroK12tMFgFtxsqX9Ay81H7e7n8Q0kmEzaH/icS/PTR7I50KuPVe45CmPybd509CDr 9URlfxMmjr7OFLL4e6h1qIPLSZT+mPyc7T7zOqJ+ivDA2CyMl8G3gWCWDdASyoVOz2DJ /ijQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=Q5G3cI2EOtw4AkgkuMwrdlGEKsnp3KWg6s0vrCd3UKA=; b=wms3me2KVUzIsxu5db7l+1FoQc/9PsUoaZs/aG6LXunMRnV/wSTIeThWJOSnhMucNQ M98NWGg/sf4b8NaUGBniIBolPBs9qZ7siHxnUNnj4YrPoAwpPxwp0cpRiWQfUiQ3r+YN 6xEmfCXS/fP0FTvlN//O1eUG8RQ/E8pMTTaWU8i/EXqwRqpfRqW6Fcb2hMAgGwzjarbc 8bG50+cAsfFElFQTGr01g8Q62+LbQx7mO0ufAz28vcP7lzxAv2Ojiw5vlMeGJjdZDxZb ZVsf5eYftp2PYjj+gil3JPlfLY83cPRCpJhRwiS9+yL6cAiMcrmtxagEAJ09mRyINWC+ pJyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C8hqtsQj; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n22-20020a1709062bd600b0072b4f1c6680si3315750ejg.75.2022.08.25.04.59.35; Thu, 25 Aug 2022 05:00:03 -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=@intel.com header.s=Intel header.b=C8hqtsQj; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240579AbiHYLnZ (ORCPT + 99 others); Thu, 25 Aug 2022 07:43:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240452AbiHYLnX (ORCPT ); Thu, 25 Aug 2022 07:43:23 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029CD9F0F0; Thu, 25 Aug 2022 04:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661427803; x=1692963803; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=tYG7WhfDi49Qt6vYSgp3uYShnGTRn+X7NAL+bBNRm8c=; b=C8hqtsQjY910L1h3IfwEP1KDpg810BkX1FxFfYvnOZ80263XYRlk1b5R nx0Zcbn96GV3ldS/u88DD1s+NMqRyjx+jF2lQ5DGZc3hQ7IVEXpC82P3k DNnRpBr4+fEr1D4LlGPnarTUgiZAAtDuW8w7cCe+/zeuTIpsYImY1qqga 4B9S8aGCQXLLYd+zRpomOAOp8a4ewWTuQQtWyu4kwXeHVTP0R2gu1arzW RwGz6XjFfYRVtBfMF/JGaio7ZKmckdOhjtRRRKSumAJSjr9D2zThxQdz7 Td9SJBXh+npkczVfvVQIzxEcQJgrnomncm9gNKRZyHOdxzLtKM51JeU9h w==; X-IronPort-AV: E=McAfee;i="6500,9779,10449"; a="295497277" X-IronPort-AV: E=Sophos;i="5.93,263,1654585200"; d="scan'208";a="295497277" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 04:43:12 -0700 X-IronPort-AV: E=Sophos;i="5.93,263,1654585200"; d="scan'208";a="560996613" Received: from jnikula-mobl4.fi.intel.com (HELO localhost) ([10.237.66.149]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Aug 2022 04:43:05 -0700 From: Jani Nikula To: David Hildenbrand , 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 Subject: Re: [PATCH RFC 2/2] checkpatch: warn on usage of VM_BUG_ON() and friends In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220824163100.224449-1-david@redhat.com> <20220824163100.224449-3-david@redhat.com> <3c250aa26020b2f336fd575a58d06ba26faf1f14.camel@perches.com> Date: Thu, 25 Aug 2022 14:43:02 +0300 Message-ID: <87y1vch7ll.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Thu, 25 Aug 2022, David Hildenbrand wrote: > 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 > CI_BUG_ON( > -> Bad with CONFIG_DRM_I915_DEBUG > GEM_BUG_ON( > -> Bad with CONFIG_DRM_I915_DEBUG_GEM_ONCE These are hidden behind debug knobs that we use in our CI to specifically catch "should not happen" cases fast and loud. Should not be a problem for regular users. BR, Jani. > 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*\(/ > > ? -- Jani Nikula, Intel Open Source Graphics Center