Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1099887pxu; Wed, 6 Jan 2021 12:14:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3gIB6Khn++ajPY6E9p83BCENGND1x7rig2AZcoOD0KM46pOFJM9FbOr4kyHLZg4Fe53GT X-Received: by 2002:a17:906:a181:: with SMTP id s1mr4186236ejy.60.1609964090133; Wed, 06 Jan 2021 12:14:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609964090; cv=none; d=google.com; s=arc-20160816; b=tk7Mz4lNK+VLMjM1/rAw9BdQyQ3T5Ll4HGvBw6foNVTbH5tIZfQERQk6xa8uL0hhti 42wCJo0Ndslf/BnQiWiny91NUBaZNAxYcSasxeg2yR8qoz3JACwhGn3eaqsn6SUhOm/l 135lkCTd6cc5g0SfRrqgfcGpmNDbFRizU/HQYs53jJYvqoKJxpHuZM90Xu7Ced1E6LFx 5ZZmb6Lem+hMB7B/yFXBnkx7ChSX3qisvtAsIHJu2yvUHXp26gWXeh4v/vvuXsdtENQ0 oR+tD/fqPkLre9Uqzy9nrEvmj3JxftV5jlqxTUulp6bJhnGEFzfg2uYGIvoPowECTj88 Qdow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YOrnA9VnDgH6pNnP7UKRM/V25n0w2/nGPxStTRfdjXU=; b=dkfZGx034NKGw1VwrBySP5HCe9P3sA3kOYvyk0wme187OzRg+c4xXZUwoBVABinr/w rTTMnadOcnmkOyr0PIDyXyO47mYXK6/UOEWrpmDBqHzHcvg+DWPwEcms/VDFjqkiuDCS DwrFah+uOCXAzzEgT/3euRhnfby+7CDyv20yL8OkJR8L8iMDDbg1v9V/f3pfQ3i8uHkD L0c2AOLR9LUe5Er5bUk9aL+ARv7+5tdDGQYabkJqNTyynovvU8qaSro21CgD+fvtyMlk AawMcsCyM9zbQzOrr3Rr1NB4pAQPql10xPJE0hZj4uld8SFpuIANpRX12RzWO3RvNtWq wxyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="H/DFoGKf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c23si1266387eds.525.2021.01.06.12.14.26; Wed, 06 Jan 2021 12:14:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="H/DFoGKf"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727276AbhAFULB (ORCPT + 99 others); Wed, 6 Jan 2021 15:11:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30790 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbhAFULB (ORCPT ); Wed, 6 Jan 2021 15:11:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609963774; 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=H/DFoGKf4m50XoBNNuvlkNUlby0Whk/f2tKo+HRe/Z5H2RrP8wnv4wLoALBxY81yOXDjVE +0pWodvwRDH4RCvQ2fdEkjvqqARnCBnEBv/F9SxPZhW5ziXpqLwerg9bBC7+WmhL5FNa5O EMysL6sXpdCOHPcAJp2p9jWJdAZHef8= 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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