On Sep 26, 2007, at 09:40:20, Erez Zadok wrote:
In message <[email protected]>, "Kok, Auke" writes:
I've been told several times that adding these is almost always
bogus - either it messes up the CPU branch prediction or the
compiler/CPU just does a lot better at finding the right way
without these hints.
Adding them as a blanket seems rather strange. Have you got any
numbers that this really improves performance?
Auke, that's a good question, but I found it hard to find any info
about it. There's no discussion on it in Documentation/, and very
little I could find elsewhere. I did see one url explaining what
un/likely does precisely, but no guidelines. My understanding is
that it can improve performance, as long as it's used carefully
(otherwise it may hurt performance).
Hmm, even still I agree with Auke, you probably use it too much.
Recently we've done a full audit of the entire code, and added un/
likely where we felt that the chance of succeeding is 95% or better
(e.g., error conditions that should rarely happen, and such).
Actually due to the performance penalty on some systems I think you
only want to use it if the chance of succeeding is 99% or better, as
the benefit if predicted is a cycle or two and the harm if
mispredicted can be more than 50 cycles, depending on the CPU. You
should also remember than in filesystems many "failures" are
triggered by things like the ld.so library searches, where it
literally calls access() 20 different times on various possible paths
for library files, failing the first 19. It does this once for each
necessary library.
Typically you only want to add unlikely() or likely() for about 2
reasons:
(A) It's a hot path and the unlikely case is just going to burn a
bunch of CPU anyways
(B) It really is extremely unlikely that it fails (Think physical
hardware failure)
Anything else is just bogus.
Cheers,
Kyle Moffett
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]