From: Andi Kleen <andi@firstfloor.org>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: Russell Leighton <russ@elegant-software.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: OT: Does Linux have any "Perfect Code"
Date: Thu, 15 Nov 2007 08:43:46 +0100 [thread overview]
Message-ID: <p73mytgc5sd.fsf@bingen.suse.de> (raw)
In-Reply-To: <473BE75B.9070701@cosmosbay.com> (Eric Dumazet's message of "Thu\, 15 Nov 2007 07\:29\:47 +0100")
Eric Dumazet <dada1@cosmosbay.com> writes:
>
> http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/os/timers.c#1106
>
> I would say this code was OK 10 years ago.
I would have expected 1997 compilers to already do these standard muliplication
optimizations.
> Now that a processor (say an Opteron in 64 bits mode, used on SUN
> hardware), can perform a multiply in few cycles, ts2hrt() could use a
> normal multiply and an addition.
To be fair Linux runs on a lot of CPUs which are not quite as fast
at multiplying as an Opteron, especially not for 64bit multiplies.
So some optimizations might be still a good idea. For divisions
at least Linux also actively does this.
On the other hand compilers also get worse. Modern gccs now turn
while (nsec >= NANOSEC) {
nsec -= NANOSEC;
sec++;
}
into a division which is actually much slower. Or insert unnecessary
cache misses randomly. See the recent gcc thread safety discussion
where it turned out that the thread breaking optimization is actually
more a general pessimization.
-Andi
next prev parent reply other threads:[~2007-11-15 7:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-15 1:21 OT: Does Linux have any "Perfect Code" Russell Leighton
2007-11-15 1:33 ` David Miller
2007-11-15 6:29 ` Eric Dumazet
2007-11-15 7:11 ` David Miller
2007-11-15 7:43 ` Andi Kleen [this message]
2007-11-15 8:27 ` Philippe Elie
2007-11-15 13:16 ` Michael Gerdau
2007-11-15 15:10 ` Daniel Barkalow
2007-11-17 8:44 ` Geert Uytterhoeven
2007-11-15 17:05 ` Chris Friesen
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=p73mytgc5sd.fsf@bingen.suse.de \
--to=andi@firstfloor.org \
--cc=dada1@cosmosbay.com \
--cc=linux-kernel@vger.kernel.org \
--cc=russ@elegant-software.com \
/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