Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp479352pxu; Thu, 7 Jan 2021 09:39:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFrDnvCUCL3tO00JzOrai2EcBglSDYiXUGVaQKRUiSt0FOVXcUZCBYKJq4cR1ufp2uHDRo X-Received: by 2002:aa7:c253:: with SMTP id y19mr2439164edo.179.1610041187552; Thu, 07 Jan 2021 09:39:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610041187; cv=none; d=google.com; s=arc-20160816; b=Oqw6UMOrEKSaG4wqROZeN4S1JXkSdVcHm2KhvksHTZJa7hXRwV6Z3+mGBebM6o1akG cVIfSc5wxmVugRcOJSOLOdFXgzvLCtEfE/MDdGrKokW5syHdRa90Uv9cgGAOuDXjb5WO mAwH1KrFzTBBK95osmzbhljDCSA/ITucdcqiFn6W9qwg/hGcQOs4zlg382E4OEjZqD2K XiyEp5XnT7wMfyklC58u5YQ9/4Xwhm46jCLedNE8jQ6EE5c2VpJMWMKaaeE6qQEMu/JX 9ECC4sKnTFSczdRsHi47AyE8prebQr0ipSz54JVqjR0KJuHODPeHJc8k3sqj/bK5T3nJ Rx8A== 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=HAodYt2HQFDdAV3Nlwj/zRiTtI08o4QNW6FChKlHIwI=; b=dW3Tcl8CV3EEwoevYA+KYQaVaPMO8QSHJhemPrLj7k88aZyA9/FnkS2Aw1q/ey39Sc IXXegmAl9fW8NN6fgQYHOMAIUPVj9jYFFEhfJFAa68rdBei6/IHKPNEyBTzYvvIcGcDx Q2SPRwQnCancArriaXgYROJ7bbeZ7Jq7ql5xgLWS7AJDnt/50O1btuSe6l0784u5w8jh BrQfa/sSmNc3F1I5P0A1wCUMmjbhfhtdbrqF7fVvBbXVEkqp9BP/vrjAoQ8ycnBlws2Z Nd/p4Rfd+rN4ia3EJS9zJdss/Sut9dUNNYdPIn0tJh4SgrmFMENXxbLwwTolG28wkFlf 4ZRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VREKnqPw; 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 l18si2453724eje.178.2021.01.07.09.39.24; Thu, 07 Jan 2021 09:39:47 -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=VREKnqPw; 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 S1728231AbhAGRhh (ORCPT + 99 others); Thu, 7 Jan 2021 12:37:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46981 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbhAGRhh (ORCPT ); Thu, 7 Jan 2021 12:37:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610040971; 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=HAodYt2HQFDdAV3Nlwj/zRiTtI08o4QNW6FChKlHIwI=; b=VREKnqPw8DtlosGR8JZEVxU6wAKZxVSXxfZ2aUggMax4F9+FFmQlL8MJIZgfgpWAtwQ/ib 4JyuQVF8kNVvDJf5rb+mXKRERi75kY5irEdIZRwIHVLKWbLr12Xxk70y/KIW0MnBvUUI/M 8E1i4HnU3OzMl0OmAVIa2NDJYIDlxMA= 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-580-jdWXXdCXP9mMnCa2FnvqhA-1; Thu, 07 Jan 2021 12:36:06 -0500 X-MC-Unique: jdWXXdCXP9mMnCa2FnvqhA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5073C100F349; Thu, 7 Jan 2021 17:36:05 +0000 (UTC) Received: from mail (ovpn-112-222.rdu2.redhat.com [10.10.112.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DDEC860C0F; Thu, 7 Jan 2021 17:36:04 +0000 (UTC) Date: Thu, 7 Jan 2021 12:36:04 -0500 From: Andrea Arcangeli To: Vlastimil Babka Cc: Hugh Dickins , Andrew Morton , 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: User-Agent: Mutt/2.0.4 (2020-12-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, and that is an infinite loop while(1), not an 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