From: David Daney <ddaney@caviumnetworks•com>
To: Coly Li <bosong.ly@taobao•com>
Cc: Wang Cong <xiyou.wangcong@gmail•com>,
Jeremy Fitzhardinge <jeremy@goop•org>,
linuxppc-dev@lists•ozlabs.org, linux-kernel@vger•kernel.org,
Yong Zhang <yong.zhang0@gmail•com>
Subject: Re: [PATCH 2/7] PowerPC: add unlikely() to BUG_ON()
Date: Thu, 27 Jan 2011 09:57:39 -0800 [thread overview]
Message-ID: <4D41B213.4070606@caviumnetworks.com> (raw)
In-Reply-To: <1296130356-29896-3-git-send-email-bosong.ly@taobao.com>
Why not also CC the PPC maintainers as well? I am not certain, but I
think they may be reached at:
linuxppc-dev@lists•ozlabs.org
On 01/27/2011 04:12 AM, Coly Li wrote:
> 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@taobao•com>
> Cc: Jeremy Fitzhardinge<jeremy@goop•org>
> Cc: David Daney<ddaney@caviumnetworks•com>
> Cc: Wang Cong<xiyou.wangcong@gmail•com>
> Cc: Yong Zhang<yong.zhang0@gmail•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))
> +
This is the same type of frobbing you were trying to do to MIPS.
I will let the powerpc maintainers weigh in on it, but my opinion is
that, as with MIPS, BUG_ON() is expanded to a single machine
instruction, and this unlikely() business will not change the generated
code in any useful way. It is thus gratuitous code churn and
complexification.
David Daney
> #define __WARN_TAINT(taint) do { \
> __asm__ __volatile__( \
> "1: twi 31,0,0\n" \
next parent reply other threads:[~2011-01-27 17:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1296130356-29896-1-git-send-email-bosong.ly@taobao.com>
[not found] ` <1296130356-29896-3-git-send-email-bosong.ly@taobao.com>
2011-01-27 17:57 ` David Daney [this message]
2011-01-27 20:04 ` [PATCH 2/7] PowerPC: add unlikely() to BUG_ON() Scott Wood
2011-01-27 20:32 ` David Daney
2011-01-28 9:05 ` David Laight
[not found] ` <AE90C24D6B3A694183C094C60CF0A2F6D8AC2D__37237.0892241181$1296205746$gmane$org@saturn3.aculab.com>
2011-01-28 10:14 ` Andreas Schwab
2011-01-28 11:02 ` Coly Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D41B213.4070606@caviumnetworks.com \
--to=ddaney@caviumnetworks$(echo .)com \
--cc=bosong.ly@taobao$(echo .)com \
--cc=jeremy@goop$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=xiyou.wangcong@gmail$(echo .)com \
--cc=yong.zhang0@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox