从软件的角度来看,内存页面弄脏的指令与内核页面条目(PTE)中核心实际标记页面的时间之间的延迟是多少?
换句话说,如果指令弄脏页面,下一条指令是否可以读取PTE并看到脏位设置?
我不关心实际经过的周期,只有当有一个软件可见窗口时,尚未设置脏位。我似乎无法在参考手册中找到任何保证。
答案 0 :(得分:8)
从AMD的手册(大约2005年),第2卷:系统编程:
5.4页面 - 翻译 - 表格输入字段
...
Dirty (D) Bit. Bit 6.
This bit is only present in the lowest level of the page-translation hierarchy. It indicates whether the pagetranslation table or physical page to which this entry points has been written. The D bit is set to 1 by the processor the first time there is a write to the physical page.
同上英特尔(约2006年),第3-A卷:系统编程指南,第1部分:
3.7.6页面目录和页面表条目
...
Dirty (D) flag, bit 6
Indicates whether a page has been written to when set. (This flag is not used in page-directory entries that point to page tables.) Memory management software typically clears this flag when a page is initially loaded into physical memory. The processor then sets this flag the first time a page is accessed for a write operation.
<强>更新强>:
从最新的intel手册(第3A卷,系统编程指南):
8.1.2.1 Automatic Locking
The operations on which the processor automatically follows the LOCK semantics are as follows:
...
When updating page-directory and page-table entries —
When updating page-directory and page-table entries, the processor uses locked cycles to set the accessed and dirty flag in the page-directory and page-table entries.
从8.1和8.2节的其余部分开始,一旦CPU使用锁定操作设置脏位,其他CPU应该开始看到更新的值。
当然,您可能遇到竞争条件,因为您首先在一个CPU(或其中一个线程)中读取脏位为0,然后另一个CPU(或同一CPU上的另一个线程)导致此位设置为1,但这并不罕见。
答案 1 :(得分:5)
AMD64 Architecture Programmer’s Manual Volume 2: System Programming (revision 3.22, Sept. 2012)
通常,针对其他负载排序脏位更新 和商店,虽然不一定是访问WC 记忆;特别是,它们可能不会导致WC缓冲区被刷新。 但是,确保与未来处理器的兼容性,序列化 在读取D位之前应插入操作。
(强调我的。)
答案 2 :(得分:1)
根据this document的第2033页,英特尔x86缓存有关页表的信息。该文本指出,如果通过软件清除脏位,则CPU可能仍然将其视为等于1.
现在,对于这个问题:如果CPU缓存脏位,则PTE(页表条目)的更新可能不会立即发生。它可能会被缓存 - 回写策略延迟。
同一文档的第1651页描述了刷新内部缓存的WBINVD指令。它并没有说这包括CPU缓存的所有数据。