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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 52AF4C433DB for ; Thu, 7 Jan 2021 08:33:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CAEFB20784 for ; Thu, 7 Jan 2021 08:33:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CAEFB20784 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E1FE36B030F; Thu, 7 Jan 2021 03:33:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA8AA6B0310; Thu, 7 Jan 2021 03:33:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C21096B0311; Thu, 7 Jan 2021 03:33:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id A902A6B030F for ; Thu, 7 Jan 2021 03:33:26 -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 6F4E3181AEF07 for ; Thu, 7 Jan 2021 08:33:26 +0000 (UTC) X-FDA: 77678314812.04.quill12_1a0b27b274e8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 5753C80104D6 for ; Thu, 7 Jan 2021 08:33:26 +0000 (UTC) X-HE-Tag: quill12_1a0b27b274e8 X-Filterd-Recvd-Size: 3750 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 7 Jan 2021 08:33:25 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1610008404; h=from:from:reply-to: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=atqkR6C9/ExhC/8cuG/QGTvgoAMgF5+BLpqtsv0ezpE=; b=eaMrF6pBLcI5HmqeMr5Jwf+N7AZJQq8O4+DcXq7tmFfc6hk/5BvC3NJALjUFiUgr3EsOQy TVCRQCSZ54+/t5HcLebSjTy5EAKb2FrsJwfKw9q95ofQN5XWd4wRKVxjX3MrehNuBRZ9cP UWa5doHmCnua8SQfLS3A6ARHjKlIsnI= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 76E86B762; Thu, 7 Jan 2021 08:33:24 +0000 (UTC) Date: Thu, 7 Jan 2021 09:33:23 +0100 From: Michal Hocko To: Hugh Dickins Cc: Andrew Morton , Alex Shi , Minchan Kim , Andrea Arcangeli , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mmap: replace if (cond) BUG() with BUG_ON() Message-ID: <20210107083323.GZ13207@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 06-01-21 12:10:30, Hugh Dickins wrote: > 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. I agree with Hugh. BUG_ON on something that is not a trivial predicate makes the code slightly harder to follow. I also do agree that accomodating the coding style to the existing code is better as well because the resulting code is more compact. In general I consider code transformations like this without a higher goal that is stated explicitly a pointless churn which doesn't bring much while it consumes a very scarce review bandwidth. Even when those look trivial there is always a room to introduce silent breakage. Be it a checkpatch or coccinelle the change shouldn't be based solely on the script complains. Really, what is the point of changing an existing if (cond) BUG into BUG_ON? Fewer lines? Taste? Code consistency? -- Michal Hocko SUSE Labs