Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Willy Tarreau
On Tue, Feb 19, 2008 at 10:28:46AM +0100, Andi Kleen wrote: > > Sometimes, for performance critical paths, I would like gcc to be dumb and > > follow *my* code and not its hard-coded probabilities. > > If you really want that, simple: just disable optimization @) already tried. It fixed some dif

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Nick Piggin
On Tuesday 19 February 2008 20:57, Andi Kleen wrote: > On Tue, Feb 19, 2008 at 08:46:46PM +1100, Nick Piggin wrote: > > I think it was just a simple context switch benchmark, but not lmbench > > (which I found to be a bit too variable). But it was a long time ago... > > Do you still have it? > > I

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Andi Kleen
On Tue, Feb 19, 2008 at 08:46:46PM +1100, Nick Piggin wrote: > On Tuesday 19 February 2008 20:25, Andi Kleen wrote: > > On Tue, Feb 19, 2008 at 01:33:53PM +1100, Nick Piggin wrote: > > > > I actually once measured context switching performance in the scheduler, > > > and removing the unlikely hi

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Nick Piggin
On Tuesday 19 February 2008 20:25, Andi Kleen wrote: > On Tue, Feb 19, 2008 at 01:33:53PM +1100, Nick Piggin wrote: > > I actually once measured context switching performance in the scheduler, > > and removing the unlikely hint for testing RT tasks IIRC gave about 5% > > performance drop. > > OT:

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Andi Kleen
> Sometimes, for performance critical paths, I would like gcc to be dumb and > follow *my* code and not its hard-coded probabilities. If you really want that, simple: just disable optimization @) > Maybe one thing we would need would be the ability to assign probabilities > to each branch based

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-19 Thread Andi Kleen
On Tue, Feb 19, 2008 at 01:33:53PM +1100, Nick Piggin wrote: > On Tuesday 19 February 2008 01:39, Andi Kleen wrote: > > Arjan van de Ven <[EMAIL PROTECTED]> writes: > > > you have more faith in the authors knowledge of how his code actually > > > behaves than I think is warranted :) > > > > iirc t

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Adrian Bunk
On Tue, Feb 19, 2008 at 08:46:03AM +1100, Michael Ellerman wrote: > On Mon, 2008-02-18 at 16:13 +0200, Adrian Bunk wrote: > > On Mon, Feb 18, 2008 at 03:01:35PM +0100, Geert Uytterhoeven wrote: > > > On Mon, 18 Feb 2008, Adrian Bunk wrote: > > > > > > > > This means it generates faster code with a

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Nick Piggin
On Tuesday 19 February 2008 16:58, Willy Tarreau wrote: > On Tue, Feb 19, 2008 at 01:33:53PM +1100, Nick Piggin wrote: > > > Note in particular the last predictors; assuming branch ending > > > with goto, including call, causing early function return or > > > returning negative constant are not tak

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Willy Tarreau
On Tue, Feb 19, 2008 at 01:33:53PM +1100, Nick Piggin wrote: > > Note in particular the last predictors; assuming branch ending > > with goto, including call, causing early function return or > > returning negative constant are not taken. Just these alone > > are likely 95+% of the unlikelies in th

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Nick Piggin
On Tuesday 19 February 2008 13:40, Arjan van de Ven wrote: > On Tue, 19 Feb 2008 13:33:53 +1100 > > Nick Piggin <[EMAIL PROTECTED]> wrote: > > Actually one thing I don't like about gcc is that I think it still > > emits cmovs for likely/unlikely branches, which is silly (the gcc > > developers seem

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Arjan van de Ven
On Tue, 19 Feb 2008 13:33:53 +1100 Nick Piggin <[EMAIL PROTECTED]> wrote: > > Actually one thing I don't like about gcc is that I think it still > emits cmovs for likely/unlikely branches, which is silly (the gcc > developers seem to be in love with that instruction). If that goes > away, then bra

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Nick Piggin
On Tuesday 19 February 2008 01:39, Andi Kleen wrote: > Arjan van de Ven <[EMAIL PROTECTED]> writes: > > you have more faith in the authors knowledge of how his code actually > > behaves than I think is warranted :) > > iirc there was a mm patch some time ago to keep track of the actual > unlikely

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Michael Ellerman
On Mon, 2008-02-18 at 16:13 +0200, Adrian Bunk wrote: > On Mon, Feb 18, 2008 at 03:01:35PM +0100, Geert Uytterhoeven wrote: > > On Mon, 18 Feb 2008, Adrian Bunk wrote: > > > > > > This means it generates faster code with a current gcc for your platform. > > > > > > But a future gcc might e.g. rep

Re: [Cbe-oss-dev] [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Andrew Pinski
On Feb 18, 2008 6:01 AM, Geert Uytterhoeven <[EMAIL PROTECTED]> wrote: > > This means it generates faster code with a current gcc for your platform. > > > > But a future gcc might e.g. replace the whole loop with a division > > (gcc SVN head (that will soon become gcc 4.3) already does > > transfor

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Arjan van de Ven
On Mon, 18 Feb 2008 13:11:06 -0500 [EMAIL PROTECTED] wrote: > On Mon, 18 Feb 2008 14:27:10 GMT, David Howells said: > > > __builtin_expect() is useful on FRV where you _have_ to give each > > branch and conditional branch instruction a measure of probability > > whether the branch will be taken.

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Valdis . Kletnieks
On Mon, 18 Feb 2008 14:27:10 GMT, David Howells said: > __builtin_expect() is useful on FRV where you _have_ to give each branch and > conditional branch instruction a measure of probability whether the branch > will be taken. What does gcc do the 99.998% of the time we don't have likely/unlikely

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Roel Kluin
David Howells wrote: > Geert Uytterhoeven <[EMAIL PROTECTED]> wrote: > >> Hence shouldn't we ask the gcc people what's the purpose of >> __builtin_expect(), if it doesn't live up to its promise? > > __builtin_expect() is useful on FRV where you _have_ to give each branch and > conditional branch

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Andi Kleen
Arjan van de Ven <[EMAIL PROTECTED]> writes: > you have more faith in the authors knowledge of how his code actually behaves > than I think is warranted :) iirc there was a mm patch some time ago to keep track of the actual unlikely values at runtime and it showed indeed some wrong ones. But the

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread David Howells
Geert Uytterhoeven <[EMAIL PROTECTED]> wrote: > Hence shouldn't we ask the gcc people what's the purpose of > __builtin_expect(), if it doesn't live up to its promise? __builtin_expect() is useful on FRV where you _have_ to give each branch and conditional branch instruction a measure of probabil

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Adrian Bunk
On Mon, Feb 18, 2008 at 03:01:35PM +0100, Geert Uytterhoeven wrote: > On Mon, 18 Feb 2008, Adrian Bunk wrote: > > > > This means it generates faster code with a current gcc for your platform. > > > > But a future gcc might e.g. replace the whole loop with a division > > (gcc SVN head (that will s

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Geert Uytterhoeven
On Mon, 18 Feb 2008, Adrian Bunk wrote: > On Sun, Feb 17, 2008 at 10:50:03PM +1100, Michael Ellerman wrote: > > On Sat, 2008-02-16 at 10:39 -0800, Arjan van de Ven wrote: > >... > > > for mordern (last 10 years) x86 cpus... the cpu branchpredictor is better > > > than the coder in general. Same for

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-18 Thread Adrian Bunk
On Sun, Feb 17, 2008 at 10:50:03PM +1100, Michael Ellerman wrote: > On Sat, 2008-02-16 at 10:39 -0800, Arjan van de Ven wrote: >... > > for mordern (last 10 years) x86 cpus... the cpu branchpredictor is better > > than the coder in general. Same for most other architectures. > > > > unlikely() cre

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-17 Thread Michael Ellerman
On Sat, 2008-02-16 at 10:39 -0800, Arjan van de Ven wrote: > > >> > you found a great set of bugs.. > > >> > but to be honest... I suspect it's just best to remove unlikely > > >> > altogether for these cases; unlikely() is almost a > > >> > go-faster-stripes thing, and if you don't know how to use

Re: [Cbe-oss-dev] [PATCH 1/3] Fix Unlikely(x) == y

2008-02-17 Thread Willy Tarreau
On Sun, Feb 17, 2008 at 01:45:23AM -0800, Andrew Pinski wrote: > On Feb 16, 2008 9:58 AM, Willy Tarreau <[EMAIL PROTECTED]> wrote: > > Last but not least, gcc 4 tends to emit stupid checks, to the point that I > > have replaced unlikely(x) with (x) in my code when gcc >= 4 is detected. > > What >

Re: [Cbe-oss-dev] [PATCH 1/3] Fix Unlikely(x) == y

2008-02-17 Thread Andrew Pinski
On Feb 16, 2008 9:58 AM, Willy Tarreau <[EMAIL PROTECTED]> wrote: > Last but not least, gcc 4 tends to emit stupid checks, to the point that I > have replaced unlikely(x) with (x) in my code when gcc >= 4 is detected. What > I observe is that the following code : > > if (unlikely(p == NULL)) ..

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Geoff Levand
On 02/16/2008 08:08 AM, Roel Kluin wrote: > The patch below was not yet tested. If it's correct as it is, please comment. > - if (unlikely(plug) == NO_IRQ) { > + if (unlikely(plug == NO_IRQ)) { A good catch! I'll put it in with some other 2.6.25 bug fixes. -Geoff -- To unsubscribe from

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Arjan van de Ven
On Sat, 16 Feb 2008 10:31:26 -0800 Geoff Levand <[EMAIL PROTECTED]> wrote: > On 02/16/2008 09:42 AM, Arjan van de Ven wrote: > > On Sat, 16 Feb 2008 18:33:16 +0100 > > Willy Tarreau <[EMAIL PROTECTED]> wrote: > > > >> On Sat, Feb 16, 2008 at 09:25:52AM -0800, Arjan van de Ven wrote: > >> > On Sat

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Geoff Levand
On 02/16/2008 09:42 AM, Arjan van de Ven wrote: > On Sat, 16 Feb 2008 18:33:16 +0100 > Willy Tarreau <[EMAIL PROTECTED]> wrote: > >> On Sat, Feb 16, 2008 at 09:25:52AM -0800, Arjan van de Ven wrote: >> > On Sat, 16 Feb 2008 17:08:01 +0100 >> > Roel Kluin <[EMAIL PROTECTED]> wrote: >> > >> > > The

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Arjan van de Ven
On Sat, 16 Feb 2008 18:58:49 +0100 > > If you think unlikely() means something else, we should fix what it > > maps to towards gcc ;) (to.. be empty ;) > > eventhough the gcc docs say it's just a hint to help the compiler > optimize the branch it takes by default, I too have noticed that it > more

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Willy Tarreau
On Sat, Feb 16, 2008 at 09:42:26AM -0800, Arjan van de Ven wrote: > On Sat, 16 Feb 2008 18:33:16 +0100 > Willy Tarreau <[EMAIL PROTECTED]> wrote: > > > On Sat, Feb 16, 2008 at 09:25:52AM -0800, Arjan van de Ven wrote: > > > On Sat, 16 Feb 2008 17:08:01 +0100 > > > Roel Kluin <[EMAIL PROTECTED]> wr

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Arjan van de Ven
On Sat, 16 Feb 2008 18:33:16 +0100 Willy Tarreau <[EMAIL PROTECTED]> wrote: > On Sat, Feb 16, 2008 at 09:25:52AM -0800, Arjan van de Ven wrote: > > On Sat, 16 Feb 2008 17:08:01 +0100 > > Roel Kluin <[EMAIL PROTECTED]> wrote: > > > > > The patch below was not yet tested. If it's correct as it is,

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Willy Tarreau
On Sat, Feb 16, 2008 at 09:25:52AM -0800, Arjan van de Ven wrote: > On Sat, 16 Feb 2008 17:08:01 +0100 > Roel Kluin <[EMAIL PROTECTED]> wrote: > > > The patch below was not yet tested. If it's correct as it is, please > > comment. --- > > Fix Unlikely(x) == y > > > > you found a great set of bug

Re: [PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Arjan van de Ven
On Sat, 16 Feb 2008 17:08:01 +0100 Roel Kluin <[EMAIL PROTECTED]> wrote: > The patch below was not yet tested. If it's correct as it is, please > comment. --- > Fix Unlikely(x) == y > you found a great set of bugs.. but to be honest... I suspect it's just best to remove unlikely altogether for

[PATCH 1/3] Fix Unlikely(x) == y

2008-02-16 Thread Roel Kluin
The patch below was not yet tested. If it's correct as it is, please comment. --- Fix Unlikely(x) == y Signed-off-by: Roel Kluin <[EMAIL PROTECTED]> --- diff --git a/arch/powerpc/platforms/ps3/interrupt.c b/arch/powerpc/platforms/ps3/interrupt.c index 3a6db04..a14e5cd 100644 --- a/arch/powerpc/pl