难道Linux的使用TLB x86处理器的PCID功能?如果不是,为什么? [英] Does Linux use x86 CPU's PCID feature for TLB? If not, why?

查看:2734
本文介绍了难道Linux的使用TLB x86处理器的PCID功能?如果不是,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个内核模块来检查CR4.PCIDE,它不设置。为什么不能在Linux由于TLB失效和缓存污染使用这种功能来减少业绩增速放缓?

I wrote a kernel module to check CR4.PCIDE, it is not set. Why doesn't Linux use such feature to reduce the performance slowdown due to TLB invalidation and cache pollution?

推荐答案

请注意:我不是一个Linux开发人员

Note: I'm not a Linux developer

有关英特尔的进程背景标识符,有4096 ID的限制。这意味着,当有超过4096的过程需要对它们进行管理(例如,也许做一个最近最少使用的事情,所以,如果需要进行再执行,目前没有一个ID的过程从采取的一些ID其他过程和重复使用)。

For Intel's "Process Context Identifiers", there's a limit of 4096 IDs. This means that when there are more than 4096 processes you need to manage them (e.g. maybe do a "least recently used" thing so that if a process that currently doesn't have an ID needs to be executed then the ID is taken from some other process and reused).

这是进入它的另一件事是TLB击落在多CPU系统。这些可能是有点贵,所以人们做技巧,以避免它们。例如,如果一个进程只有一个线程那么就只有一个CPU上运行,你知道有没有必要的IPI发送到其它的CPU(打断他们,并要求他们做到TLB击落)。一旦你开始使用的PCID你无法确保其他CPU不还是有TLB项,并不能做到这些技巧,以避免TLB击落。这也意味着,(理论上,为妥善执行PCID支持)的性能,你从PCID获得可能会少于你失去因unavoided TLB击落和ID管理费用,造成净亏损的性能。

The other thing that comes into it is "TLB shootdown" on multi-CPU systems. These can be a little expensive, so people do tricks to avoid them. For example, if a process only has one thread then it can only be running on one CPU and you know there's no need to send an IPI to other CPUs (interrupting them and asking them to do the "TLB shootdown"). Once you start using PCIDs you can't be sure that other CPUs don't still have TLB entries, and can't do these tricks to avoid "TLB shootdown". It also means that (in theory, for badly implemented PCID support) the performance you gain from PCID may be less than the performance you lose due to unavoided TLB shootdown and ID management overhead, resulting in a net loss.

主要是我要说的是,这是一个有点复杂,增加对PCID支持(它不喜欢你可以设置一个标志CR4,而忘记了它)。你必须做一些研究(实验原型,基准测试),以确定实现它的最有效的方法。对于大/复杂/旧内核(如Linux),它会更加复杂,因为你必须要小心,不要意外爆冷别的东西。另一件事是,这个功能是比较新的(如果我没有记错它只是存在了数年),并没有被大量的CPU(例如任何年纪大一点的,和任何来自AMD)的支持。

Mostly what I'm saying is that it's a little complicated to add support for PCID (it's not like you can just set a flag in CR4 and forget about it). You'd have to do some research (experiments, prototypes, benchmarking) to determine the most effective way of implementing it. For a large/complex/old kernel (like Linux) it'd be even more complicated as you'd have to be careful not to upset something else by accident. The other thing is that this feature is relatively new (it's only existed for a few years if I remember correctly) and isn't supported by a lot of CPUs (e.g. anything a little older, and anything from AMD).

基本上,我认为它归结为时间与收益(或者,没有足够的时间上的CPU数量有限的小的性能提升)。

Basically, I'd assume that it comes down to "time vs. benefits" (or, not enough time for a small performance improvement on a limited number of CPUs).

这篇关于难道Linux的使用TLB x86处理器的PCID功能?如果不是,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆