简体   繁体   English

由于修复了最近公布的英特尔漏洞,gettimeofday()会变慢吗?

[英]Will gettimeofday() be slowed due to the fix to the recently announced Intel bug?

I have been estimating the impact of the recently announced Intel bug on my packet processing application using netmap . 我一直在估计最近宣布的英特尔错误对使用netmap的数据包处理应用程序的影响 So far, I have measured that I process about 50 packets per each poll() system call made, but this figure doesn't include gettimeofday() calls. 到目前为止,我已经测量过我每次poll()系统调用处理大约50个数据包,但这个数字不包括gettimeofday()调用。 I have also measured that I can read from a non-existing file descriptor (which is about the cheapest thing that a system call can do) 16.5 million times per second. 我还测量过我可以从一个不存在的文件描述符(这是系统调用可以做的最便宜的事情)中读取每秒1650万次。 My packet processing rate is 1.76 million packets per second, or in terms of system calls, 0.0352 million system calls per second. 我的数据包处理速率是每秒176万个数据包,或者就系统调用而言,每秒0.0352百万次系统调用。 This means performance reduction would be 0.0352 / 16.5 = 0.21333% if system call penalty doubles, hardly something I should worry about. 这意味着如果系统调用惩罚加倍,性能降低将为0.0352 / 16.5 = 0.21333%,这几乎不值得我担心。

However, my application may use gettimeofday() system calls quite often. 但是,我的应用程序可能经常使用gettimeofday()系统调用。 My understanding is that these are not true system calls, but rather implemented as virtual system calls, as described in What are vdso and vsyscall? 我的理解是,这些不是真正的系统调用,而是实现为虚拟系统调用,如什么是vdso和vsyscall中所述? .

Now, my question is, does the fix to the recently announced Intel bug (that may affect ARM as well and that probably won't affect AMD) slow down gettimeofday() system calls? 现在,我的问题是,对最近公布的英特尔错误(可能会影响ARM并且可能不会影响AMD)的修复是否会降低gettimeofday()系统调用的速度? Or is gettimeofday() an entirely different animal due to being implemented as a different kind of virtual system call? 或者gettimeofday()是一个完全不同的动物,因为它被实现为一种不同类型的虚拟系统调用?

In general, no. 一般来说,没有。

The current patches keep things like the vDSO pages mapped in user-space, and only change the behavior for the remaining vast majority of kernel-only pages which will no longer be mapped in user-space. 当前的补丁保留了用户空间中映射的vDSO页面之类的内容,并且仅更改剩余的绝大多数仅内核页面的行为,这些页面将不再映射到用户空间中。

On most architectures, gettimeofday() is implemented as a purely userspace call, and never enters the kernel, doesn't include the TLB flush or CR3 switch that KPTI implies, so you shouldn't see a performance impact. 在大多数体系结构中, gettimeofday()实现为纯粹的用户空间调用,并且从不进入内核,不包括KPTI所暗示的TLB刷新或CR3交换机,因此您不应该看到性能影响。

Exceptions include unusual kernel or hardware configurations that don't use the vDSO mechanisms, eg, if you don't have a constant rdtsc or if you have explicitly disabled rdtsc timekeeping via a boot parameter. 例外情况包括不使用vDSO机制的异常内核或硬件配置,例如,如果您没有常量rdtsc或者您已通过引导参数明确禁用了rdtsc计时。 You'd probably already know if that was the case since it means that gettimeofday would take 100-200ns rather than 15-20ns since it's already making a kernel call. 您可能已经知道是否是这种情况,因为它意味着gettimeofday需要100-200ns而不是15-20ns,因为它已经在进行内核调用。

Good question, the VDSO pages are kernel memory mapped into user space. 好问题,VDSO页面内核内存映射到用户空间。 If you single-step into gettimeofday() , you see a call into the VDSO page where some code there uses rdtsc and scales the result with scale factors it reads from another data page. 如果您单步进入gettimeofday() ,您会看到对VDSO页面的call ,其中某些代码使用rdtsc并使用从另一个数据页读取的比例因子来缩放结果。

But these pages are supposed to be readable from user-space, so Linux can keep them mapped without any risk. 但是这些页面应该是可以从用户空间读取的,因此Linux可以保持映射而没有任何风险。 The Meltdown vulnerability is that the U/S bit (user/supervisor) in page-table / TLB entries doesn't stop unprivileged loads (and further dependent instructions) from happening microarchitecturally, producing a change in the microarchitectural state which can then be read with cache-timing. Meltdown漏洞是页表/ TLB条目中的U / S位(用户/管理程序)不会阻止非特权加载(以及进一步的依赖指令)发生微体系结构,从而产生微架构状态的变化,然后可以读取缓存时序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM