[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0909122336330.12448@eddie.linux-mips.org>
Date: Sat, 12 Sep 2009 23:51:40 +0100 (BST)
From: "Maciej W. Rozycki" <macro@...ux-mips.org>
To: Daniel Walker <dwalker@...o99.com>
cc: Cyrill Gorcunov <gorcunov@...il.com>, Ingo Molnar <mingo@...e.hu>,
Julia Lawall <julia@...u.dk>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86: apic: convert BUG() to BUG_ON()
On Sat, 12 Sep 2009, Daniel Walker wrote:
> For one it condenses duplicate code (i.e. the if()). If the BUG_ON()
> macro gets updated with something new, all the users get the updates
> automatically. The other thing is your re-using potentially more
> advanced code that's inside the macro. In this case it's fairly trivial,
>
> #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
>
> So we're getting the benefit on the new "unlikely" in the apic code.
> unlikely/likely calls will usually allow the compiler to create smaller,
> and or, more optimized code.
For non-x86 platforms the use of the BUG_ON() macro may result in more
efficient code GCC may not be able to optimise to with if (...) BUG();.
For example the macro may expand to inline assembly with a conditional
trap instruction GCC would not emit for an if () clause. While GCC does
have a __builtin_trap() intrinsic that could be optimised if alone in a
conditional block, such usage may not be frequent enough for a dedicated
optimisation to be provided and build-time efficiency of the compiler does
matter too, so such an optimisation might be of too questionable a value
to incur an additional performance hit for the compiler.
Just a general note on patches of this kind, or to put it short, yes I
agree it's a good idea.
Maciej
--
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