Gongjin Sun
2018-08-27 06:28:34 UTC
Hi,
First, I really thank the maintainer(s) of the cache code who wrote so many
detailed comments for almost all key code in the cache access path to help
the readers (especially the beginners) understand how the cache hierarchy
works.
I read these useful comments again and again and understand most of them.
But still some are not so easy to understand. I list them as follows and
hopefully can get some answers. I appreciate it a lot!
1 BaseCache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList
&writebacks) (src/mem/cache/base.cc)
(1) In the segment "if (pkt->isEviction()) { ...}", if I understand it
correctly, this code segment checks whether arriving requests (Writeback
and CleanEvict) have already had their copies (for the same block address)
in the Write Buffer and handle them accordingly.
But I notice the comments
"// We check for presence of block in above caches before issuing
// Writeback or CleanEvict to write buffer. Therefore the only
...
", it is confusing to say here "in above caches". Shouldn't it be "for
presence of block in this Write Buffer"?
Also, about the comments
"// Dirty writeback from above trumps our clean writeback... discard here",
why is the local found writeback is clean? I think it could be clean or
dirty. So arriving dirty writeback sees local writeback in the write buffer
and the former could be (but not necessarily) newer than the latter. (One
such scenario is: cpu core write hit block A in L1 data cache and then
write it back to L2. Then core read it into L1 again. Next, the dirty A is
put into Write Buffer in L2. After that, the cpu core could "write back A
to L2 again" or "write A (the second write) and then write back A to L2
again". The latter makes arriving dirty A has different value from the
dirty A in L2's write buffer.)
About the comments
"// The CleanEvict and WritebackClean snoops into other
// peer caches of the same level while traversing the",
Do here "peer caches of the same level" mean the caches of the same level
in other cpus?
(2) About the comments
"// we could get a clean writeback while we are having outstanding accesses
to a block, ..."
How does this happen? I just cannot understand this. If we see an
outstanding access in local cache, that means it must miss in above caches
for the same cpu. How can the above cache still evict a clean block (it is
a miss) and write it back to next cache level? Would you like to show one
scenario for this?
2 BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList
&writebacks, bool allocate)
(1) About the comments
"// existing block... probably an upgrade
// either we're getting new data or the block should already be valid"
How does the block become valid from previous (when "pkt" as a request
packet was accessing the cache but not satisfied) invalid status?
(2) About the comments
"// we got the block in Modified state, and invalidated the owners copy"
After it, there is a statement "blk->status |= BlkDirty;", but I don't find
any statements about "invalidated the owners copy" as mentioned in the
above comments. Where is it?
Thank you in advance!
gjins
First, I really thank the maintainer(s) of the cache code who wrote so many
detailed comments for almost all key code in the cache access path to help
the readers (especially the beginners) understand how the cache hierarchy
works.
I read these useful comments again and again and understand most of them.
But still some are not so easy to understand. I list them as follows and
hopefully can get some answers. I appreciate it a lot!
1 BaseCache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, PacketList
&writebacks) (src/mem/cache/base.cc)
(1) In the segment "if (pkt->isEviction()) { ...}", if I understand it
correctly, this code segment checks whether arriving requests (Writeback
and CleanEvict) have already had their copies (for the same block address)
in the Write Buffer and handle them accordingly.
But I notice the comments
"// We check for presence of block in above caches before issuing
// Writeback or CleanEvict to write buffer. Therefore the only
...
", it is confusing to say here "in above caches". Shouldn't it be "for
presence of block in this Write Buffer"?
Also, about the comments
"// Dirty writeback from above trumps our clean writeback... discard here",
why is the local found writeback is clean? I think it could be clean or
dirty. So arriving dirty writeback sees local writeback in the write buffer
and the former could be (but not necessarily) newer than the latter. (One
such scenario is: cpu core write hit block A in L1 data cache and then
write it back to L2. Then core read it into L1 again. Next, the dirty A is
put into Write Buffer in L2. After that, the cpu core could "write back A
to L2 again" or "write A (the second write) and then write back A to L2
again". The latter makes arriving dirty A has different value from the
dirty A in L2's write buffer.)
About the comments
"// The CleanEvict and WritebackClean snoops into other
// peer caches of the same level while traversing the",
Do here "peer caches of the same level" mean the caches of the same level
in other cpus?
(2) About the comments
"// we could get a clean writeback while we are having outstanding accesses
to a block, ..."
How does this happen? I just cannot understand this. If we see an
outstanding access in local cache, that means it must miss in above caches
for the same cpu. How can the above cache still evict a clean block (it is
a miss) and write it back to next cache level? Would you like to show one
scenario for this?
2 BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList
&writebacks, bool allocate)
(1) About the comments
"// existing block... probably an upgrade
// either we're getting new data or the block should already be valid"
How does the block become valid from previous (when "pkt" as a request
packet was accessing the cache but not satisfied) invalid status?
(2) About the comments
"// we got the block in Modified state, and invalidated the owners copy"
After it, there is a statement "blk->status |= BlkDirty;", but I don't find
any statements about "invalidated the owners copy" as mentioned in the
above comments. Where is it?
Thank you in advance!
gjins