LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Coly Li <i@coly.li>
To: David Daney <ddaney@caviumnetworks.com>
Cc: Coly Li <bosong.ly@taobao.com>,
linux-kernel@vger.kernel.org,
Wang Cong <xiyou.wangcong@gmail.com>,
Yong Zhang <yong.zhang0@gmail.com>,
linux-mips <linux-mips@linux-mips.org>,
Ralf Baechle <ralf@linux-mips.org>
Subject: Re: [PATCH 1/7] MIPS: add unlikely() to BUG_ON()
Date: Fri, 28 Jan 2011 18:41:41 +0800 [thread overview]
Message-ID: <4D429D65.3020000@coly.li> (raw)
In-Reply-To: <4D41B06F.8070804@caviumnetworks.com>
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
next prev parent reply other threads:[~2011-01-28 10:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-27 12:12 [PATCH 0/6] use BUG_ON correctly, v2 Coly Li
2011-01-27 12:12 ` [PATCH 1/7] MIPS: add unlikely() to BUG_ON() Coly Li
2011-01-27 17:50 ` David Daney
2011-01-28 10:41 ` Coly Li [this message]
2011-01-27 12:12 ` [PATCH 2/7] PowerPC: " Coly Li
2011-01-27 17:57 ` David Daney
2011-01-27 20:04 ` 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
2011-01-27 12:12 ` [PATCH 3/7] dma: use BUG_ON correctly in iop-adma.c Coly Li
2011-01-27 12:12 ` [PATCH 4/7] dma: use BUG_ON correctly in mv_xor.c Coly Li
2011-01-27 12:12 ` [PATCH 5/7] dma: use BUG_ON correctly in ppc4xx/adam.c Coly Li
2011-01-27 12:12 ` [PATCH 6/7] wl_cfg80211.c: use BUG_ON correctly Coly Li
2011-01-27 12:12 ` [PATCH 7/7] scsi_lib.c: " 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=4D429D65.3020000@coly.li \
--to=i@coly.li \
--cc=bosong.ly@taobao.com \
--cc=ddaney@caviumnetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
--cc=xiyou.wangcong@gmail.com \
--cc=yong.zhang0@gmail.com \
--subject='Re: [PATCH 1/7] MIPS: add unlikely() to BUG_ON()' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).