我对以下任务有疑问。
考虑一个IA-32系统,其中MMU支持两个级别的页面表。第二级包含1024个页表条目,映射到4KB页帧。每个页面表条目(两个级别)的大小为4个字节。系统只支持4 KB的页面大小。
我们希望从虚拟内存中连续读取8MB,从字节0开始。我们一次读一个单词(4个字节)
我们有8个入口数据TLB。需要多少内存访问才能读取上面指定的8MB内存?
如果TLB有4个条目而不是8个条目,这会有什么区别吗?
所以,我们按顺序阅读。这意味着8MB/4B = 2M内存访问。我们有一个两级的页面表。因此,2M + 2*2M = 6M内存访问没有TLB。
但我不知道如何计算内存访问,包括一个TLB。
有人能解释一下吗?那会很有帮助的。
发布于 2014-03-11 21:56:14
由于访问模式是流访问,因此每个TLB条目将用于对整个页面的每四个字节进行一次访问,并且永远不会重复使用。这意味着每个TLB条目将被重用1023次,因此每页将避免1023次查找(2046个内存访问)。(由于不同翻译的使用没有重叠,而且只有完全本地化的重用,单个条目数据TLB的性能甚至相当于2048年条目TLB。)
考虑以下对两项直接映射数据TLB正在发生的情况的描述(认识到对于TLB来说,忽略最不重要的12位虚拟地址(页面中的偏移量),并使用一位虚拟地址索引到TLB中):
load 0x0100_0000; // TLB entry 0 tag != 0x0800 (page # 0x0_1000) [miss]
// 2 memory accesses to fill TLB entry 0
load 0x0100_0004; // TLB entry 0 tag == 0x0800 [hit]
load 0x0100_0008; // TLB entry 0 tag == 0x0800 [hit]
... // 1020 TLB hits in TLB entry 0
load 0x0100_0ffc; // TLB entry 0 tag == 0x0800 [hit]; last word in page
load 0x0100_1000; // TLB entry 1 tag != 0x0800 (page # 0x0_1001) [miss]
// 2 memory accesses to fill TLB entry 1
load 0x0100_1004; // TLB entry 1 tag == 0x0800 [hit]
load 0x0100_1008; // TLB entry 1 tag == 0x0800 [hit]
... // 1020 TLB hits in TLB entry 1
load 0x0100_1ffc; // TLB entry 1 tag == 0x0800 [hit]; last word in page
load 0x0100_2000; // TLB entry 0 tag (0x0800) != 0x0801 (page # 0x0_1002) [miss]
// 2 memory accesses to fill TLB entry 0
load 0x0100_2004; // TLB entry 0 tag == 0x0801 [hit]
load 0x0100_2008; // TLB entry 0 tag == 0x0801 [hit]
... // 1020 TLB hits in TLB entry 0
load 0x0100_2ffc; // TLB entry 0 tag == 0x0801 [hit]; last word in page
load 0x0100_3000; // TLB entry 1 tag (0x0800) != 0x0801 (page # 0x0_1003) [miss)
// 2 memory accesses to fill TLB entry 1
load 0x0100_3004; // TLB entry 1 tag == 0x0801 [hit]
load 0x0100_3008; // TLB entry 1 tag == 0x0801 [hit]
... // 1020 TLB hits in TLB entry 1
load 0x0100_3ffc; // TLB entry 1 tag == 0x0801 [hit]; last word in page
... // repeat the above 510 times
// then the last 4 pages of the 8 MiB stream
load 0x017f_c000; // TLB entry 0 tag (0x0bfd) != 0x0bfe (page # 0x0_17fc) [miss]
// 2 memory accesses to fill TLB entry 0
load 0x017f_c004; // TLB entry 0 tag == 0x0bfe [hit]
load 0x017f_c008; // TLB entry 0 tag == 0x0bfe [hit]
... // 1020 TLB hits in TLB entry 0
load 0x017f_cffc; // TLB entry 0 tag == 0x0bfe [hit]; last word in page
load 0x017f_d000; // TLB entry 1 tag (0x0bfd) != 0x0bfe (page # 0x0_17fd) [miss]
// 2 memory accesses to fill TLB entry 1
load 0x017f_d004; // TLB entry 1 tag == 0x0bfe [hit]
load 0x017f_d008; // TLB entry 1 tag == 0x0bfe [hit]
... // 1020 TLB hits in TLB entry 1
load 0x017f_dffc; // TLB entry 1 tag == 0x0bfe [hit]; last word in page
load 0x017f_e000; // TLB entry 0 tag (0x0bfe) != 0x0bff (page # 0x0_17fe) [miss]
// 2 memory accesses to fill TLB entry 0
load 0x017f_e004; // TLB entry 0 tag == 0x0bff [hit]
load 0x017f_e008; // TLB entry 0 tag == 0x0bff [hit]
... // 1020 TLB hits in TLB entry 0
load 0x017f_effc; // TLB entry 0 tag == 0x0bff [hit]; last word in page
load 0x017f_f000; // TLB entry 1 tag (0x0bfe) != 0x0bff (page # 0x0_17ff) [miss]
// 2 memory accesses to fill TLB entry 1
load 0x017f_f004; // TLB entry 1 tag == 0x0bff [hit]
load 0x017f_f008; // TLB entry 1 tag == 0x0bff [hit]
... // 1020 TLB hits in TLB entry 1
load 0x017f_fffc; // TLB entry 1 tag == 0x0bff [hit]; last word in page每个页面按顺序被引用1024次(每四个字节元素一次),然后不再被引用。
(现在考虑一个有四个TLB条目和两个条目缓存页面目录条目的设计,每个条目都有指向页表条目页面的指针。每个缓存的PDE将被重用用于1023页的查找,减少到每个内存访问。如果8 MiB流访问被作为一个内循环重复并对齐了4 MiB,那么在第一次迭代之后,一个双条目的PDE缓存将被完全热身,所有后续的页面表查找只需要一个内存引用。)
https://stackoverflow.com/questions/22333776
复制相似问题