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 98309C00140 for ; Wed, 24 Aug 2022 16:31:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F187B940007; Wed, 24 Aug 2022 12:31:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA09B6B0074; Wed, 24 Aug 2022 12:31:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D42C1940007; Wed, 24 Aug 2022 12:31:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BF07D6B0073 for ; Wed, 24 Aug 2022 12:31:09 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8F522A0433 for ; Wed, 24 Aug 2022 16:31:09 +0000 (UTC) X-FDA: 79835025858.06.FB1128B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id E47B5140050 for ; Wed, 24 Aug 2022 16:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661358668; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1Meo/JVVOcnrflu5rlIGOgtbrV+Zw+zKCUGgyNys75s=; b=LVR0GDn0LlyANRjs6QyFyC51RNHINXxrk/oxc4e4Eyz4x7AYogbT/ptBti4eew3Fw995Gv ZTRLPg7pi56roHhW3+JXFaabrR38l2Hi8sNJuiMIyq3ysEkddR5rGQY+QPBU5j0DQ660BA ftK9nY4n6FKyTRLpClmSIsZmfxefqV8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-1hJq29stMFOCbma2_vFXbA-1; Wed, 24 Aug 2022 12:31:06 -0400 X-MC-Unique: 1hJq29stMFOCbma2_vFXbA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17417185A7B2; Wed, 24 Aug 2022 16:31:06 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D4C6492C3B; Wed, 24 Aug 2022 16:31:02 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-doc@vger.kernel.org, kexec@lists.infradead.org, David Hildenbrand , Linus Torvalds , Andrew Morton , Ingo Molnar , David Laight , Jonathan Corbet , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Baoquan He , Vivek Goyal , Dave Young Subject: [PATCH RFC 0/2] coding-style.rst: document BUG() and WARN() rules Date: Wed, 24 Aug 2022 18:30:58 +0200 Message-Id: <20220824163100.224449-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661358669; a=rsa-sha256; cv=none; b=5G6BcT3XEcwwtDRWktIsMwZE+Tb5y9HW2vqjrk2LUc7ISNcooihlp1IcUslRib/HXbJFru +oWlxmWjY+xj7va8lGb5QAKw1lTmRZDGZ4viGZgVyjaDw7qr4vuDENLinao4uFCOVB0K2X 1CVKPXkI2IhSaH73RB5UYJ5ksLeklxY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LVR0GDn0; spf=pass (imf09.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=1661358669; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=1Meo/JVVOcnrflu5rlIGOgtbrV+Zw+zKCUGgyNys75s=; b=T7X7la2YN1tE95zCKR8G9awQw0v5mbbiLNBXi+uTMduHPK5SoAyEw3TRaMzSDdUCyaOYlm oxWjiNRyn6LvLnsq7XaPUdW+Bk3XkQ4mF7rltsqJ/jj6jcTCVrr5Bqbhrz+cDsy18kuhJe MaeMZU0KoKHYPRg/uh8iciUihK4qDII= X-Rspam-User: X-Stat-Signature: jwnbsjuq7x3y16j4e5r1wzddc3himjit X-Rspamd-Queue-Id: E47B5140050 X-Rspamd-Server: rspam12 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LVR0GDn0; spf=pass (imf09.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-HE-Tag: 1661358668-352151 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: As it seems to be rather unclear if/when to use BUG(), BUG_ON(), VM_BUG_ON(), WARN_ON_ONCE(), ... let's try to document the result of a recent discussion. Details can be found in patch #1. -------------------------------------------------------------------------- Here is some braindump after thinking about BUG_ON(), WARN_ON(), ... and how it interacts with kdump. I was wondering what the expectation on a system with armed kdump are, for example, after we removed most BUG_ON() instances and replaced them by WARN_ON_ONCE(). I would assume that we actually want to panic in some cases to capture a proper system dump instead of continuing and eventually ending up with a completely broken system where it's hard to extract any useful debug information. We'd have to enable panic_on_warn. But we'd only want to do that in case kdump is actually armed after boot. So one idea would be to have some kind of "panic_on_warn_with_kdump" mode. But then, we'd actually crash+kdump even on the most harmless WARN_ON() conditions, because they all look alike. To compensate, we would need some kind of "severity" levels of a warning -- at least some kind of "this is harmless and we can easily recover, but please tell the developers" vs. "this is real bad and unexpected, capture a dump immediately instead of trying to recover and eventually failing miserably". But then, maybe we really want something like BUG_ON() -- let's call it CBUG_ON() for simplicity -- but be able to make it be usable in conditionals (to implement recovery code if easily possible) and make the runtime behavior configurable. if (CBUG_ON(whatever)) try_to_recover() Whereby, for example, "panic_on_cbug" and "panic_on_cbug_with_kdump" could control the runtime behavior. But this is just a braindump and I assume people reading along have other, better ideas. Especially, a better name for CBUG. Cc: Linus Torvalds Cc: Andrew Morton Cc: Ingo Molnar Cc: David Laight Cc: Jonathan Corbet Cc: Andy Whitcroft Cc: Joe Perches Cc: Dwaipayan Ray Cc: Lukas Bulwahn Cc: Baoquan He Cc: Vivek Goyal Cc: Dave Young David Hildenbrand (2): coding-style.rst: document BUG() and WARN() rules ("do not crash the kernel") checkpatch: warn on usage of VM_BUG_ON() and friends Documentation/process/coding-style.rst | 27 ++++++++++++++++++++++++++ scripts/checkpatch.pl | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) -- 2.37.1