From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754504Ab1A0LyE (ORCPT ); Thu, 27 Jan 2011 06:54:04 -0500 Received: from [114.251.86.0] ([114.251.86.0]:25837 "EHLO enigma.site" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754013Ab1A0LyD (ORCPT ); Thu, 27 Jan 2011 06:54:03 -0500 X-Greylist: delayed 434 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Jan 2011 06:54:02 EST From: Coly Li To: linux-kernel@vger.kernel.org Cc: Coly Li , Jeremy Fitzhardinge , David Daney , Wang Cong , Yong Zhang Subject: [PATCH 2/7] PowerPC: add unlikely() to BUG_ON() Date: Thu, 27 Jan 2011 20:12:31 +0800 Message-Id: <1296130356-29896-3-git-send-email-bosong.ly@taobao.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296130356-29896-1-git-send-email-bosong.ly@taobao.com> References: <1296130356-29896-1-git-send-email-bosong.ly@taobao.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Jeremy Fitzhardinge Cc: David Daney Cc: Wang Cong Cc: Yong Zhang 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 #include /* @@ -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" \