[英]vDSO: why does linux use them only for time-related functions?
Just searched the Linux kernel for vdso hooks (eg found this at kernel.org), and it seems to be currently used mostly for time-related system calls.刚刚在 Linux 内核中搜索了 vdso 钩子(例如在 kernel.org 上找到了这个),它目前似乎主要用于与时间相关的系统调用。 This brings two questions to mind:
这让人想到两个问题:
clock_gettime()
really becoming a large enough bottleneck to motivate the design of vDSO? clock_gettime()
真的成为一个足够大的瓶颈来激发 vDSO 的设计吗? Is there any particular kind of application for which this was helpful? It just seemed odd to design a new kernel syscall interface for just time lookups.为时间查找设计一个新的内核系统调用接口似乎很奇怪。 I am guessing it helps high-performance servers for things like timestamping request-responses and logs.
我猜它可以帮助高性能服务器处理诸如时间戳请求响应和日志之类的事情。 But I want to know if anybody here has more concrete details than just guesses.
但我想知道这里是否有人有比猜测更具体的细节。
The vDSO manual page has this to say about the reason for creating this special library: vDSO手册页有关于创建这个特殊库的原因的说明:
Why does the vDSO exist at all?
为什么 vDSO 会存在? There are some system calls the kernel provides that user-space code ends up using frequently, to the point that such calls can dominate overall performance.
内核提供了一些系统调用,用户空间代码最终会频繁使用,以至于这些调用可以支配整体性能。 This is due both to the frequency of the call as well as the context- switch overhead that results from exiting user space and entering the kernel.
这是由于调用频率以及退出用户空间和进入内核导致的上下文切换开销。
Further reading will tell you of the various strategies used to make it possible to share data between the kernel and user space.进一步阅读将告诉您用于在内核和用户空间之间共享数据的各种策略。 Especially:
尤其:
This information is also not secret —any application in any privilege mode (root or any unprivileged user) will get the same answer.
这个信息也不是秘密——任何特权模式下的任何应用程序(root 或任何非特权用户)都会得到相同的答案。
Note: Emphasis mine.注意:强调我的。
That tells us that the data offered through that vDSO interface has to be public, something that any process running on the system would anyway have access to.这告诉我们,通过该 vDSO 接口提供的数据必须是公开的,系统上运行的任何进程无论如何都可以访问这些数据。 This is obviously very important.
这显然非常重要。
So to recap we have two reasons/constraints for adding functions to the vDSO:因此,回顾一下我们向 vDSO 添加功能有两个原因/限制:
If you look further in the vDSO manual page, you will notice lists of functions supported by various implementations (See the * ARCHITECTURE-SPECIFIC NOTES section).如果您进一步查看 vDSO 手册页,您会注意到各种实现支持的功能列表(请参阅 * ARCHITECTURE-SPECIFIC NOTES部分)。 This gives us another piece of information: the Linux version when such and such was implemented/accessible.
这为我们提供了另一条信息:实现/访问某某时的 Linux 版本。 The very first available implementation was in Linux 2.5 ( late 2001 , note also that was a development version, so the first user available version was 2.6.1 in 2003).
第一个可用的实现是在 Linux 2.5 中( 2001 年末,还要注意那是一个开发版本,所以第一个用户可用的版本是 2003 年的 2.6.1)。
We find the following functions in the vDSO:我们在 vDSO 中找到以下功能:
sigreturn
rt_sigreturn
sigtramp
sigtramp32
sigtramp_rt32
sigtramp_rt64
syscall_via_break
syscall_via_epc
vsyscall
get_syscall_map
lws_entry
linux_gateway_entry
gettimeofday
clock_gettime
clock_gettime64
clock_getres
time
getcpu
get_tbfreq
sync_dicache
sync_dicache_p5
flush_icache
getpid
getppid
set_tid_address
set_thread_pointer
datapage_offset
So overall we see calls for:所以总的来说,我们看到呼吁:
For x86 processors, it is mostly limited to Time and CPU.对于 x86 处理器,它主要限于时间和 CPU。 In i386, there are signal related functions too.
在 i386 中,也有信号相关的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.