Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp484317pxu; Thu, 7 Jan 2021 09:47:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz93MTKlGiAtfmSJ8NjWGu2MLbxsQPOq6xCMBloP1P3DEl7JdKgao/qVk8Jr4DD9IQ8vclA X-Received: by 2002:a17:906:d784:: with SMTP id pj4mr6957321ejb.360.1610041673071; Thu, 07 Jan 2021 09:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610041673; cv=none; d=google.com; s=arc-20160816; b=NKXb5KNufzdRW/Uo2cNumzk/yHmTM/NvtP/JXlTamnKGwTBg24MvxqW2O9XUJdpDnQ aIiFoeh+Qs7Gb6k7ewuxbHIzHORaH1xEDzXl9Okm8JBMC6lYve+5HUtllmWcgg7bZVgV WniZPGVFKrsMVoNYeXJNUojCQ6dt9KplOq/i2TVczJzujstS4RTGdSMHbv6wf/SxS8vp RM4gvE/X7V7Ge+wX5lRc4Q7rKlAXWrww6XJ2VQG9I4+6ptfnwEUMgJHhTE/yf3lYcFvd nlPhQmmlHPD9rXF4j3vGwFCVbzKes45rTKl/Io5ADsLRqLMmJh+5JIOp/iiGOA52bytJ T40Q== 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=ec+vz5icnGbx+7xaSY1BCHTdXx/s5RO2v90o0OJt77A=; b=dzqH+/cf2BmWdXeWWvTHCVHEi0NfViu/WvoScWZW//m0IzEyXJoEnoOdllPei4VuPt B49w6JiNOEOJHN0VoPyfDycV0i/0d+s4dUQviNpyRcaie+UqIV+dGqMs4VJeWLl1TZQS EpOYKuS8D3akuyeYaCeVRHzO5L8L1bmId92+a7Gj9/27lZE9DmpGdp37syCT8/d7RUZZ I2dvxRMuSNKhIdaJiKXD6Js/FNrqazzH5HEfUx/tM0oFR5RzHApowaodWqIqtdQUOe5B eV8aeX6QPqgZkPUyC8nrBSpfMuJclVIN8ht+2/P5HJq8oG9/0WzDrLARZr15aZiNyjI7 qJbw== 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 l18si2453724eje.178.2021.01.07.09.47.28; Thu, 07 Jan 2021 09:47:53 -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 S1728571AbhAGRpy (ORCPT + 99 others); Thu, 7 Jan 2021 12:45:54 -0500 Received: from mx2.suse.de ([195.135.220.15]:39698 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727061AbhAGRpy (ORCPT ); Thu, 7 Jan 2021 12:45:54 -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 3E703AD78; Thu, 7 Jan 2021 17:45:13 +0000 (UTC) To: Andrea Arcangeli Cc: Hugh Dickins , 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:45:12 +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/7/21 6:36 PM, Andrea Arcangeli wrote: > On Thu, Jan 07, 2021 at 06:28:29PM +0100, Vlastimil Babka wrote: >> 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? > > But this not BUG_ON, Oh, you're right, I got lost in the maze. > and that is an infinite loop while(1), not an And I overlooked that "1" too. So that AFAICS means *both* VM_BUG_ON and VM_WARN_ON behave differently wrt side-effects when disabled than BUG_ON and WARN_ON. > optimization away as in while (0) that I was suggesting to just throw > away cond and make it a noop. BUG() is actually the thing to use to > move functional stuff out of BUG_ON so it's not going to be causing > issues if it just loops. > > This overall feels mostly an aesthetically issue. > > Thanks, > Andrea >