Current BUG_ON() in arch/mips/include/asm/bug.h does not use unlikely(),
in order to get better branch predict result, source code should call
BUG_ON() with unlikely() explicitly. This is not a suggested method to
use BUG_ON().
This patch adds unlikely() inside BUG_ON implementation on MIPS code,
callers can use BUG_ON without explicit unlikely() now.
I have no usable MIPS hardware to build and test the fix, any test result
of this patch is welcome.
Signed-off-by: Coly Li<bosong.ly@xxxxxxxxxx>
Cc: David Daney<ddaney@xxxxxxxxxxxxxxxxxx>
Cc: Wang Cong<xiyou.wangcong@xxxxxxxxx>
Cc: Yong Zhang<yong.zhang0@xxxxxxxxx>
---
arch/mips/include/asm/bug.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/mips/include/asm/bug.h b/arch/mips/include/asm/bug.h
index 540c98a..6771c07 100644
--- a/arch/mips/include/asm/bug.h
+++ b/arch/mips/include/asm/bug.h
@@ -30,7 +30,7 @@ static inline void __BUG_ON(unsigned long condition)
: : "r" (condition), "i" (BRK_BUG));
}
-#define BUG_ON(C) __BUG_ON((unsigned long)(C))
+#define BUG_ON(C) __BUG_ON((unsigned long)unlikely(C))