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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E01BCC04AA5 for ; Thu, 25 Aug 2022 11:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F98E940007; Thu, 25 Aug 2022 07:43:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A9416B0075; Thu, 25 Aug 2022 07:43:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 270EC940007; Thu, 25 Aug 2022 07:43:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 10A9A6B0074 for ; Thu, 25 Aug 2022 07:43:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D775F41BDB for ; Thu, 25 Aug 2022 11:43:18 +0000 (UTC) X-FDA: 79837929276.30.5994ED7 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf18.hostedemail.com (Postfix) with ESMTP id 8A6AC1C0011 for ; Thu, 25 Aug 2022 11:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661427797; x=1692963797; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=tYG7WhfDi49Qt6vYSgp3uYShnGTRn+X7NAL+bBNRm8c=; b=RVTLroGGMRgyv0fi1TcbhRzFvwY2DtzS2RrqJ6CKCoqXobF5DnduGvhT LYzXHhzC0OJdT4Bi/srqcfJbwEgw7OnyL4IHcarwWqUSuPGsCVpV85/fI +SxYdUig9pW1nLCK/yEmshMZeoUq8pPaw1H+PYmWT3clifPbGHUFoXgQp sTyUEDUgvBXxCrkZcawf1Mq0J5bFsfCDV+9EyPh+ZvH2VETWo+I0EU8Uq Yk+q9Futj9aOTH4Rp/u/tTC5jnd98tDhiFXyS38nHTLmRZ08pypnRitVO dOWYnckQBPQ2fZ3fNi6Dd+X6xhqeXzdkMoE2H2ldlMIiHWsoknfE/FL7f g==; X-IronPort-AV: E=McAfee;i="6500,9779,10449"; a="273970384" X-IronPort-AV: E=Sophos;i="5.93,263,1654585200"; d="scan'208";a="273970384" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661427798; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Q5G3cI2EOtw4AkgkuMwrdlGEKsnp3KWg6s0vrCd3UKA=; b=Q48xGhL7Yw7iKyu6GUd4wvHcX07KD2zsmcVz3V9Ll++xbqh1Itz4MdeM3LSI8lC5qLBiEk OlPdmaupqhUArErkWVtiCCjTgQEWG51SsMOynk8XJwMjtBR+QDj+sujAUORzyCjlTQArTC R1fQjDFIo2RLTri+hWBZLVQ/RMrlN88= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=RVTLroGG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of jani.nikula@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=jani.nikula@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661427798; a=rsa-sha256; cv=none; b=Wy0jdq03X9fXbVZZUEQ/qXF5B3jEGukmOOMSln+ZaqvC+5R8jCtL0YdkXvPyJhxJnLf/Ye onfTeCk0oq6PS889g91MOp0QsygARHzhgB4Ya1GicfkQhl6zve60h//ZdZOuefaE1dygmG mdh0VB6frBjT76UwIsH02kVWQFzmnuI= Authentication-Results: imf18.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=RVTLroGG; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of jani.nikula@intel.com designates 192.55.52.136 as permitted sender) smtp.mailfrom=jani.nikula@intel.com X-Rspam-User: X-Rspamd-Queue-Id: 8A6AC1C0011 X-Rspamd-Server: rspam10 X-Stat-Signature: nn58xwf75q1i7b5f3ctu6qu75dyj7cta X-HE-Tag: 1661427797-965623 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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