SCX eBPF macro likely
The likely
macro hints to the compiler that an expression is likely to be true. This can help the compiler optimize the generated code.
Definition
#define likely(x) __builtin_expect(!!(x), 1)
Usage
The likely
macro can be used on boolean expressions, like in if
statements, where you expect the expression to be true most of the time. This can help the compiler optimize the generated instructions.
An example of such an optimization would be to place instructions for the likely code path close to the conditional jump to improve instruction cache locality.
Example
if (likely(x > 0)) {
// Likely code path
} else {
// Unlikely code path
}