The assembly code of the Linux kernel is complicated and poorly maintained, according to some Linux developers. So a lot of code is rewritten in C.
Linux kernel 4.1 comes with many x86 ASM code changes and one of the developers; Andy Lutomirski explains what kind of issues he encountered.
“The exit-to-usermode code is copied in several places and is written
in a nasty combination of asm and C. It’s not at all clear what
it’s supposed to do, and the way it’s structured makes it very hard
to work with. For example, it’s not even clear why syscall exit
hooks are called only once per syscall right now. (It seems to be a
side effect of the way that rdi and rdx are handled in the asm loop,
and it seems reliable, but it’s still pointlessly complicated.) The
existing code also makes context tracking overly complicated and
hard to understand. Finally, it’s nearly impossible for anyone to
change what happens on exit to usermode, since the existing code is
so fragile.”, Andy Lutomirski explains.
Still a lot of work has to be done and as soon as Linux kernel 4.1 will be released (probably after the coming weekend) you will notice a slight performance gain.
Read more about the Linux kernel code cleanup here.