2012年5月30日 星期三

ARM MMU Cacheable and Bufferable bits

C=0,B=0: NCNB (WB off)
C=0,B=1: NCB (WB on)
C=1,B=0: WriteThrough, no write allocate (WB on)
C=1,B=1: WriteBack, no write allocate (WB on)

[藍森林-自由軟件] - 如果cache打開而MMU不打開,這種情況允許嘛?- 系統管理
http://www.lslnet.com/linux/f/docs1/i56/big5375649.htm

1.WB的設計是為了防止處理器流水線被寫數據總線操作(寫主存,寫外圍設備寄存器等)拉住。典型寫數據總線時機有三種:一是cache處於write through策略下的寫操作;二是cache處於write back策略下,dirty數據由於cache行替換或者被程序主動清空而寫回主存,三是不經過cache,直接對數據總線的寫操作。有了WB之後,被寫回數據總線的內容在進入WB之後,處理器和cache就可以立刻繼續使用了。這就是WB和cache的關係。
2.那個表的含義如下:
ARM各系列的處理器上的cache設計有所不同,所以有的cache只有write through策略,有的cache只有write back策略,還有的cache是write back策略但允許一定的write through行為,因此C和B位的四種組合對這三種cache而言有不同的含義。第一列和第二列分別針對write through型cache和write back型cache進行解釋,其含義可以參考我對第1個問題的回答,第三列針對write back策略但允許一定的write through行為的cache,第一行好理解,第二行之所以在B位為0的情況下依然是bufferable,應該是因為硬件上的設計原因(節省硬件資源或者由於目標設計頻率限制),第三行的含義是,當C==1,B==0時,cache使用write through策略,WB開啟,第四行的含義是,當C==1,B==1時,cache使用write back策略,WB開啟。
可以看到,對第三種類型的cache,C和B位不再「嚴格」是其本來控制cacheable和bufferable的含義,而是利用這兩位的「組合」來控制cache和WB的表現行為,這樣做比另外再增加一位來選擇cache的write back策略和write through策略硬件上節約了資源,效果上卻差不多,少了cache和WB幾種意義不大的組合,應該說還是挺巧妙的。


7.5.3. Cacheable and bufferable flags
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/BABJJDIE.html
If you set a region to be cacheable:

  • When you load from that region, the cache is searched. If the item is found, it is loaded from the cache. If the item is not found, a complete cache line including the required address is loaded. Some other cache line is evicted from the cache, unless there is an unused cache line available.
  • When you save to that region, the cache is searched. If the item is found, the save is made to the cache. If the item is not found, the save is made to memory.

The exact effect of the bufferable flag varies (see the Technical Reference Manual for your processor for details).

沒有留言: