大网数据广告活动
服务器运维问答

Do system calls in x86_64 linux still generate interrupts?

· 52CE 我爱测

In older versions of linux architecture, system calls would always generate an interrupt during their execution. They would be executed by setting the system call number into %eax and parameters into %ebx, %ecx and so on, followe…

问题原文

原帖链接 · arrwags · CC BY-SA 3.0

In older versions of linux architecture, system calls would always generate an interrupt during their execution. They would be executed by setting the system call number into %eax and parameters into %ebx, %ecx and so on, followed by issuing the specific interrupt int 0x80. Thus, system calls could be said to be a common cause of software interrupts on a system.

However, on modern architectures of x86_64 there is a specific system call instruction "syscall", which bypasses the need to use interrupt 0x80, and thus, the interrupt descriptor table at all. While I believe the previous method of generating an interrupt for syscall is still supported, the syscall instruction seems to be the way it's done in practice.

Thus, my question is: Is it no longer correct to say that system calls generate interrupts? Would a system call still increment the number seen in the "interrupts" column output of vmstat, for example?

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 3.0

Yes, modern C code for Linux x86_64 uses the syscall instruction, see for example glibc sysdeps/unix/sysv/linux/x86_64/syscall.S. No, this does not mean system call interrupts go away, due to compatibility.

https://www.kernel.org/doc/Documentation/x86/entry_64.txt

The x86 architecture has quite a few different ways to jump into kernel code. Most of these entry points are registered in arch/x86/kernel/traps.c and implemented in arch/x86/entry/entry_64.S for 64-bit, arch/x86/entry/entry_32.S for 32-bit and finally arch/x86/entry/entry_64_compat.S which implements the 32-bit compatibility syscall entry points and thus provides for 32-bit processes the ability to execute syscalls when running on 64-bit kernels.

The IDT vector assignments are listed in arch/x86/include/asm/irq_vectors.h.

Some of these entries are:

  • system_call: syscall instruction from 64-bit code.

  • entry_INT80_compat: int 0x80 from 32-bit or 64-bit code; compat syscall either way.

  • entry_INT80_compat, ia32_sysenter: syscall and sysenter from 32-bit code

And for read only syscalls (gettimeofday) there is vDSO which does not enter kernel mode at all.

system calls can be profiled in a few ways, such as ftrace or eBPF. In addition to being obsolete in 64 bit mode, interrupts happen for reasons other than system calls.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。