lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 27 Jan 2011 20:12:31 +0800
From:	Coly Li <bosong.ly@...bao.com>
To:	linux-kernel@...r.kernel.org
Cc:	Coly Li <bosong.ly@...bao.com>,
	Jeremy Fitzhardinge <jeremy@...p.org>,
	David Daney <ddaney@...iumnetworks.com>,
	Wang Cong <xiyou.wangcong@...il.com>,
	Yong Zhang <yong.zhang0@...il.com>
Subject: [PATCH 2/7] PowerPC: add unlikely() to BUG_ON()

Current BUG_ON() arch/powerpc/include/asm/bug.h does not use unlikely(),
in order to get better branch predict result, source code may have to 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 PPC
code, callers can use BUG_ON without explicit unlikely() now.

I don't have any PPC hardware to compile and test this fix, any feedback
of this patch is welcome.

Signed-off-by: Coly Li <bosong.ly@...bao.com>
Cc: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: David Daney <ddaney@...iumnetworks.com>
Cc: Wang Cong <xiyou.wangcong@...il.com>
Cc: Yong Zhang <yong.zhang0@...il.com>
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h
index 065c590..10889a6 100644
--- a/arch/powerpc/include/asm/bug.h
+++ b/arch/powerpc/include/asm/bug.h
@@ -2,6 +2,7 @@
 #define _ASM_POWERPC_BUG_H
 #ifdef __KERNEL__
 
+#include <linux/compiler.h>
 #include <asm/asm-compat.h>
 
 /*
@@ -71,7 +72,7 @@
 	unreachable();						\
 } while (0)
 
-#define BUG_ON(x) do {						\
+#define __BUG_ON(x) do {					\
 	if (__builtin_constant_p(x)) {				\
 		if (x)						\
 			BUG();					\
@@ -85,6 +86,8 @@
 	}							\
 } while (0)
 
+#define BUG_ON(x) __BUG_ON(unlikely(x))
+
 #define __WARN_TAINT(taint) do {				\
 	__asm__ __volatile__(					\
 		"1:	twi 31,0,0\n"				\
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ