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=-7.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 AD2A7C433E0 for ; Wed, 6 Jan 2021 20:09:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5AC5E23131 for ; Wed, 6 Jan 2021 20:09:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AC5E23131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A047E6B02D0; Wed, 6 Jan 2021 15:09:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 98D4F6B02D4; Wed, 6 Jan 2021 15:09:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 856176B02D5; Wed, 6 Jan 2021 15:09:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 6AE956B02D0 for ; Wed, 6 Jan 2021 15:09:37 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 26B03824556B for ; Wed, 6 Jan 2021 20:09:37 +0000 (UTC) X-FDA: 77676440394.19.cows97_4213693274e4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 46C3E1AD1BA for ; Wed, 6 Jan 2021 20:09:36 +0000 (UTC) X-HE-Tag: cows97_4213693274e4 X-Filterd-Recvd-Size: 3888 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 Jan 2021 20:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609963775; 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=YOrnA9VnDgH6pNnP7UKRM/V25n0w2/nGPxStTRfdjXU=; b=Ri/2QCMUYJBw26D9a6utmEz7ffD/aJq9hDApoR9Snu5Y1kZtQA8jutvqnwsAEtrAFu0Rfu pgXUDOZxy57RjDOBsigJ41yqaLnE1aApBKw5NiRnzT4au9rr+9a0Z84fOD1DEg5slCHxzO 45PDI82KZdnkKt/V6SgBvILsJo+vkOY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-2hlsXVJfN_6r8-CzC9htEw-1; Wed, 06 Jan 2021 15:09:33 -0500 X-MC-Unique: 2hlsXVJfN_6r8-CzC9htEw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B96061005504; Wed, 6 Jan 2021 20:09:31 +0000 (UTC) Received: from mail (ovpn-112-222.rdu2.redhat.com [10.10.112.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0BBA60875; Wed, 6 Jan 2021 20:09:30 +0000 (UTC) Date: Wed, 6 Jan 2021 15:09:30 -0500 From: Andrea Arcangeli To: Andrew Morton Cc: Hugh Dickins , Alex Shi , Minchan Kim , 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: 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: <20210106114620.5c221690f3a9cad7afcc3077@linux-foundation.org> User-Agent: Mutt/2.0.4 (2020-12-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: Hello, On Wed, Jan 06, 2021 at 11:46:20AM -0800, 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. > > 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? I'd be surprised if the kernel can boot with BUG_ON() defined as "do {}while(0)" so I guess it doesn't make any difference. I've no strong opinion either, but personally my views matches Hugh's views on this. I certainly tried to stick to that in the past since I find it cleaner if a bugcheck just "checks" and can be deleted at any time without sudden breakage. Said that I also guess we're in the minority. Thanks, Andrea