关于 TLB 条目和 Page table 条目

About TLB entries and Page table entries

来自有关 TLB 的网站:(https://www.bottomupcs.com/virtual_memory_hardware.xhtml#other-page-related-faults):

我强调了以下部分:

1:TLB词条格式和PTE一样吗(第table页词条)?而且不清楚
页面中的“页面”可以标记为是指TLB入口还是PTE?

2:对于中的“页面”,遍历所有页面,它们是TLB条目还是PTE?

3:为什么它是移出而不是“移入”?

4: 顺序是(1)设置两个位(2)放入TLB,还是相反?

There are two other important faults that the TLB can generally generate which help to mange accessed and dirty pages. Each page generally contains an attribute in the form of a single bit which flags if the page has been accessed or is dirty.

An accessed page is simply any page that has been accessed. 1When a page translation is initially loaded into the TLB the page can be marked as having been accessed (else why were you loading it in?[19])

2The operating system can periodically go through all the pages and clear the accessed bit to get an idea of what pages are currently in use. When system memory becomes full and it comes time for the operating system to choose pages to be swapped out to disk, obviously those pages whose accessed bit has not been reset are the best candidates for removal, because they have not been used the longest.

A dirty page is one that has data written to it, and so does not match any data already on disk. For example, if a page is loaded in from swap and then written to by a process, 3before it can be moved out of swap it needs to have its on disk copy updated. A page that is clean has had no changes, so we do not need the overhead of copying the page back to disk.

Both are similar in that they help the operating system to manage pages. The general concept is that a page has two extra bits; the dirty bit and the accessed bit. 4When the page is put into the TLB, these bits are set to indicate that the CPU should raise a fault.

When a process tries to reference memory, the hardware does the usual translation process. However, it also does an extra check to see if the accessed flag is not set. If so, it raises a fault to the operating system, which should set the bit and allow the process to continue. Similarly if the hardware detects that it is writing to a page that does not have the dirty bit set, it will raise a fault for the operating system to mark the page as dirty.

我建议忽略 link 作为来源。这是非常混乱的。我没有看到任何具体实现的提及,但它清楚地描述了一个。

在任何设计合理的处理器中,TLB对程序员(甚至系统程序员)来说都是完全透明的。它完全是一个硬件。

1: Is the format of TLB entries the same as PTE(page table entries)?

程序员永远看不到 TLB 条目。它们可以具有与 PTE 相同的格式。他们可能不会。

2: For "the pages" in go through all the pages, are they TLB entries or PTEs?

程序员无权访问 TLB 条目。他们必须参考PTE。

3: Why it's moved out of not "moved into"?

可能是,但您的 link 中似乎有很多混淆。

4: Is that the order is (1)set the two bits (2)put into TLB, or the converse?

这是在描述一些具体的、未命名的实现。大多数处理器都有脏位,但并非所有处理器都有访问位。