x86如何提示设置页面脏位? [英] How prompt is x86 at setting the page dirty bit?

查看:160
本文介绍了x86如何提示设置页面脏位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从软件的角度来看,弄脏内存页面的指令与内核在页面表项(PTE)中实际将页面标记为肮脏之间的延迟是多少?

From a software point of view, what is the latency between an instruction that dirties a memory page and when the core actually marks the page dirty in the Page Table Entry (PTE)?

换句话说,如果一条指令弄脏了页面,那么下一条指令可以读取PTE并查看脏位设置吗?

In other words, if an instruction dirties a page, can the very next instruction read the PTE and see the dirty bit set?

我不关心实际经过的周期,只要有一个可见的软件窗口,其中脏位尚未设置.我似乎在参考手册中找不到任何保证.

I don't care about the actual elapsed cycles, only if there is a software visible window in which the dirty bit is not yet set. I can't seem to find any guarantees in the reference manuals.

推荐答案

摘自AMD手册(2005年左右),第2卷:系统编程:

From the AMD's manual (circa 2005), Volume 2: System Programming:

5.4页面翻译表输入字段 ...脏(D)位.位6.此位仅出现在页面翻译层次结构的最低级别中.它指示页面翻译是否 此入口指向的表或物理页面. 第一次写入时,处理器将D位设置为1 到物理页面.

5.4 Page-Translation-Table Entry Fields ... 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.

Ditto,来自Intel(大约于2006年),第3-A卷:系统编程指南,第1部分:

Ditto from Intel (circa 2006), Volume 3-A: System Programming Guide, Part 1:

3.7.6页面目录和页面表条目 ...脏(D)标志,位6指示设置时是否已写入页面. (在指向页面的页面目录条目中不使用此标志 表.)内存管理软件通常会在出现以下情况时清除此标志: 页面最初被加载到物理内存中.处理器然后设置 首次访问页面进行写操作时,此标志.

3.7.6 Page-Directory and Page-Table Entries ... 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卷,系统编程指南):

From the latest Intel manual (vol 3A, System Programming Guide):

8.1.2.1自动锁定处理器自动遵循LOCK语义的操作如下:...当 更新页面目录和页面表条目—更新时 页面目录和页面表条目,处理器使用锁定 设置页面目录中访问和脏标志的周期,然后 页表条目.

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就应该开始查看更新后的值.

From the rest of the text in sections 8.1 and 8.2 it follows that once the CPU sets the dirty bit using the locked operation, the other CPUs should start seeing the updated value.

当然,您可能会遇到争用情况,因为您首先在一个CPU(或其一个线程中)上读取脏位为0,然后又在另一个CPU(或同一CPU上的另一个线程)上将脏位读为0.设置为1,但这并不稀奇.

Of course, you may have a race condition in that you first read the dirty bit as 0 on one CPU (or in one of its threads) and later another CPU (or another thread on the same CPU) causes this bit to be set to 1, but that isn't any unusual.

这篇关于x86如何提示设置页面脏位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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