设为首页 加入收藏

TOP

Cache的相关知识(二)(五)
2023-07-23 13:30:27 】 浏览:184
Tags:Cache 相关知
Back 回写模式:在进行写操作时,数据直接写入当前高速缓存,而不会继续传递,当该高速缓存行被替换出去时,被改写的数据才会更新到下一级高速缓存或主存储器中。该策略增加了高速缓存一致性的实现难度,但是有效降低了总线带宽需求。

9. 共享域

为了支持数据一致性协议 ,需要增加硬件很多开销,会降低系统的性能,同时也会增加系统的功耗。但是,很多时候并不需要系统中的所有模块之间都保持数据一致性,而只需要在系统中的某些模块之间保证数据一致性就行了。因此,需要对系统中的所有模块,根据数据一致性的要求,做出更细粒度的划分。ARMv8架构将这种划分称作为域(Domain)

共享域一共划分成了四类:

共享域类型 说明
非共享域(Non-shareable) 处于这个域中的内存只由当前CPU核访问,所以,如果一个内存区域是非共享的,系统中没有任何硬件会保证其缓存一致性。如果一不小心共享出去了,别的CPU核可以访问了,那必须由软件自己来保证其一致性。
内部共享域(Inner Shareable) (1) 处于这个域中的内存可以由系统中的多个模块同时访问,并且系统硬件保证对于这段内存,对于处于同一个内部共享域中的所有模块,保证缓存一致性。
(2) 一个系统中可以同时存在多个内部共享域,对一个内部共享域做出的操作不会影响另外一个内部共享域。
外部共享域(Outer Shareable) (1) 处于这个域中的内存也可以由系统中的多个模块同时访问,并且系统硬件保证对于这段内存,对于处于同一个外部共享域中的所有模块,保证缓存一致性。外部共享域可以包含一个或多个内部共享域,但是一个内部共享域只能属于一个外部共享域,不能被多个外部共享域共享。
(2) 对一个外部共享域做出的操作会影响到其包含的所有的内部共享域
全系统共享域(Full System) 表示对内存的修改可以被系统中的所有模块都感知到

??在一个具体的系统中,不同域的划分是由硬件平台设计者决定的,不由软件控制。并且,Arm的文档中也没有提及具体要怎么划分。但有一些指导原则,一般在一个操作系统中可以看到的所有CPU核要分配在一个内部域里面,如下图所示:

??这些域的划分只是为了更细粒度的管理内存的缓存一致性,理论上所有内存都可以放到全系统共享域中,从功能上说也可以,但会影响性能。

?? 可缓存性和共享性一定是对普通内存才有的概念。设备内存一定是不支持缓存的,且是外部共享的

inner share和outer share:
??怎么去区分inner share还是outer share呢,arm手册里讲了,不同的SOC设计有不同的区分方法,不过有一个通用的规则: inner share通常是CPU IP集成的caches,包括CPU IP集成的L1 data cache和L2 cache,而outer share是通过总线连接到cache,比如外接的L3 cache等

??下面这个图,比较直观。这个图,虚线分成了两部分,上半部都是inner share,下半部都是outershare。上半部表示是CPU IP集成的cache,左侧的cores集成了L1和L2cache,而右侧的core集成了L1 cache,那虚线框出来的都是inner share。我们再来看虚线下面,通过总线外接了L2 cache或者L3 cache,都是outer share。


10. PoU和PoC的区别

10.1 PoU(Point of Unification - 统一点)

Point of Unification (PoU)
The PoU for a PE is the point by which the instruction and data caches and the translation table walks of that PE are guaranteed to see the same copy of a memory location. In many cases, the Point of Unification is the point in a uniprocessor memory system by which the instruction and data caches and the translation table walks have merged. The PoU for an Inner Shareable shareability domain is the point by which the instruction and data caches and the translation table walks of all the PEs in that Inner Shareable shareability domain are guaranteed to see the same copy of a memory location. Defining this point permits self-modifying software to ensure future instruction fetches are associated with the modified version of the software by using the standard correctness policy of:
1. Clean data cache entry by address.
2. Invalidate instruction cache entry by address

PoU: 表示一个CPU中的指令cache,数据cache还有MMU,TLB等看到的是同一份的内存拷贝。

  • PoU for a PE,是说保证PE看到的I/D cache和MMU是同一份拷贝。大多数情况下,PoU是站在单核系统的角度来观察的。
  • PoU for inner share,是说在内部共享域里面的所有CPU核都能看到相同的一份拷贝。

所以,PoU有两个观察点,一个是PoU for a PE,PE就是cpu core,另外一个是PoU for inner share。关于PoU的描述,请参阅《Arm® Architecture Reference Manual Armv8, for Armv8-A architecture profile - The AArch64 System Level Memory Model D4.4 Cache support》。

其中,提到self-modifing code在PoU for inner share里,使用下面两条简单的指令就能保证data cache和指令cache的一致性。如果不是PoU for inner share,要保证data cache和指令cache的一致性,需要额外的memory barrier的指令。


10.2 PoC(Point of Coherency - 一致性点)

Point of Coherency (PoC)
The point at which all agents that can access memory are guaranteed to see the same copy of a memory location for accesses of any memory type or cacheability attribute. In many cases this is effectively the main system memory, although the architecture does not prohibit the implemen
首页 上一页 2 3 4 5 6 7 下一页 尾页 5/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇UBOOT编译--- UBOOT编译过程目标.. 下一篇UBOOT编译--- UBOOT的$(version_h..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目