简体   繁体   English

vDSO:为什么 linux 只将它们用于与时间相关的功能?

[英]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:这让人想到两个问题:

  • Are there any other system calls that are planned to use vDSO interface soon?是否有任何其他系统调用计划很快使用 vDSO 接口?
  • Were 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?是否有任何特定类型的应用程序对此有帮助? If so, what kind of application and by how much?如果是这样,什么样的应用程序和多少?

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.但我想知道这里是否有人有比猜测更具体的细节。

Reasons Behind the vDSO vDSO 背后的原因

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 添加功能有两个原因/限制:

  1. The functions must be providing information which is not secret功能必须提供非秘密信息
  2. The functions must be used so much that it is really worth moving to the vDSO必须大量使用这些功能,以至于确实值得迁移到 vDSO

Available Functions可用功能

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:所以总的来说,我们看到呼吁:

  • Signal信号
  • System/Kernel系统/内核
  • Time时间
  • CPU/Cache CPU/缓存
  • Processes流程

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.

相关问题 为什么Linux在目录而不是read()上使用getdents()? - Why does Linux use getdents() on directories instead of read()? 为什么ObservableCollection具有与用户界面相关的限制? - Why does ObservableCollection have a user interface related limitation? 为什么仿真必须实时完成? - Why does emulation have to be done in real time? 为什么要分组相关测试 - Why to group related tests 如果函数不使用全局数据,为什么它们在机器代码级别是线程安全的? - Why are functions thread safe on a machine code level if they don't use global data? 为什么 win32 API 函数没有重载而是使用 Ex 作为后缀? - Why don't win32 API functions have overloads and instead use Ex as suffix? 为什么在记事本 window 中键入时鼠标 cursor 消失,但在浏览器或 cmd 中没有? 哪个 Win API 函数显示它以及如何显示? - Why does the mouse cursor disappear when typing inside a notepad window, but not in a browser or cmd? Which Win API functions display it and how? 为什么Kohana的ORM使用工厂模式? - Why does Kohana's ORM use the factory pattern? 键入URL时,为什么网页需要很长时间才能加载到手机的浏览器中? - When I key in a URL, why does the webpage take a long time to load on my mobile phone's browser? 根据Clean Architecture,实体不存在,只有用例存在于SNS上吗? - Entity does not exist and only use case exist on SNS according to Clean Architecture?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM