From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Jamie Lokier <jamie@shareable.org>
Cc: Pavel Machek <pavel@ucw.cz>, Dave Jones <davej@redhat.com>,
Mitchell Blank Jr <mitch@sfgoth.com>,
Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] oops_in_progress is unlikely()
Date: Wed, 10 Sep 2003 16:32:02 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.53.0309101619020.18924@chaos> (raw)
In-Reply-To: <20030910201240.GB24424@mail.jlokier.co.uk>
On Wed, 10 Sep 2003, Jamie Lokier wrote:
> Richard B. Johnson wrote:
> > cmpl $1, %eax
> > jz 1f
> > jc 2f
> > call do_default
> > jmp more_code
> > 1: call do_something_if_equal
> > jmp more_code
> > 2: call do_something_if_less
> > more_code:
> >
> > In every case, one has to jump around code for other execution paths
> > except the last, where you have to jump on condition anyway. There
> > is no free liunch, and the straight-through route, do_default
> > uas just as many jumps as the last.
>
> Here is your code optimised for no jumps in the "do_default" case:
>
> cmpl $1,%eax
> jbe 1f
> call do_default
> more_code:
> .subsection 1
> 1: jnz 2f
> call do_something_if_equal
> jmp more_code
> 2: call do_something_if_less
> jmp more_code
> .previous
>
You are a magician! Putting in a .subsection to hide the jump
is absolute bullshit. The built-in macros, ".subsection", and
".previous" just made the damn linker do the fixup. You just
did a long jump, out of the current code-stream, into some
other section. Then you jumped back. Hell of an optimization!
Might even reload the cache if you are lucky! Linker tricks
won't work for me. Also, putting some address on the stack
and executing 'ret' emulate a jump won't impress me either.
In any real code, only the last instruction in a procedure
gets to have a jump optimized away. Most of the times you
can't even do that because you need to restore different
stack-levels from different code paths (one reason to use
a frame-pointer, but still not good enough).
> > > How would you optimise it, if you were writing assembly language yourself?
>
> > I did. And I do this for a living. And, after 30 years of this shit
> > they still haven't fired me. Learn something. I'm pissed.
>
> It's ok to be pissed. I'd be pissed too :)
>
> *ducks*
>
> Enjoy :)
> -- Jame
>
Sure do. I love it. I even get paid for this kind of stuff!
Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (794.73 BogoMips).
Note 96.31% of all statistics are fiction.
next prev parent reply other threads:[~2003-09-10 20:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-07 6:42 Mitchell Blank Jr
2003-09-07 22:13 ` Dave Jones
2003-09-10 14:20 ` Pavel Machek
2003-09-10 14:23 ` Dave Jones
2003-09-10 15:29 ` Pavel Machek
2003-09-10 16:07 ` Richard B. Johnson
2003-09-10 18:31 ` Jamie Lokier
2003-09-10 18:58 ` Richard B. Johnson
2003-09-10 19:02 ` Pavel Machek
2003-09-10 20:12 ` Jamie Lokier
2003-09-10 20:32 ` Richard B. Johnson [this message]
2003-09-10 21:27 ` Pavel Machek
2003-09-10 21:52 ` Jamie Lokier
2003-09-10 21:46 ` Jamie Lokier
2003-09-12 5:12 ` Mitchell Blank Jr
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=Pine.LNX.4.53.0309101619020.18924@chaos \
--to=root@chaos.analogic.com \
--cc=akpm@osdl.org \
--cc=davej@redhat.com \
--cc=jamie@shareable.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mitch@sfgoth.com \
--cc=pavel@ucw.cz \
/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
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
all inboxes | Powered by JetHome®