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=-6.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 CC0F1C433DB for ; Wed, 6 Jan 2021 19:46:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6DB0123132 for ; Wed, 6 Jan 2021 19:46:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6DB0123132 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B59766B02C7; Wed, 6 Jan 2021 14:46:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AE2EC6B02C8; Wed, 6 Jan 2021 14:46:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D0B26B02C9; Wed, 6 Jan 2021 14:46:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 841A26B02C7 for ; Wed, 6 Jan 2021 14:46:23 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3D50F181AEF30 for ; Wed, 6 Jan 2021 19:46:23 +0000 (UTC) X-FDA: 77676381846.10.balls55_540822c274e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 10CE916A0B9 for ; Wed, 6 Jan 2021 19:46:23 +0000 (UTC) X-HE-Tag: balls55_540822c274e4 X-Filterd-Recvd-Size: 2485 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 19:46:22 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B00123131; Wed, 6 Jan 2021 19:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1609962381; bh=mTkPqvalyZGT+HNCgL8RBG8IvEJHEcO8w9JgqACOlqk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lOdJhUQafw8lhnLzWFVEy8xjLN97baNoa8CetSHuHg+wkKl6LbziGFBbfNl4FMqrT vu5eHaNGbgR9wcM8KVJ9C+TCtUEwuJsYX5dc4fKzyXkG7bhaR92EnBWv8NUH6C8bDy BjS+g2qj8JhLYGOuRb7YWqbfl48p7+SuMShXOmcg= Date: Wed, 6 Jan 2021 11:46:20 -0800 From: Andrew Morton To: Hugh Dickins Cc: 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() Message-Id: <20210106114620.5c221690f3a9cad7afcc3077@linux-foundation.org> In-Reply-To: References: <1607743586-80303-1-git-send-email-alex.shi@linux.alibaba.com> <1607743586-80303-2-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 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. As are things like the existing BUG_ON(mmap_read_trylock(mm)); BUG_ON(wb_domain_init(&global_wb_domain, GFP_KERNEL)); etc. No strong opinion here, but is current mostly-practice really useful?