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 X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB61C433E0 for ; Wed, 6 Jan 2021 20:10:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 390D223131 for ; Wed, 6 Jan 2021 20:10:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 390D223131 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A9D016B02D4; Wed, 6 Jan 2021 15:10:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A27066B02D6; Wed, 6 Jan 2021 15:10:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9174A6B02D7; Wed, 6 Jan 2021 15:10:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 7AC2A6B02D4 for ; Wed, 6 Jan 2021 15:10:47 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3F119181AEF2A for ; Wed, 6 Jan 2021 20:10:47 +0000 (UTC) X-FDA: 77676443334.04.sofa00_3210fba274e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 2037480118EF for ; Wed, 6 Jan 2021 20:10:47 +0000 (UTC) X-HE-Tag: sofa00_3210fba274e4 X-Filterd-Recvd-Size: 4877 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 20:10:46 +0000 (UTC) Received: by mail-oi1-f178.google.com with SMTP id 15so4784839oix.8 for ; Wed, 06 Jan 2021 12:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=sckuBFKDP/tBwUgNZbg7jLIawlE/HReY1fWcTvNn+Ik=; b=FqMt0IyR2Gr6pgNEehhrW0GUBda+3DiL1blCiFaqlcFWCHRwxQRp34T/GG5+OBM+zD RcNlYhaaMHPkb9NxPGJMO3oO82xw82mTugaMEWf6zQ5Z3SOIHFHfZncjzThUUl3uK+sP X6K/N2BLAcXBTDIKcWfWZoT7C65ZguG2kUmWn3m+7argOLDFMw1MeSfoIwIYMdqWc1PO 7tYQNZmtNJJOb9zxI2NeLXcaCcc5MawFFra84U2GNUUY5xA1TSNSHtk7ptOUhRfmZj7l /Tvf1xKB3NNj+/d+IixsIARQUvAfwBCKrmuruCUZ7GEx6Qne500hD5tkN1+NOPChaLg9 Z/pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=sckuBFKDP/tBwUgNZbg7jLIawlE/HReY1fWcTvNn+Ik=; b=JhfIZoAh/4+6Tno+j0Yk/jvL0VwjD1GIpxfWQ9+ZKl+yHu0tOjVW9b6gQpjFH9mSlH xF1uorTbwhkLB903wh0mM8hdZSnKMnTXHUrXfSpweXG78fCVcLzqYX9h0Z7dBdLjQeMt 6/DdOPAcxud5W+ZqkpZWVgv+D+8uBEjKUaK3RBbutoaeKjNk2y2Ial7y+adr4r4SwWKL +U5YE2rSrhflNwbLl+zQCmImdcVhJghRjFQ3F28Ga1+256WdzfUEui3eid54Jll/rato fnu7bxsCRpweCbnldc1yE51eUAjXb6DdAJRxzHapy23W63p+S6LiryMGsCNRDrX6DVxJ I9cg== X-Gm-Message-State: AOAM533wwm8vi15LSYncBCAIaa76dClWouZXRQRA6rGhDCn45YYCyRyf fxmAzytROXfiRuXw+FaseIWmAA== X-Google-Smtp-Source: ABdhPJzr/Lph7HH4uDU/k4Bu9lyenK39zcnUlm8v++01PvcJSgzXwNU5CF3ETlZDAA98y26LwAL6lg== X-Received: by 2002:a05:6808:b18:: with SMTP id s24mr4373888oij.72.1609963845708; Wed, 06 Jan 2021 12:10:45 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id m15sm692345otl.11.2021.01.06.12.10.44 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 06 Jan 2021 12:10:45 -0800 (PST) Date: Wed, 6 Jan 2021 12:10:30 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Hugh Dickins , Alex Shi , Minchan Kim , Andrea Arcangeli , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mmap: replace if (cond) BUG() with BUG_ON() In-Reply-To: <20210106114620.5c221690f3a9cad7afcc3077@linux-foundation.org> Message-ID: References: <1607743586-80303-1-git-send-email-alex.shi@linux.alibaba.com> <1607743586-80303-2-git-send-email-alex.shi@linux.alibaba.com> <20210106114620.5c221690f3a9cad7afcc3077@linux-foundation.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Wed, 6 Jan 2021, Andrew Morton wrote: > On Tue, 5 Jan 2021 20:28:27 -0800 (PST) Hugh Dickins 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