* [PATCH] asm-generic: add unlikely to default BUG_ON(x)
@ 2019-08-28 21:09 Denis Efremov
2019-08-28 21:13 ` Denis Efremov
2019-08-30 20:08 ` Arnd Bergmann
0 siblings, 2 replies; 4+ messages in thread
From: Denis Efremov @ 2019-08-28 21:09 UTC (permalink / raw)
Cc: Denis Efremov, linux-kernel, Arnd Bergmann, linux-arch
Add unlikely to default BUG_ON(x) in !CONFIG_BUG. It makes
the define consistent with BUG_ON(x) in CONFIG_BUG.
Signed-off-by: Denis Efremov <efremov@linux.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: <linux-arch@vger.kernel.org>
---
include/asm-generic/bug.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index aa6c093d9ce9..7357a3c942a0 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -185,7 +185,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
#endif
#ifndef HAVE_ARCH_BUG_ON
-#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
#endif
#ifndef HAVE_ARCH_WARN_ON
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] asm-generic: add unlikely to default BUG_ON(x)
2019-08-28 21:09 [PATCH] asm-generic: add unlikely to default BUG_ON(x) Denis Efremov
@ 2019-08-28 21:13 ` Denis Efremov
2019-08-30 20:08 ` Arnd Bergmann
1 sibling, 0 replies; 4+ messages in thread
From: Denis Efremov @ 2019-08-28 21:13 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel, linux-arch
Maybe it will be better to move this define out of ifdef, i.e.:
#ifdef CONFIG_BUG
...
-#define BUG_ON()...
...
#else
...
-#define BUG_ON()...
...
#endif
+#define BUG_ON()...
I can prepare a patch if you think it worth it.
Thanks,
Denis
On 29.08.2019 00:09, Denis Efremov wrote:
> Add unlikely to default BUG_ON(x) in !CONFIG_BUG. It makes
> the define consistent with BUG_ON(x) in CONFIG_BUG.
>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: <linux-arch@vger.kernel.org>
> ---
> include/asm-generic/bug.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
> index aa6c093d9ce9..7357a3c942a0 100644
> --- a/include/asm-generic/bug.h
> +++ b/include/asm-generic/bug.h
> @@ -185,7 +185,7 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
> #endif
>
> #ifndef HAVE_ARCH_BUG_ON
> -#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
> +#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
> #endif
>
> #ifndef HAVE_ARCH_WARN_ON
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] asm-generic: add unlikely to default BUG_ON(x)
2019-08-28 21:09 [PATCH] asm-generic: add unlikely to default BUG_ON(x) Denis Efremov
2019-08-28 21:13 ` Denis Efremov
@ 2019-08-30 20:08 ` Arnd Bergmann
2019-08-30 20:47 ` Kees Cook
1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2019-08-30 20:08 UTC (permalink / raw)
To: Denis Efremov
Cc: Linux Kernel Mailing List, linux-arch, Kees Cook, Andrew Morton,
Stephen Rothwell
On Wed, Aug 28, 2019 at 11:09 PM Denis Efremov <efremov@linux.com> wrote:
>
> Add unlikely to default BUG_ON(x) in !CONFIG_BUG. It makes
> the define consistent with BUG_ON(x) in CONFIG_BUG.
>
> Signed-off-by: Denis Efremov <efremov@linux.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: <linux-arch@vger.kernel.org>
This makes sense, I've applied it to the asm-generic tree for now.
Two concerns though:
- adding unlikely() can cause new (usually false-postive) compile time
warnings to show up in random configurations, so we'll have to see what
the build bots think
- Kees Cook has recently sent a series for asm/bug.h that was merged by
Andrew Morton. If there are is a conflict with your patch, it may be better
to merge both through the same tree, either linux-mm or asm-generic.
Arnd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] asm-generic: add unlikely to default BUG_ON(x)
2019-08-30 20:08 ` Arnd Bergmann
@ 2019-08-30 20:47 ` Kees Cook
0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2019-08-30 20:47 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Denis Efremov, Linux Kernel Mailing List, linux-arch,
Andrew Morton, Stephen Rothwell
On Fri, Aug 30, 2019 at 10:08:49PM +0200, Arnd Bergmann wrote:
> On Wed, Aug 28, 2019 at 11:09 PM Denis Efremov <efremov@linux.com> wrote:
> >
> > Add unlikely to default BUG_ON(x) in !CONFIG_BUG. It makes
> > the define consistent with BUG_ON(x) in CONFIG_BUG.
> >
> > Signed-off-by: Denis Efremov <efremov@linux.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: <linux-arch@vger.kernel.org>
>
> This makes sense, I've applied it to the asm-generic tree for now.
>
> Two concerns though:
>
> - adding unlikely() can cause new (usually false-postive) compile time
> warnings to show up in random configurations, so we'll have to see what
> the build bots think
>
> - Kees Cook has recently sent a series for asm/bug.h that was merged by
> Andrew Morton. If there are is a conflict with your patch, it may be better
> to merge both through the same tree, either linux-mm or asm-generic.
FWIW, this patch looks sensible to me. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-30 20:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28 21:09 [PATCH] asm-generic: add unlikely to default BUG_ON(x) Denis Efremov
2019-08-28 21:13 ` Denis Efremov
2019-08-30 20:08 ` Arnd Bergmann
2019-08-30 20:47 ` Kees Cook
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).