Amit: How new-lines affect the Linux kernel performance
Amit: How new-lines affect the Linux kernel performance
Nadav Amit decided to dig into why some small kernel functions were not
being inlined by GCC; the result is a detailed
investigation into how these things can go wrong. "Ignoring the
assembly shenanigans that this code uses, we can see that in practice it
generates a single ud2 instruction. However, the compiler considers this
code to be 'big' and consequently oftentimes does not inline functions that
use WARN() or similar functions.
The reason turns to be the newline characters (marked as '\n' above). The
kernel compiler, GCC, is unaware to the code size that will be generated by
the inline assembly. It therefore tries to estimate its size based on
newline characters and statement separators (';' on x86).
"