Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp473971pxu; Thu, 7 Jan 2021 09:31:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJygeJRUp6Maz8RSVUA7HoTkLQwkMaBUBMzQj4e8q4CRkVqui1S4GViPlQHiWE+5X2O0yFnL X-Received: by 2002:a17:906:6a92:: with SMTP id p18mr6770648ejr.308.1610040692441; Thu, 07 Jan 2021 09:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610040692; cv=none; d=google.com; s=arc-20160816; b=ZHAve3G1PdzjAVvIhAY9NAxbA9tyxtJP6j9pM5OtANEP9Ksli6yrxmkWOHapT2hmAf DiJgNHRcG8z6wNMjsGYkDl0H5jDK4djXb9XoVt6zmjshVna3KrHev+CEtyFaeB9woasp hiQE94Rs//exL+3BbrO64L3DtjGRl7jPklOk+BoFtKwU/MjSKLF0vZAEzwgiPmB4AjYa LPB9p+jN/IySusfygyotIzydKNlnGUFTE/QYP+BmB8/JOGDo/PbiKD2WLxqMW5bdqj5t Jz6lnQUB1TbSsZNPkQv/hC+UCfwDl3Vbrfl5edX8meL+KKgmg+caAP/RMnjCgClcnvR5 g7hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=2G19jY23Ma/+4+p5NU11tS16oBufLHZkp/TZJP0yW84=; b=K7bL25f0qF2/ZK5uY2d6O5Lhek2uXfzPROY9jbbb6nRLOa3ddsXDthYt6TqpDE0jDZ WheakO7hrmf9TmPLxnFZ9jWoj11JZKEKgfTjHQq4JRG2lBowzF0WxL3iPwLpaFIbcIQs RM+XxoCT3fjaKLvdWetbvQ/RRqIsIJLspuXJ1IqJ7irVHZAmzXTeetOe/nVpPlyHodoh e5SDKV6VvHH7sc/ino/BRQzOSJLWVmPC/JJsE2+4zFrItPRazxYnWwIjzMNarkbsDL6z WVfV6u0WUIOkJJnsT8LJyogjJlRvxuf5X55OcxTU1+hwWWwIK7YjbMSAWdD8CgYxYvIF 7pGQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx6si2456837ejb.550.2021.01.07.09.31.07; Thu, 07 Jan 2021 09:31:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbhAGR3O (ORCPT + 99 others); Thu, 7 Jan 2021 12:29:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:60010 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbhAGR3M (ORCPT ); Thu, 7 Jan 2021 12:29:12 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 37078AD26; Thu, 7 Jan 2021 17:28:30 +0000 (UTC) To: Hugh Dickins , Andrea Arcangeli Cc: Andrew Morton , Alex Shi , Minchan Kim , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org 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> From: Vlastimil Babka Subject: Re: [PATCH] mm/mmap: replace if (cond) BUG() with BUG_ON() Message-ID: Date: Thu, 7 Jan 2021 18:28:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/6/21 9:18 PM, Hugh Dickins wrote: > On Wed, 6 Jan 2021, Andrea Arcangeli wrote: >> >> 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 had been afraid of that too, when CONFIG_BUG is not set: > but I think it's actually "if (cond) do {} while (0)". It's a maze of configs and arch-specific vs generic headers, but I do see this in include/asm-generic/bug.h: #else /* !CONFIG_BUG */ #ifndef HAVE_ARCH_BUG #define BUG() do {} while (1) #endif So seems to me there *are* configurations possible where side-effects are indeed thrown away, right? WARN_ON is different as the result of the "inner" condition should be further usable for constructing "outer" conditions: (still in !CONFIG_BUG section) #ifndef HAVE_ARCH_WARN_ON #define WARN_ON(condition) ({ int __ret_warn_on = !!(condition); unlikely(__ret_warn_on); }) #endif For completeness let's look at our own extensions when VM_DEBUG is disabled, which is quite analogical to disabling CONFIG_BUG and thus it should better be consistent with the generic stuff. #define VM_BUG_ON(cond) BUILD_BUG_ON_INVALID(cond) where BUILD_BUG_ON_INVALID generates no code, so it's consistent with BUG_ON() and !CONFIG_BUG. #define VM_WARN_ON(cond) BUILD_BUG_ON_INVALID(cond) ... well that's not consistent with WARN_ON. Hmm if you have asked me before I checked, I would have said that it is, that I checked it already in the past and/or there was some discussion already about it. Memory is failing me it seems. We should better fix this?