linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	 Minchan Kim <minchan@kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	 Michal Hocko <mhocko@suse.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap: replace if (cond) BUG() with BUG_ON()
Date: Wed, 6 Jan 2021 12:10:30 -0800 (PST)	[thread overview]
Message-ID: <alpine.LSU.2.11.2101061150180.2400@eggly.anvils> (raw)
In-Reply-To: <20210106114620.5c221690f3a9cad7afcc3077@linux-foundation.org>

On Wed, 6 Jan 2021, Andrew Morton wrote:
> On Tue, 5 Jan 2021 20:28:27 -0800 (PST) Hugh Dickins <hughd@google.com> wrote:
> 
> > Alex, please consider why the authors of these lines (whom you
> > did not Cc) chose to write them without BUG_ON(): it has always
> > been preferred practice to use BUG_ON() on predicates, but not on
> > functionally effective statements (sorry, I've forgotten the proper
> > term: I'd say statements with side-effects, but here they are not
> > just side-effects: they are their main purpose).
> > 
> > We prefer not to hide those away inside BUG macros
> 
> Should we change that?  I find BUG_ON(something_which_shouldnt_fail())
> to be quite natural and readable.

Fair enough.  Whereas my mind tends to filter out the BUG lines when
skimming code, knowing they can be skipped, not needing that effort
to pull out what's inside them.

Perhaps I'm a relic and everyone else is with you: I can only offer
my own preference, which until now was supported by kernel practice.

> 
> As are things like the existing
> 
> BUG_ON(mmap_read_trylock(mm));
> BUG_ON(wb_domain_init(&global_wb_domain, GFP_KERNEL));
> 
> etc.

People say "the exception proves the rule".  Perhaps we should invite a
shower of patches to change those?  (I'd prefer not, I'm no fan of churn.)

> 
> No strong opinion here, but is current mostly-practice really
> useful?

You've seen my vote.  Now let the games begin!

Hugh


  parent reply	other threads:[~2021-01-06 20:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12  3:26 [PATCH] mm/zsmalloc: replace if (cond) BUG() with BUG_ON() Alex Shi
2020-12-12  3:26 ` [PATCH] mm/mmap: " Alex Shi
2020-12-12  3:52   ` Alex Shi
2021-01-06  4:28     ` Hugh Dickins
2021-01-06  8:40       ` Alex Shi
2021-01-06 19:46       ` Andrew Morton
2021-01-06 20:09         ` Andrea Arcangeli
2021-01-06 20:18           ` Hugh Dickins
2021-01-06 20:42             ` Andrew Morton
2021-01-07 17:28             ` Vlastimil Babka
2021-01-07 17:36               ` Andrea Arcangeli
2021-01-07 17:45                 ` Vlastimil Babka
2021-01-06 20:10         ` Hugh Dickins [this message]
2021-01-07  8:33           ` Michal Hocko
2020-12-21 16:41 ` [PATCH] mm/zsmalloc: " Minchan Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.2101061150180.2400@eggly.anvils \
    --to=hughd@google.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).