From: Vlastimil Babka <vbabka@suse.cz>
To: Hugh Dickins <hughd@google.com>, Andrea Arcangeli <aarcange@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alex Shi <alex.shi@linux.alibaba.com>,
Minchan Kim <minchan@kernel.org>, Michal Hocko <mhocko@suse.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmap: replace if (cond) BUG() with BUG_ON()
Date: Thu, 7 Jan 2021 18:28:29 +0100 [thread overview]
Message-ID: <bd10e2dc-7a5e-835d-9a1f-9fff36cc22b5@suse.cz> (raw)
In-Reply-To: <alpine.LSU.2.11.2101061213540.2492@eggly.anvils>
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?
next prev parent reply other threads:[~2021-01-07 17:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-12 3:26 [PATCH] mm/zsmalloc: " Alex Shi
2020-12-12 3:26 ` [PATCH] mm/mmap: " Alex Shi
2020-12-12 3:52 ` Alex Shi
2021-01-06 4:28 ` Hugh Dickins
2021-01-06 8:40 ` Alex Shi
2021-01-06 19:46 ` Andrew Morton
2021-01-06 20:09 ` Andrea Arcangeli
2021-01-06 20:18 ` Hugh Dickins
2021-01-06 20:42 ` Andrew Morton
2021-01-07 17:28 ` Vlastimil Babka [this message]
2021-01-07 17:36 ` Andrea Arcangeli
2021-01-07 17:45 ` Vlastimil Babka
2021-01-06 20:10 ` Hugh Dickins
2021-01-07 8:33 ` Michal Hocko
2020-12-21 16:41 ` [PATCH] mm/zsmalloc: " Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd10e2dc-7a5e-835d-9a1f-9fff36cc22b5@suse.cz \
--to=vbabka@suse.cz \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@linux.alibaba.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®