在支持系统调用和系统调用的x86-64英特尔系统上,什么是来自vanilla内核的64位用户代码的“最快”系统调用?
特别是,它必须是一个系统调用来运行syscall / sysret用户< - > kernel transition1,但是除此之外的工作量最少.它甚至不需要进行系统调用本身:某种类型的早期错误从未调度到内核端的特定调用,这是好的,只要它不会因为这样而走慢路径.
这样的调用可用于估计原始系统调用和系统调用开销,而与调用所做的任何工作无关.
1特别是,这排除了似乎是系统调用但在VDSO中实现的事物(例如,clock_gettime)或由运行时缓存(例如,getpid).
解决方法
一个不存在的,因此快速返回-ENOSYS.
来自arch / x86 / entry / entry_64.S:
- #if __SYSCALL_MASK == ~0
- cmpq $__NR_syscall_max,%rax
- #else
- andl $__SYSCALL_MASK,%eax
- cmpl $__NR_syscall_max,%eax
- #endif
- ja 1f /* return -ENOSYS (already in pt_regs->ax) */
- movq %r10,%rcx
- /*
- * This call instruction is handled specially in stub_ptregs_64.
- * It might end up jumping to the slow path. If it jumps,RAX
- * and all argument registers are clobbered.
- */
- #ifdef CONFIG_RETPOLINE
- movq sys_call_table(,%rax,8),%rax
- call __x86_indirect_thunk_rax
- #else
- call *sys_call_table(,8)
- #endif
- .Lentry_SYSCALL_64_after_fastpath_call:
- movq %rax,RAX(%rsp)
- 1: