When reading the Linux source code, we often find likely and unlikely, which are defined under Compiler.h.
#define LIKELY (x)__builtin_expect (!! (x), 1)
#define UNLIKELY (x)__builtin_expect (!! (x), 0)
Here we need to first understand __builtin_expect:# define __builtin_expect (x, Expected_value) (x)
So it can be found that likely (x) and x are a meaning, so why bother with such a strength to complicate it?
This is to improve the speed of the system, when the likely instead of direct judgment, the GCC compiler will know that the likely branch is more likely to occur, then we put it in front, so that the cache hit probability will increase, and if it is unlikely, Then this thing may not happen, we should put it in the back, through such a mechanism, is to let the upper layer will be more likely to occur in the awareness of the system to improve the overall speed of operation, from the whole system will have a certain optimization
Linux-kernel of likely and unlikely