linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] asm-generic: bug: unify hints for BUG_ON()
@ 2018-09-08  4:59 Igor Stoppa
  2018-09-10 12:16 ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Igor Stoppa @ 2018-09-08  4:59 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: igor.stoppa, Igor Stoppa, linux-arch, linux-kernel

If BUG_ON() is used instead of BUG(), it means that probably the
preferred outcome is to not BUG(), therefore the condition tested should
be unlikely().

However, when CONFIG_PROFILE_ANNOTATED_BRANCHES is enabled, the hint is
disabled, to avoid generating false-positive warnings caused by
-Wmaybe-uninitialized.

Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 include/asm-generic/bug.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 20561a60db9c..b91273c36baf 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -58,8 +58,12 @@ struct bug_entry {
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
+#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
 #endif
+#endif
 
 #ifdef __WARN_FLAGS
 #define __WARN_TAINT(taint)		__WARN_FLAGS(BUGFLAG_TAINT(taint))
@@ -183,7 +187,11 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
 #define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
+#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
+#endif
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] asm-generic: bug: unify hints for BUG_ON()
  2018-09-08  4:59 [PATCH v2] asm-generic: bug: unify hints for BUG_ON() Igor Stoppa
@ 2018-09-10 12:16 ` Arnd Bergmann
  2018-09-10 12:22   ` Igor Stoppa
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-09-10 12:16 UTC (permalink / raw)
  To: Igor Stoppa; +Cc: igor.stoppa, linux-arch, Linux Kernel Mailing List

On Sat, Sep 8, 2018 at 6:59 AM Igor Stoppa <igor.stoppa@gmail.com> wrote:
>
> If BUG_ON() is used instead of BUG(), it means that probably the
> preferred outcome is to not BUG(), therefore the condition tested should
> be unlikely().
>
> However, when CONFIG_PROFILE_ANNOTATED_BRANCHES is enabled, the hint is
> disabled, to avoid generating false-positive warnings caused by
> -Wmaybe-uninitialized.
>
> Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: linux-arch@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---

Acked-by: Arnd Bergmann <arnd@arndb.de>

I assume this will be included in a longer patch series rather than
going through
my asm-generic tree, right?

     Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] asm-generic: bug: unify hints for BUG_ON()
  2018-09-10 12:16 ` Arnd Bergmann
@ 2018-09-10 12:22   ` Igor Stoppa
  0 siblings, 0 replies; 4+ messages in thread
From: Igor Stoppa @ 2018-09-10 12:22 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: igor.stoppa, linux-arch, Linux Kernel Mailing List



On 10/09/18 15:16, Arnd Bergmann wrote:

> Acked-by: Arnd Bergmann <arnd@arndb.de>
> 
> I assume this will be included in a longer patch series rather than
> going through
> my asm-generic tree, right?

sadly, no: this patch is just for the asm-generic tree
I tried with the longer patch series, but it didn't work out
I'm now submitting individual patches to their respective mailing lists 
and maintainers.
It requires more churning, but at least some patches are going through.

--
thanks, igor

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] asm-generic: bug: unify hints for BUG_ON()
@ 2018-09-11 12:19 Igor Stoppa
  0 siblings, 0 replies; 4+ messages in thread
From: Igor Stoppa @ 2018-09-11 12:19 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: igor.stoppa, Igor Stoppa, linux-arch, linux-kernel

If BUG_ON() is used instead of BUG(), it means that probably the
preferred outcome is to not BUG(), therefore the condition tested should
be unlikely().

However, when CONFIG_PROFILE_ANNOTATED_BRANCHES is enabled, the hint is
disabled, to avoid generating false-positive warnings caused by
-Wmaybe-uninitialized.

Signed-off-by: Igor Stoppa <igor.stoppa@huawei.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 include/asm-generic/bug.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 20561a60db9c..b91273c36baf 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -58,8 +58,12 @@ struct bug_entry {
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
+#define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
 #endif
+#endif
 
 #ifdef __WARN_FLAGS
 #define __WARN_TAINT(taint)		__WARN_FLAGS(BUGFLAG_TAINT(taint))
@@ -183,7 +187,11 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 #endif
 
 #ifndef HAVE_ARCH_BUG_ON
+#ifdef CONFIG_PROFILE_ANNOTATED_BRANCHES
 #define BUG_ON(condition) do { if (condition) BUG(); } while (0)
+#else
+#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
+#endif
 #endif
 
 #ifndef HAVE_ARCH_WARN_ON
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-11 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-08  4:59 [PATCH v2] asm-generic: bug: unify hints for BUG_ON() Igor Stoppa
2018-09-10 12:16 ` Arnd Bergmann
2018-09-10 12:22   ` Igor Stoppa
2018-09-11 12:19 Igor Stoppa

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).