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 592BEC28D13 for ; Thu, 25 Aug 2022 11:51:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 92E5D940007; Thu, 25 Aug 2022 07:51:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DC336B0075; Thu, 25 Aug 2022 07:51:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77C7A940007; Thu, 25 Aug 2022 07:51:22 -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 68EBC6B0074 for ; Thu, 25 Aug 2022 07:51:22 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3E1D51A0D13 for ; Thu, 25 Aug 2022 11:51:22 +0000 (UTC) X-FDA: 79837949604.14.BC47EC5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id E7813C0004 for ; Thu, 25 Aug 2022 11:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661428280; 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=FtM1BEUnONM80EGQIlSjFJxOzxx4asObkPOcf/dUoJ4=; b=Lyr54WD1q0IE6LrorPtddJy0VppvUkGqsnwW5MLVOF5qrswTQjoK2e2RKO7L80ceNr38Wd d6WAaWa7HdZihIUhJn2v+hxgUNuroHOOODk/OhOsmrVJ7Mdews4NXURnzKIOr2LRmkT00M +J1wNXNa5AJKmDTiCil0A8s2i3BbFbo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-283-hojLaz0uOT-F_FccFRQCDg-1; Thu, 25 Aug 2022 07:51:19 -0400 X-MC-Unique: hojLaz0uOT-F_FccFRQCDg-1 Received: by mail-wm1-f71.google.com with SMTP id i7-20020a1c3b07000000b003a534ec2570so2358998wma.7 for ; Thu, 25 Aug 2022 04:51:19 -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:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=FtM1BEUnONM80EGQIlSjFJxOzxx4asObkPOcf/dUoJ4=; b=DqjV6npzX6+uAMZNR5mzs8+BvojPlRrNlsVNkRi+B+0Hw0R84m6UuYqL8g4sgIxBut GYm6UUvlY/10ZTxeju1wOgQWSS3dHxpx2JfJRNVJcExiHplq7ygCjlnyZfSN4Ybq1bQu xE9Qm7bvWcY8KwhQxSphHBcg04mte817DSmptZ4hWf+DnNVSEiwX6wqPIX7i5hTGpbvy l/QNfA0nx8ISZop97IQpQgxVE7QnGrmLNHKTI5hg0XkFeYY6l6PVlvbnvYPUbVHhHNbv c3ZoyZL/M7JULVJoRsCg3CdUwLzVC0/J5NWq1fy7dg8QsMhRvbot1TMEjHMx1P6JxF4N 5WAQ== X-Gm-Message-State: ACgBeo0XV9WgWEYLEgvvHhwy50yDg/00Ne9srKlncXx13CWy9RVCHB93 /vllNw0byUK4BddOP181Lnr2WQQE5XHJwXRiZwwVGpPoOctmXxH0BwuDgcXxuhMEYMqdW+fBGWb MMppc5DikphQ= X-Received: by 2002:a5d:5711:0:b0:225:2884:cc88 with SMTP id a17-20020a5d5711000000b002252884cc88mr2042084wrv.141.1661428278227; Thu, 25 Aug 2022 04:51:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ItDcDX1kgqfGm06T3zwrfPTH11v1D3bxOfe8g8QfbYHQI/EKxqMNESF+ugudGdiYuS0nzTQ== X-Received: by 2002:a5d:5711:0:b0:225:2884:cc88 with SMTP id a17-20020a5d5711000000b002252884cc88mr2042062wrv.141.1661428277919; Thu, 25 Aug 2022 04:51:17 -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 w6-20020a5d4b46000000b002205a5de337sm19282158wrs.102.2022.08.25.04.51.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 04:51:17 -0700 (PDT) Message-ID: <7d146520-52e2-bd8d-3c53-a444e93e4006@redhat.com> Date: Thu, 25 Aug 2022 13:51:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH RFC 2/2] checkpatch: warn on usage of VM_BUG_ON() and friends To: Jani Nikula , 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> <87y1vch7ll.fsf@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <87y1vch7ll.fsf@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661428281; a=rsa-sha256; cv=none; b=1vLfPrqR6FeiexhxtgpsbPSqqjbHMK22PqP+MCgvOpGTPvoCNZkevysqOzl9Crh3vHYmGm Y7YT0P6PI6YaKXM898JiaDCi3ayV03eBbP6lp7mMKBh6NrBQiPX5d5EEfgSPEPo2/ryRoY n0Vq7Ao5eUsAozM14AezWRArVJs/wAY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lyr54WD1; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661428281; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FtM1BEUnONM80EGQIlSjFJxOzxx4asObkPOcf/dUoJ4=; b=bRa8+krC3QpwBeH4oRHQe6sqE5jNwdM27vwoJaGKJTTmcInBOc23LsPWbsBCGTgtd++oL/ pUsczyWjPvNwcLvSdv/i/6hFlhex3IhxBH5ST99Qb8ssgB2bNbHdVKGS6muwGjeZ+FlFsQ sYPTVyg8yzL+k29ERe5DtNyvjtf+Xvg= Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lyr54WD1; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 4bp3p4w5p1o5ydeffae89c3hhm41a7j1 X-Rspamd-Queue-Id: E7813C0004 X-HE-Tag: 1661428280-597031 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 25.08.22 13:43, Jani Nikula wrote: > 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. > I tend to agree but I don't think this is worth an exception. VM_BUG_ON also requires CONFIG_DEBUG_VM and absolutely shouldn't be used as I learned. Quoting Linus: Really. BUG_ON() IS NOT FOR DEBUGGING. [1] This kind of "I don't think this can happen" is _never_ an excuse for it. [2] For CI work, it might be sufficient to use WARN_ON_ONCE() combined with panic_on_warn. [1] https://lore.kernel.org/all/CAHk-=wiEAH+ojSpAgx_Ep=NKPWHU8AdO3V56BXcCsU97oYJ1EA@mail.gmail.com/ [2] https://lore.kernel.org/all/CAHk-=wg40EAZofO16Eviaj7mfqDhZ2gVEbvfsMf6gYzspRjYvw@mail.gmail.com/ -- Thanks, David / dhildenb