- 浏览: 208967 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
Prepared:
Hadoop的几个明显缺点 -
CSunDNan:
...
openjdk jvm 方法字节码执行过程 -
幻影之蚀:
...
mysql 源码分析2 源码调试环境建立 -
shukongchengje:
紧急呼唤楼主,mysql代码从哪里弄?官网wiki上看的一头雾 ...
mysql源码分析 整体架构 -
yeshaoting:
好文章.不介意的话转载了.
jvm 字节码中文含义
刚写完一篇关于Cache Coherence的文章,就发现BNN2年前就有一篇好文,早知道就不这么费事自己写了:)
Recently work with dual cpu kernel part. For dual cpu, or we say, multi-processor, the big challenge part for a kernel is how to handle the cache coherence.
Conceptually, two choices--Write Invalidate and Write Update.
We will talk about Write Invalidate today.
Typically, there are two protocols falling into the Write Invalidate protocol, namely, the Write-Through Write Invalidate Protocol and the Write Once(Or Write-Back Write Invalidate Protocol). Note that the well-known MESI protocol is derived from the Write Once. That's why we will focus on the Write Once here.
--------------------------
Write Once:
Write Once protocol is to offset the shortcomings of Write-Through Write-Invalidate Protocol, which will introduce extra bus traffic onto the system bus.
Write Once works basically as follows:
(Assume
* the hardware snoop enabled over the shared system bus.
* The cache is Write Back
)
There are four states for Write Once protocol--Valid, Reserved, Dirty and Invalid.
Initial State:
* When a LOAD MISS, the data will be loaded into cache line and the state goes to VALID state
// Please note here, Write Once protocol will promise that your loaded data in memory will be the latest. Why? If at the time you tried to load a cache line, there is an modified copy in another CPU, the snoop protocol will abort the load bus transaction; flush another cpu's data into main memory and then resume the aborted transaction so that the requesting CPU will then get the updated data....
Now, let's investigate the state machine of Write Once Protocol.
***************
VALID State:
***************
When a LOAD HIT, we do nothing. That's right. The cache line is already here. CPU is happy to find the data in the cache.
When a LOAD MISS, we will re-start the init procesure to load the latest data into cache line.
When a CPU STORE HIT(a store hit from the current processor) , Now comes to the key part of Write Once protocol. When having a write/store behavior, for UP(unique processor) system, we all understand that the cache state will go to DIRTY state and ****didn't write data back to main memory****. However, Write-Once protocol works like this below in order to achieve multiple processor cache coherence.
The stored data will be flushed back to main memory(why? We need a bus transaction over the bus!!!) and then cache state will be moved to Reserved State.
This is exactly why this protocol is given the name of "Write Once"---Write the first time write access to a write-back cache line into main memory*****!!!! so that other processor cache controller will be awared and then invalidate the corresponding cache lines, and thus the whole system will only one copy of the cache line.
After the first time write once, the subsequent write access will only change the state to DIRTY state and the data will stay in cache line and will not be flushed into main memory, the same case as we see in UP write-back approach.
When a SNOOP STOEE HIT( we found another CPU is trying to do a store on that cached address), then, with the write-invalidate semantics, we know, the system will then invalidate its own copy in this current processor in order to keep only one legal copy for that cache line. In other words, the state will go to Invalid state from Valid state. Note that, we don't have to do any flush. The reason is simple: In this processor, we didn't do any write yet. So we will only invalidate our own copy in this processor. In the later, if we want to read this particular data, we will have to load it from main memory again.
For VALID state, we have other input needed to be considered, like
snoop load hit
cpu store miss
How cpu will react with these two actions?
I will leave questions to you guys......
Recently work with dual cpu kernel part. For dual cpu, or we say, multi-processor, the big challenge part for a kernel is how to handle the cache coherence.
Conceptually, two choices--Write Invalidate and Write Update.
We will talk about Write Invalidate today.
Typically, there are two protocols falling into the Write Invalidate protocol, namely, the Write-Through Write Invalidate Protocol and the Write Once(Or Write-Back Write Invalidate Protocol). Note that the well-known MESI protocol is derived from the Write Once. That's why we will focus on the Write Once here.
--------------------------
Write Once:
Write Once protocol is to offset the shortcomings of Write-Through Write-Invalidate Protocol, which will introduce extra bus traffic onto the system bus.
Write Once works basically as follows:
(Assume
* the hardware snoop enabled over the shared system bus.
* The cache is Write Back
)
There are four states for Write Once protocol--Valid, Reserved, Dirty and Invalid.
Initial State:
* When a LOAD MISS, the data will be loaded into cache line and the state goes to VALID state
// Please note here, Write Once protocol will promise that your loaded data in memory will be the latest. Why? If at the time you tried to load a cache line, there is an modified copy in another CPU, the snoop protocol will abort the load bus transaction; flush another cpu's data into main memory and then resume the aborted transaction so that the requesting CPU will then get the updated data....
Now, let's investigate the state machine of Write Once Protocol.
***************
VALID State:
***************
When a LOAD HIT, we do nothing. That's right. The cache line is already here. CPU is happy to find the data in the cache.
When a LOAD MISS, we will re-start the init procesure to load the latest data into cache line.
When a CPU STORE HIT(a store hit from the current processor) , Now comes to the key part of Write Once protocol. When having a write/store behavior, for UP(unique processor) system, we all understand that the cache state will go to DIRTY state and ****didn't write data back to main memory****. However, Write-Once protocol works like this below in order to achieve multiple processor cache coherence.
The stored data will be flushed back to main memory(why? We need a bus transaction over the bus!!!) and then cache state will be moved to Reserved State.
This is exactly why this protocol is given the name of "Write Once"---Write the first time write access to a write-back cache line into main memory*****!!!! so that other processor cache controller will be awared and then invalidate the corresponding cache lines, and thus the whole system will only one copy of the cache line.
After the first time write once, the subsequent write access will only change the state to DIRTY state and the data will stay in cache line and will not be flushed into main memory, the same case as we see in UP write-back approach.
When a SNOOP STOEE HIT( we found another CPU is trying to do a store on that cached address), then, with the write-invalidate semantics, we know, the system will then invalidate its own copy in this current processor in order to keep only one legal copy for that cache line. In other words, the state will go to Invalid state from Valid state. Note that, we don't have to do any flush. The reason is simple: In this processor, we didn't do any write yet. So we will only invalidate our own copy in this processor. In the later, if we want to read this particular data, we will have to load it from main memory again.
For VALID state, we have other input needed to be considered, like
snoop load hit
cpu store miss
How cpu will react with these two actions?
I will leave questions to you guys......
----------------
Valid State
----------------
SNOOP LOAD HIT:
That means that current CPU cache controller ***see** a bus transaction issued by another device, for instance, another CPU, to access the data that is currentily cached. When this happens, current CPU cache will do nothing but stay the VALID state. The reason is simple: Another device/cpu will fetch the data from the memory that STILL holds the latest data.
CPU STORE MISS:
How/when this situation could happen, after a cache line WAS loaded before? Yeah, you are right. That cache line could be **replaced** by other datas(Remember the LRU algorithm of cache management; Set associative concepts/mechanisms and so such).
when a CPU store miss happens, the data will be written into main memory and also have a copy in the cache (That's the "Write Allocate" when handling a write miss). After that, the cache snoop protocol will move its state into Reserved from the VALID. Why? That means that a write and more importantly, the first write, has just completed!
--------------
Reserved
--------------
As I said before, the Reserved state was introduced to reflect the write once semantics--The first write will flush data into memory so that other devices/CPUs are able to see/be notified a bus transaction!
For this state, same as VALID state, its input could vary as follows:
* CPU LOAD HIT
Simply feed the data back to CPU and keep the state stay.
* CPU WRITE HIT
Since we are using WT(write back) for the cache lines, then we will change our state to DIRTY. In other words, we will not flush data into memory, in contrast with the WT(Write Through) approach.
* CPU Load Miss
System will simply load the data from main memory and keep a copy in the cache(if it is Not-Read Through). And reset the system as VALID STATE.
* CPU WRITE MISS
This cache line got replaced some time after it was loaded into cache. System will simply write the data back to main memory and then keep the latest copy in the cache and set the state still as Reserved.
* SNOOP LOAD HIT
We **see** another device is to read the cached data. Here we don't have to do any cache flush/invalidating behavior. What need to do is to change the cache coherent protocol state to VALID. Question: what would happen if we stay Reserved state? For example, if there is a coming CPU store hit?:-)
* SNOOP WRITE HIT
We **see** a write access issued by another device/CPU. We will invalidate our own cache, which will then become stale and move our state to INVALID. The reason why we don't have to involve in any flushing is simple: Our local cache data value is the same as the one in main memory. Thus, the only thing we need to do is to invalidate our private copy.
Recently work with dual cpu kernel part. For dual cpu, or we say, multi-processor, the big challenge part for a kernel is how to handle the cache coherence.
Conceptually, two choices--Write Invalidate and Write Update.
We will talk about Write Invalidate today.
Typically, there are two protocols falling into the Write Invalidate protocol, namely, the Write-Through Write Invalidate Protocol and the Write Once(Or Write-Back Write Invalidate Protocol). Note that the well-known MESI protocol is derived from the Write Once. That's why we will focus on the Write Once here.
--------------------------
Write Once:
Write Once protocol is to offset the shortcomings of Write-Through Write-Invalidate Protocol, which will introduce extra bus traffic onto the system bus.
Write Once works basically as follows:
(Assume
* the hardware snoop enabled over the shared system bus.
* The cache is Write Back
)
There are four states for Write Once protocol--Valid, Reserved, Dirty and Invalid.
Initial State:
* When a LOAD MISS, the data will be loaded into cache line and the state goes to VALID state
// Please note here, Write Once protocol will promise that your loaded data in memory will be the latest. Why? If at the time you tried to load a cache line, there is an modified copy in another CPU, the snoop protocol will abort the load bus transaction; flush another cpu's data into main memory and then resume the aborted transaction so that the requesting CPU will then get the updated data....
Now, let's investigate the state machine of Write Once Protocol.
***************
VALID State:
***************
When a LOAD HIT, we do nothing. That's right. The cache line is already here. CPU is happy to find the data in the cache.
When a LOAD MISS, we will re-start the init procesure to load the latest data into cache line.
When a CPU STORE HIT(a store hit from the current processor) , Now comes to the key part of Write Once protocol. When having a write/store behavior, for UP(unique processor) system, we all understand that the cache state will go to DIRTY state and ****didn't write data back to main memory****. However, Write-Once protocol works like this below in order to achieve multiple processor cache coherence.
The stored data will be flushed back to main memory(why? We need a bus transaction over the bus!!!) and then cache state will be moved to Reserved State.
This is exactly why this protocol is given the name of "Write Once"---Write the first time write access to a write-back cache line into main memory*****!!!! so that other processor cache controller will be awared and then invalidate the corresponding cache lines, and thus the whole system will only one copy of the cache line.
After the first time write once, the subsequent write access will only change the state to DIRTY state and the data will stay in cache line and will not be flushed into main memory, the same case as we see in UP write-back approach.
When a SNOOP STOEE HIT( we found another CPU is trying to do a store on that cached address), then, with the write-invalidate semantics, we know, the system will then invalidate its own copy in this current processor in order to keep only one legal copy for that cache line. In other words, the state will go to Invalid state from Valid state. Note that, we don't have to do any flush. The reason is simple: In this processor, we didn't do any write yet. So we will only invalidate our own copy in this processor. In the later, if we want to read this particular data, we will have to load it from main memory again.
For VALID state, we have other input needed to be considered, like
snoop load hit
cpu store miss
How cpu will react with these two actions?
I will leave questions to you guys......
Recently work with dual cpu kernel part. For dual cpu, or we say, multi-processor, the big challenge part for a kernel is how to handle the cache coherence.
Conceptually, two choices--Write Invalidate and Write Update.
We will talk about Write Invalidate today.
Typically, there are two protocols falling into the Write Invalidate protocol, namely, the Write-Through Write Invalidate Protocol and the Write Once(Or Write-Back Write Invalidate Protocol). Note that the well-known MESI protocol is derived from the Write Once. That's why we will focus on the Write Once here.
--------------------------
Write Once:
Write Once protocol is to offset the shortcomings of Write-Through Write-Invalidate Protocol, which will introduce extra bus traffic onto the system bus.
Write Once works basically as follows:
(Assume
* the hardware snoop enabled over the shared system bus.
* The cache is Write Back
)
There are four states for Write Once protocol--Valid, Reserved, Dirty and Invalid.
Initial State:
* When a LOAD MISS, the data will be loaded into cache line and the state goes to VALID state
// Please note here, Write Once protocol will promise that your loaded data in memory will be the latest. Why? If at the time you tried to load a cache line, there is an modified copy in another CPU, the snoop protocol will abort the load bus transaction; flush another cpu's data into main memory and then resume the aborted transaction so that the requesting CPU will then get the updated data....
Now, let's investigate the state machine of Write Once Protocol.
***************
VALID State:
***************
When a LOAD HIT, we do nothing. That's right. The cache line is already here. CPU is happy to find the data in the cache.
When a LOAD MISS, we will re-start the init procesure to load the latest data into cache line.
When a CPU STORE HIT(a store hit from the current processor) , Now comes to the key part of Write Once protocol. When having a write/store behavior, for UP(unique processor) system, we all understand that the cache state will go to DIRTY state and ****didn't write data back to main memory****. However, Write-Once protocol works like this below in order to achieve multiple processor cache coherence.
The stored data will be flushed back to main memory(why? We need a bus transaction over the bus!!!) and then cache state will be moved to Reserved State.
This is exactly why this protocol is given the name of "Write Once"---Write the first time write access to a write-back cache line into main memory*****!!!! so that other processor cache controller will be awared and then invalidate the corresponding cache lines, and thus the whole system will only one copy of the cache line.
After the first time write once, the subsequent write access will only change the state to DIRTY state and the data will stay in cache line and will not be flushed into main memory, the same case as we see in UP write-back approach.
When a SNOOP STOEE HIT( we found another CPU is trying to do a store on that cached address), then, with the write-invalidate semantics, we know, the system will then invalidate its own copy in this current processor in order to keep only one legal copy for that cache line. In other words, the state will go to Invalid state from Valid state. Note that, we don't have to do any flush. The reason is simple: In this processor, we didn't do any write yet. So we will only invalidate our own copy in this processor. In the later, if we want to read this particular data, we will have to load it from main memory again.
For VALID state, we have other input needed to be considered, like
snoop load hit
cpu store miss
How cpu will react with these two actions?
I will leave questions to you guys......
----------------
Valid State
----------------
SNOOP LOAD HIT:
That means that current CPU cache controller ***see** a bus transaction issued by another device, for instance, another CPU, to access the data that is currentily cached. When this happens, current CPU cache will do nothing but stay the VALID state. The reason is simple: Another device/cpu will fetch the data from the memory that STILL holds the latest data.
CPU STORE MISS:
How/when this situation could happen, after a cache line WAS loaded before? Yeah, you are right. That cache line could be **replaced** by other datas(Remember the LRU algorithm of cache management; Set associative concepts/mechanisms and so such).
when a CPU store miss happens, the data will be written into main memory and also have a copy in the cache (That's the "Write Allocate" when handling a write miss). After that, the cache snoop protocol will move its state into Reserved from the VALID. Why? That means that a write and more importantly, the first write, has just completed!
--------------
Reserved
--------------
As I said before, the Reserved state was introduced to reflect the write once semantics--The first write will flush data into memory so that other devices/CPUs are able to see/be notified a bus transaction!
For this state, same as VALID state, its input could vary as follows:
* CPU LOAD HIT
Simply feed the data back to CPU and keep the state stay.
* CPU WRITE HIT
Since we are using WT(write back) for the cache lines, then we will change our state to DIRTY. In other words, we will not flush data into memory, in contrast with the WT(Write Through) approach.
* CPU Load Miss
System will simply load the data from main memory and keep a copy in the cache(if it is Not-Read Through). And reset the system as VALID STATE.
* CPU WRITE MISS
This cache line got replaced some time after it was loaded into cache. System will simply write the data back to main memory and then keep the latest copy in the cache and set the state still as Reserved.
* SNOOP LOAD HIT
We **see** another device is to read the cached data. Here we don't have to do any cache flush/invalidating behavior. What need to do is to change the cache coherent protocol state to VALID. Question: what would happen if we stay Reserved state? For example, if there is a coming CPU store hit?:-)
* SNOOP WRITE HIT
We **see** a write access issued by another device/CPU. We will invalidate our own cache, which will then become stale and move our state to INVALID. The reason why we don't have to involve in any flushing is simple: Our local cache data value is the same as the one in main memory. Thus, the only thing we need to do is to invalidate our private copy.
发表评论
-
Linux内存:内存管理的实质
2010-04-13 08:49 11001. 内核初始化: * 内核建立好内核页目录页表数据 ... -
深入C++的new
2010-04-12 10:31 865“new”是C++的一个关键字,同时也是操作符。关于new的话 ... -
Linux 的多线程编程
2010-04-12 09:32 1935本文们针 Linux 线程编程主特性总结出 5 条经验,以改善 ... -
浅析Linux下core文件
2010-04-08 10:32 2160当我们的程序崩溃时,内核有可能把该程序当前内存映射到core文 ... -
Linux下的CPU利用率计算原理详解
2010-04-07 17:13 1640我们在搞性能测试的时 ... -
linux cpu负载原理
2010-04-07 16:41 1254linux cpu负载原理 内核分析 待补 -
从VFS inode到LFS inode的寻址过程
2010-03-30 17:16 1835我们知道Linux是借用虚拟文件系统作为上层抽象的管理者来统一 ... -
CPU学习
2010-03-30 14:16 1466这是作者学习硬件基本知识过程中的笔记,由于以前很少接触这方面的 ... -
Cache 的write back和write through
2010-03-30 13:54 2306Cache 的write back和write through ... -
linux 2.6 Makefile详解
2010-03-30 13:48 1487熟悉内核的Makefile对开发设备驱动、理解内核代码结构都是 ... -
linux1
2010-03-30 13:38 684linux1 linux1 linux1 -
nfs
2010-03-30 13:29 679nfs文件系统 -
修改Linux内核增加系统调用
2010-03-30 09:44 1229本文修改内核2.4.29,分两部分,第一部分修改内核并测试,第 ... -
Linux内核裁剪的具体步骤
2010-03-29 17:27 1857在menuconfig中配置: 详 ... -
Linux内核修改实验
2010-03-29 17:10 1189Linux内核修改实验 实验 ... -
Linux内核剪裁实验
2010-03-29 17:08 1343实验目的: 1. 配置、编译Linux内核; 2 ... -
c语言深度解析
2010-03-29 15:38 753c语言深度解析 嘿嘿 -
Linux线程实现机制分析
2010-03-29 15:12 935内容: ·基础 ... -
内存屏障原语
2010-03-29 15:11 2038来自于在CU的一个讨论: http://linux.chin ... -
linux 经典进程切换实现代码
2010-03-29 15:10 1238extern _inline void switch_to(i ...
相关推荐
Future multi-core processors will have many large cache banks connected by a network and shared by many cores. Hence, many important problems must be solved: cache resources must be allocated across ...
文章来自《IEEE Access》期刊。该文研究了具有缓存使能用户的多中继非正交多址(NOMA)网络,其中信源在N个中继的辅助下向两个用户发送叠加信号。我们首先分析了传统的合作NOMA网络,然后讨论了具有缓存使能用户的合作...
Content Placement in Cache-Enabled Sub-6 GHz and Millimeter-Wave Multi-Antenna Dense Small Cell Networks
赠送jar包:cache-api-1.1.1.jar; 赠送原API文档:cache-api-1.1.1-javadoc.jar; 赠送源代码:cache-api-1.1.1-sources.jar; 赠送Maven依赖信息文件:cache-api-1.1.1.pom; 包含翻译后的API文档:cache-api-...
总的来说,"cachecloud-bin-1.2.tar.gz"为用户提供了便捷的CacheCloud部署方式,"cachecloud-init.sh"进一步简化了安装流程。结合CacheCloud的特性,我们可以轻松搭建和管理Redis集群,提高运维效率,降低管理复杂性...
CAB: Cache Aware Bi-tier Task-stealing in Multi-socket Multi-core ...socket Multi-core architecture with shared caches in each socket. However, traditional task-stealing schedulers tend to
npm install multi-cache 要从 github 安装开发版本,请运行: npm install "git+https://github.com/belbis/multi-cache" 介绍 该项目的目标是为可互换数量的缓存提供高级接口 用法 简单的内存缓存示例: var ...
《cache-api-1.0.0.jar:JSR107缓存规范解析》 在IT行业中,缓存是优化系统性能的关键技术之一。本文将深入探讨“cache-api-1.0.0.jar”这个软件包,它与JSR107(Java Cache API)最终规范密切相关,为开发者提供了...
赠送jar包:cache-api-1.1.1.jar; 赠送原API文档:cache-api-1.1.1-javadoc.jar; 赠送源代码:cache-api-1.1.1-sources.jar; 赠送Maven依赖信息文件:cache-api-1.1.1.pom; 包含翻译后的API文档:cache-api-...
"SuperCache4.1-Server-x32"是一款专为32位系统设计的超级缓存服务软件,其目标是显著提高Web服务器的响应速度,降低服务器负载,从而提升整体性能和用户体验。 超级缓存软件的核心功能在于其高效的数据缓存机制。...
$this->app->singleton('cache.multi-memcached', function ($app) { $stores = []; foreach ($app['config']['cache.stores'] as $store => $config) { if ($config['driver'] === 'memcached') { $connector ...
代理缓存多文件代理和缓存多个文件和相关标头安装这个模块是通过 npm 安装的: npm i proxy-cache-multi-file --save示例用法设置 var proxyCacheMultiFile = require ( 'proxy-cache-multi-file' )...
cachecloud redis管理平台 官方说明文档: https://github.com/sohutv/cachecloud/wiki/3.服务器端接入文档#cc-binary-install
fastcache-1.1.0-cp27-cp27m-win_amd64.whl 使用安装文章地址:https://blog.csdn.net/qq_36477513/article/details/104779850
MUMPS(Massachusetts Universal Multi Programming System)是一种专为Cache数据库设计的脚本语言,主要用于编写存储过程。它作为一种多功能的编程语言,具备多用户、多任务处理能力,并支持灵活的数据结构。对于...
用于节点缓存管理器的Redis存储Redis...安装npm install cache-manager-redis-store --save 要么yarn add cache-manager-redis-store使用范例请参阅以下示例,了解如何实现Redis缓存存储。单店var cacheManager = requ
cache-jdbc
在本文中,我们将深入探讨如何在 Laravel 开发中使用多台 Memcached 服务器,这是 `Laravel-multi-memcached` 的核心概念。Laravel 是一个流行的 PHP 框架,以其优雅的语法和强大的功能而受到开发者的喜爱。...
`laravel-page-cache` 是一个专门为Laravel应用程序设计的扩展,旨在优化网站速度,通过预先渲染整个页面并存储其内容来减少数据库查询和视图渲染的时间。下面将详细探讨这个话题。 ### Laravel页面缓存简介 ...