TLB 命中会导致内存页错误吗?
在网络上提供的 UC Berkley 大学 John Kubiatowicz(Kuby 教授)关于操作系统的视频讲座中,他提到 TLB 命中并不意味着相应的页面位于主内存中。页面错误仍然可能发生。
从技术上讲,TLB 是页表条目的缓存,因为所有页表条目在主内存中都没有可用的相应页面。对于 TLB 来说也是如此。 TLB 命中可能会导致页面错误。
但根据教科书上给出的算法我无法找到这样的情况。当 TLB 未命中时,内核会参考页表并更新 TLB 缓存以进行适当的地址转换。下一次 TLB 命中不会导致页面错误。当内核换出页面时,它会更新该页表条目的相应位并使相应的 TLB 无效,因此在页面加载到主内存中之前,下次不会有 TLB 命中。
那么,有人可以支持 kuby 教授的主张的正确性,并指出一种情况,即可能发生页面错误,而不是 TLB 命中(在 TLB 中找到相应虚拟地址的翻译物理地址)吗?
In UC Berkley Video lectures on OS by John Kubiatowicz (Prof. Kuby) available on web, he mentioned that TLB hit doesn't mean that corresponding page is in main memory. Page fault can still occur.
Technically TLBs are cache for page table entry and since all page table entries don't have their corresponding page available in main memory. Same can be true for TLBs. A TLB hit may lead to page fault.
But according to algorithms given in text books I am unable to find such a case. On a TLB miss kernel refer to page tables and update the TLB cache for appropriate address translation. Next TLB hit can't lead to page fault. When kernel swap out the page, it updates the appropriate bits for that page table entry and invalidate the corresponding TLB, so there can't be a TLB hit next time until page is loaded in main memory.
So can someone stand for correctness of Prof kuby's claim and point out a case when instead of TLB hit (the translated physical address for corresponding virtual address in found in TLB), a page fault can occur?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个例子是内存访问是否与允许的不同。
例如,您想要写入写保护的内存。 TLB 存在,命中并且地址被转换。但是在访问时你会遇到一个陷阱,因为你试图写入只读内存
One example is if the memory access is different from the allowed one.
e.g. you want to write to memory that's write protected. A TLB exists, it's a hit and the address is translated. But on access you get a trap, as you're trying to write to memory that's read-only
页面错误并不意味着内存中缺少页面。页面可能仍然存在并且是脏的。这也是一个页面错误。
一般来说,页面错误是指获得的翻译无法有效使用的情况。
可能是缺失页或脏页或访问权限不匹配。
因此 TLB 命中仍然可能导致页面错误。
A page fault doesnt mean a missing page in the memory. A page can still be present and be dirty. This is also a page fault.
On a general note, the page fault refers to the scenario where the obtained translation cannot be effectively used.
It may be a missing page or a dirty page or access permission mismatch.
So a TLB hit can still lead to a page fault.
帕特森说:“如果内存中不存在页面,则无法在 TLB 中进行翻译”[计算机组织与设计,第四版修订版,第 507 页]
patterson says:"cannot have a translation in TLB if page is not present in memory" [computer organization and design,4th ed revised, page 507]