The SYSCALL instruction is said to be the 64-bit version of INT 0X80, however it's still possible to use the latter in 64-bit code (although strace decodes it wrong because of the 64-bit ABI I guess) which usually goes through a "legacy entry". But there's something I don't quite understand, why is the SYSCALL instruction faster?
1 Answer
The short answer is that syscall
has less overhead than int 0x80
.
For more details on why this is the case, see the accepted answer to Intel x86 vs x64 system call, where a nearly identical question was asked:
I'm told that syscall is lighter and faster than generating a software interrupt. Why it is faster on x64 than x86, and can I make a system call on x64 using int 80h?
See also:
- Intel P6 vs P7 system call performance
- this email thread discusses the observed slowdown on certain Intel CPUs caused by the overhead associated with
int 0x80
- this email thread discusses the observed slowdown on certain Intel CPUs caused by the overhead associated with
Sysenter Based System Call Mechanism in Linux 2.6
It was found out that this software interrupt method [int 0x80] was much slower on Pentium IV processors. To solve this issue, Linus implemented an alternative system call mechanism to take advantage of SYSENTER/SYSEXIT instructions provided by all Pentium II+ processors.
The Linux kernel, 4.6 Sysenter and the vsyscall page (2003)
It has been observed that a 2 GHz Pentium 4 was much slower than an 850 MHz Pentium III on certain tasks, and that this slowness is caused by the very large overhead of the traditional
int 0x80
interrupt on a Pentium 4. Some models of the i386 family do have faster ways to enter the kernel. On Pentium II there is thesysenter
instruction. Also AMD has asyscall
instruction.