* Re: [PATCH 1/7] MIPS: add unlikely() to BUG_ON()
[not found] ` <1296130356-29896-2-git-send-email-bosong.ly@taobao.com>
@ 2011-01-27 17:50 ` David Daney
2011-01-28 10:41 ` Coly Li
0 siblings, 1 reply; 2+ messages in thread
From: David Daney @ 2011-01-27 17:50 UTC (permalink / raw)
To: Coly Li; +Cc: linux-kernel, Wang Cong, Yong Zhang, linux-mips, Ralf Baechle
Please Cc: linux-mips@linux-mips.org for MIPS patches.
On 01/27/2011 04:12 AM, Coly Li wrote:
> 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@taobao.com>
> Cc: David Daney<ddaney@caviumnetworks.com>
> Cc: Wang Cong<xiyou.wangcong@gmail.com>
> Cc: Yong Zhang<yong.zhang0@gmail.com>
> ---
> 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))
>
NAK.
__BUG_ON() expands to a single instruction. Frobbing about with
unlikely() will have no effect on the generated code and is thus
gratuitous code churn.
David Daney
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 1/7] MIPS: add unlikely() to BUG_ON()
2011-01-27 17:50 ` [PATCH 1/7] MIPS: add unlikely() to BUG_ON() David Daney
@ 2011-01-28 10:41 ` Coly Li
0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2011-01-28 10:41 UTC (permalink / raw)
To: David Daney
Cc: Coly Li, linux-kernel, Wang Cong, Yong Zhang, linux-mips,
Ralf Baechle
On 2011年01月28日 01:50, David Daney Wrote:
> Please Cc: linux-mips@linux-mips.org for MIPS patches.
>
> On 01/27/2011 04:12 AM, Coly Li wrote:
>> 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@taobao.com>
>> Cc: David Daney<ddaney@caviumnetworks.com>
>> Cc: Wang Cong<xiyou.wangcong@gmail.com>
>> Cc: Yong Zhang<yong.zhang0@gmail.com>
>> ---
>> 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))
>>
>
> NAK.
>
> __BUG_ON() expands to a single instruction. Frobbing about with unlikely() will have no effect on the generated code and
> is thus gratuitous code churn.
>
Since unlikely() in arch implemented BUG_ON() is gratuitous, using unlikely() in kernel code like BUG_ON(unlikely(...))
for arch implemented BUG_ON is unwelcome neither.
The NAK makes sense, thanks for your reply.
Coly
--
Coly Li
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-28 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1296130356-29896-1-git-send-email-bosong.ly@taobao.com>
[not found] ` <1296130356-29896-2-git-send-email-bosong.ly@taobao.com>
2011-01-27 17:50 ` [PATCH 1/7] MIPS: add unlikely() to BUG_ON() David Daney
2011-01-28 10:41 ` Coly Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox