On 2014-07-10 11:33, Dan Carpenter wrote: > On Wed, Jul 09, 2014 at 11:31:45PM +0200, Thomas Hellstr?m wrote: >>> Speaking of verbose, all the likely/unlikely annotations should be >>> removed. >> Is this your personal opinion or has there been some kind of kernel >> developer agreement not to add this annotation and remove it from >> the kernel tree? If not, I prefer to keep it. > It obviously makes the code less readable. It makes a small speedup if > the code is called 10000 times with the and the expected value is true > every time. If more than 1 out of 10000 values is unexpected then it is > a slow down.
You may be right, but most people citicising branch prediction hints tend to stare blindly at probabilities and forget about fastpath optimization where you don't care at all about the execution speed of the slowpath and therefore hint the compiler to take the fastpath branch regardless of probabilities. My guess is it would be pretty hard to do that incorrectly. I agree, however that readability may be more important than the fastpath execution speed gained from this. But in my case not so much that I spontaneously feel like removing all branch prediction hints from the vmwgfx driver. > > There are two rules of thumb for likely/unlikely: > > 1) Don't use it in the drivers/ directory. > 2) Or don't use it without benchmarking it. Could you point me to a document or some sort of reference? Thanks, Thomas