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 10BC2ECAAA2 for ; Mon, 29 Aug 2022 01:56:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65BB3940008; Sun, 28 Aug 2022 21:56:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60A18940007; Sun, 28 Aug 2022 21:56:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AA6E940008; Sun, 28 Aug 2022 21:56:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3BF50940007 for ; Sun, 28 Aug 2022 21:56:06 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E28CB1C61E8 for ; Mon, 29 Aug 2022 01:56:05 +0000 (UTC) X-FDA: 79850964690.04.0A13C16 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 61F65140030 for ; Mon, 29 Aug 2022 01:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661738164; 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: in-reply-to:in-reply-to:references:references; bh=/lL9xtmFCS+QjOxGv7pOfwve3SFMHPxQby6r9EFdWUQ=; b=Lx8GYNd51dayv9cLFbAHoqyyrs+FNxjyaROY8Jn7CAaeQM2tWm1zLlhmcT1PJfHmgkNIRL 3rxUgodyxH0Jr2MPaGDBTTx7/A2cM3ncSbJQDECfYcWttIZwSSDOj66DGzLCYXwo7jCO0+ LVSCfnzE4fnmQiTgK79eZJeXVu5XbPE= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-97-jyQJKGIXOp2rkJHk8_RVqA-1; Sun, 28 Aug 2022 21:56:03 -0400 X-MC-Unique: jyQJKGIXOp2rkJHk8_RVqA-1 Received: by mail-ed1-f71.google.com with SMTP id r11-20020a05640251cb00b004484ec7e3a4so1750830edd.8 for ; Sun, 28 Aug 2022 18:56:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=/lL9xtmFCS+QjOxGv7pOfwve3SFMHPxQby6r9EFdWUQ=; b=5QBWTQu+rIgqWZBniFXqyWDMuFRztT1mLOjFVOMR5TiR01A5YzIc2Sb7zCM9/5Hfa9 xBGmv7WSEzU8ZeDfCBX2X6nd1IwFU+LIRpUNcs4hXDlHgWudUz2w4mcEgAtRNOD3kVVV 6JIVqzFzyZDIUPWp7QsWPdoXLZG1lOEr0nv5TKoG785jEbDYDSP2BTrB4XQfDQ1g4lE/ hQG7LSLNrOuWIbEnen2iu+YWYZx4Fy1yY8OOGYFHvG8uADABhpZPDYwhGz1K0O6ULc9e II5XwiB0hnt5NG9xttWEQ4/H9U2rRSHesUDu583hLjGR6scyR6z8G760oLCGfckHWSXb w/ug== X-Gm-Message-State: ACgBeo3Hmx/ZWlQi4w/FeVrEYIvvve8nopupSvkfra/BThTN8YPZwD15 AbhlTh7PvDAeqS0PA4fQMZX1CU2/yalRHgRTMbSsJ34OpUf4Tb/2ssoWPx/blRyumc1OqcI+6E3 7uH9s6vvqAoc1XOvb3NBc7EvFg5o= X-Received: by 2002:a05:6402:5110:b0:440:4cb1:c137 with SMTP id m16-20020a056402511000b004404cb1c137mr15415383edd.262.1661738162366; Sun, 28 Aug 2022 18:56:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5eMXbOLee5RayKIqofkJ3fxRMK30WscRLXXzrEPqElRjEUewfxLjylxvXdDgHHQSmEVcGPJxqYWWX+KCNadZg= X-Received: by 2002:a05:6402:5110:b0:440:4cb1:c137 with SMTP id m16-20020a056402511000b004404cb1c137mr15415361edd.262.1661738162130; Sun, 28 Aug 2022 18:56:02 -0700 (PDT) MIME-Version: 1.0 References: <20220824163100.224449-1-david@redhat.com> <20220824163100.224449-2-david@redhat.com> <0db131cf-013e-6f0e-c90b-5c1e840d869c@nvidia.com> In-Reply-To: From: Dave Young Date: Mon, 29 Aug 2022 09:55:51 +0800 Message-ID: Subject: Re: [PATCH RFC 1/2] coding-style.rst: document BUG() and WARN() rules ("do not crash the kernel") To: David Hildenbrand Cc: John Hubbard , linux-kernel@vger.kernel.org, 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 , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Baoquan He , Vivek Goyal , Stephen Johnston , Prarit Bhargava X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lx8GYNd5; spf=pass (imf23.hostedemail.com: domain of ruyang@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ruyang@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661738165; a=rsa-sha256; cv=none; b=7QvpHg4cz/zMl10Lmr/caDUbQdxJHezmOe7vPOyPl+276OoogZNYYcN8879JRi1b3+Qq+u tI5fx/J6rclMnzngnq8hYzsETGFntbBX7r8Vla1QLSui7kNztKH0OapNRWqsz37dEZ0/KO epRxKFZmgs6BKLLMVGC6XHLybmWQLto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661738165; 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=/lL9xtmFCS+QjOxGv7pOfwve3SFMHPxQby6r9EFdWUQ=; b=4gCrm47l3m4Cx+4fDqmhZylcbSv8oiIylHUr5vohYHN67Pa5lIr0/sd2DAWza5dZOqB97K kS+5bxOYWWjLr1/lJzWmr4CB/XmNzJudKcm0zvx/nNV1F6WrIQoHSzBwfU5pi4CkQfMC0N lR5OhLuGiWi5v4GApSYy5phYV1k8R8A= Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Lx8GYNd5; spf=pass (imf23.hostedemail.com: domain of ruyang@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=ruyang@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: i9j6azr5zjnf6smhomisj7p679w38nmx X-Rspamd-Queue-Id: 61F65140030 X-Rspam-User: X-Rspamd-Server: rspam04 X-HE-Tag: 1661738165-337788 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: Hi David, On Sat, 27 Aug 2022 at 01:02, David Hildenbrand wrote: > > On 26.08.22 03:43, Dave Young wrote: > > Hi David, > > > > [Added more people in cc] > > > > Hi Dave, > > thanks for your input! You are welcome :) > > [...] > > >> Side note: especially with kdump() I feel like we might see much more > >> widespread use of panic_on_warn to be able to actually extract debug > >> information in a controlled manner -- for example on enterprise distros. > >> ... which would then make these systems more likely to crash, because > >> there is no way to distinguish a rather harmless warning from a severe > >> warning :/ . But let's see if some kdump() folks will share their > >> opinion as reply to the cover letter. > > > > I can understand the intention of this patch, and I totally agree that > > BUG() should be used carefully, this is a good proposal if we can > > clearly define the standard about when to use BUG(). But I do have > > Essentially, the general rule from Linus is "absolutely no new BUG_ON() > calls ever" -- but I think the consensus in that thread was that there > are corner cases when it comes to unavoidable data corruption/security > issues. And these are rare cases, not the usual case where we'd have > used BUG_ON()/VM_BUG_ON(). Yes, probably.. (say probably because those cases are hidden and not clear sometimes) > > > some worries, I think this standard is different for different sub > > components, it is not clear to me at least, so this may introduce an > > unstable running kernel and cause troubles (eg. data corruption) with > > a WARN instead of a BUG. Probably it would be better to say "Do not > > WARN lightly, and do not hesitate to use BUG if it is really needed"? > > > Well, I don't make the rules, I document them and share them for general > awareness/comments :) Documenting this is valuable, because there seem > to be quite some different opinions floating around in the community -- > and I've been learning different rules from different people over the years. Understand. > > > > > About "patch_on_warn", it will depend on the admin/end user to set it, > > it is not a good idea for distribution to set it. It seems we are > > leaving it to end users to take the risk of a kernel panic even with > > all kernel WARN even if it is sometimes not necessary. > > My question would be what we could add/improve to keep systems with > kdump armed running as expected for end users, that is most probably: > > 1) don't crash on harmless WARN() that can just be reported and the > machine will continue running mostly fine without real issues. > 2) crash on severe issues (previously BUG) such that we can properly > capture a system dump via kdump. The restart the machine. > > Of course, once one would run into 2), one could try reproducing with > "panic_on_warn" to get a reasonable system dump. But I guess that's not > what enterprise customers expect. > Sometimes the bug can not be easily reproduced again. So there seems no easy and good way to use.. > > One wild idea (in the cover letter) was to add something new that can be > configured by user space and that expresses that something is more > severe than just some warning that can be recovered easily. But it can > eventually be recovered to keep the system running to some degree. But > still, it's configurable if we want to trigger a panic or let the system > run. > > John mentioned PANIC_ON(). > I would vote for PANIC_ON(), it sounds like a good idea, because BUG_ON() is not obvious and, PANIC_ON() can alert the code author that this will cause a kernel panic and one will be more careful before using it. > > What would be your expectation for kdump users under which conditions we > want to trigger kdump and when not? > > Regarding panic_on_warn, how often do e.g., RHEL users observe warnings > that we're not able to catch during testing, such that "panic_on_warn" > would be a real no-go? Well, I'm not sure how to answer the questions, when to panic should be decided by kernel developers instead of kdump users, but I think the panic behaviour does impact the supporting team. I added Stephen who is from the RH supporting team, maybe he can have some inputs. BTW, I vaguely remember Prarit introduced the panic_on_warn, see if he has any comments here. Thanks Dave > > -- > Thanks, > > David / dhildenb >