changeset a42caed28e1f in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=a42caed28e1f
description:
Cache: Split invalidateBlk up to seperate block vs. tags
This seperates the functionality to clear the state in a block into
blk.hh and the functionality to udpate the tag information into the
tags. This gets rid of the case where calling invalidateBlk on an
already-invalid block does something different than calling it on a
valid block, which was confusing.
diffstat:
src/mem/cache/blk.hh | 10 ++++++++++
src/mem/cache/cache_impl.hh | 34 ++++++++++++++++++++++------------
src/mem/cache/tags/fa_lru.cc | 9 +++------
src/mem/cache/tags/fa_lru.hh | 2 +-
src/mem/cache/tags/iic.cc | 2 +-
src/mem/cache/tags/iic.hh | 2 +-
src/mem/cache/tags/lru.cc | 30 ++++++++++++++----------------
src/mem/cache/tags/lru.hh | 2 +-
8 files changed, 53 insertions(+), 38 deletions(-)
diffs (247 lines):
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/blk.hh
--- a/src/mem/cache/blk.hh Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/blk.hh Tue Sep 11 14:14:49 2012 -0400
@@ -189,6 +189,16 @@
}
/**
+ * Invalidate the block and clear all state.
+ */
+ void invalidate()
+ {
+ status = 0;
+ isTouched = false;
+ clearLoadLocks();
+ }
+
+ /**
* Check to see if a block has been written.
* @return True if the block is dirty.
*/
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/cache_impl.hh
--- a/src/mem/cache/cache_impl.hh Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/cache_impl.hh Tue Sep 11 14:14:49 2012 -0400
@@ -170,7 +170,9 @@
pkt->assertMemInhibit();
}
// on ReadExReq we give up our copy unconditionally
- tags->invalidateBlk(blk);
+ assert(blk != tempBlock);
+ tags->invalidate(blk);
+ blk->invalidate();
} else if (blk->isWritable() && !pending_downgrade
&& !pkt->sharedAsserted() && !pkt->req->isInstFetch()) {
// we can give the requester an exclusive copy (by not
@@ -210,7 +212,9 @@
// to just ack those as long as we have an exclusive
// copy at this level.
assert(pkt->isUpgrade());
- tags->invalidateBlk(blk);
+ assert(blk != tempBlock);
+ tags->invalidate(blk);
+ blk->invalidate();
}
}
@@ -280,7 +284,8 @@
} else if (pkt->isWrite()) {
blk = tags->findBlock(pkt->getAddr());
if (blk != NULL) {
- tags->invalidateBlk(blk);
+ tags->invalidate(blk);
+ blk->invalidate();
}
}
@@ -444,7 +449,8 @@
} else if (pkt->isWrite()) {
BlkType *blk = tags->findBlock(pkt->getAddr());
if (blk != NULL) {
- tags->invalidateBlk(blk);
+ tags->invalidate(blk);
+ blk->invalidate();
}
}
@@ -644,7 +650,8 @@
if (pkt->isInvalidate()) {
BlkType *blk = tags->findBlock(pkt->getAddr());
if (blk && blk->isValid()) {
- tags->invalidateBlk(blk);
+ tags->invalidate(blk);
+ blk->invalidate();
DPRINTF(Cache, "rcvd mem-inhibited %s on 0x%x: invalidating\n",
pkt->cmdString(), pkt->getAddr());
}
@@ -953,9 +960,11 @@
mshr->popTarget();
}
- if (blk) {
+ if (blk && blk->isValid()) {
if (pkt->isInvalidate() || mshr->hasPostInvalidate()) {
- tags->invalidateBlk(blk);
+ assert(blk != tempBlock);
+ tags->invalidate(blk);
+ blk->invalidate();
} else if (mshr->hasPostDowngrade()) {
blk->status &= ~BlkWritable;
}
@@ -988,8 +997,7 @@
if (blk->isDirty()) {
allocateWriteBuffer(writebackBlk(blk), time, true);
}
- blk->status &= ~BlkValid;
- tags->invalidateBlk(blk);
+ blk->invalidate();
}
delete pkt;
@@ -1087,8 +1095,8 @@
tags->insertBlock(pkt->getAddr(), blk, id);
}
- // starting from scratch with a new block
- blk->status = 0;
+ // we should never be overwriting a valid block
+ assert(!blk->isValid());
} else {
// existing block... probably an upgrade
assert(blk->tag == tags->extractTag(addr));
@@ -1259,7 +1267,9 @@
// Do this last in case it deallocates block data or something
// like that
if (invalidate) {
- tags->invalidateBlk(blk);
+ assert(blk != tempBlock);
+ tags->invalidate(blk);
+ blk->invalidate();
}
}
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/fa_lru.cc
--- a/src/mem/cache/tags/fa_lru.cc Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/fa_lru.cc Tue Sep 11 14:14:49 2012 -0400
@@ -152,13 +152,10 @@
}
void
-FALRU::invalidateBlk(FALRU::BlkType *blk)
+FALRU::invalidate(FALRU::BlkType *blk)
{
- if (blk) {
- blk->status = 0;
- blk->isTouched = false;
- tagsInUse--;
- }
+ assert(blk);
+ tagsInUse--;
}
FALRUBlk*
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/fa_lru.hh
--- a/src/mem/cache/tags/fa_lru.hh Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/fa_lru.hh Tue Sep 11 14:14:49 2012 -0400
@@ -168,7 +168,7 @@
* Invalidate a cache block.
* @param blk The block to invalidate.
*/
- void invalidateBlk(BlkType *blk);
+ void invalidate(BlkType *blk);
/**
* Access block and update replacement data. May not succeed, in which
case
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/iic.cc
--- a/src/mem/cache/tags/iic.cc Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/iic.cc Tue Sep 11 14:14:49 2012 -0400
@@ -617,7 +617,7 @@
}
void
-IIC::invalidateBlk(IIC::BlkType *tag_ptr)
+IIC::invalidate(IIC::BlkType *tag_ptr)
{
if (tag_ptr) {
for (int i = 0; i < tag_ptr->numData; ++i) {
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/iic.hh
--- a/src/mem/cache/tags/iic.hh Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/iic.hh Tue Sep 11 14:14:49 2012 -0400
@@ -408,7 +408,7 @@
* Invalidate a block.
* @param blk The block to invalidate.
*/
- void invalidateBlk(BlkType *blk);
+ void invalidate(BlkType *blk);
/**
* Access block and update replacement data. May not succeed, in which
case
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/lru.cc
--- a/src/mem/cache/tags/lru.cc Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/lru.cc Tue Sep 11 14:14:49 2012 -0400
@@ -92,7 +92,7 @@
++blkIndex;
// invalidate new cache block
- blk->status = 0;
+ blk->invalidate();
//EGH Fix Me : do we need to initialize blk?
@@ -186,8 +186,11 @@
// deal with evicted block
assert(blk->srcMasterId < cache->system->maxMasters());
occupancies[blk->srcMasterId]--;
+
+ blk->invalidate();
}
+ blk->isTouched = true;
// Set tag for new block. Caller is responsible for setting status.
blk->tag = extractTag(addr);
@@ -201,23 +204,18 @@
}
void
-LRU::invalidateBlk(BlkType *blk)
+LRU::invalidate(BlkType *blk)
{
- if (blk) {
- if (blk->isValid()) {
- tagsInUse--;
- assert(blk->srcMasterId < cache->system->maxMasters());
- occupancies[blk->srcMasterId]--;
- blk->srcMasterId = Request::invldMasterId;
- }
- blk->status = 0;
- blk->isTouched = false;
- blk->clearLoadLocks();
+ assert(blk);
+ assert(blk->isValid());
+ tagsInUse--;
+ assert(blk->srcMasterId < cache->system->maxMasters());
+ occupancies[blk->srcMasterId]--;
+ blk->srcMasterId = Request::invldMasterId;
- // should be evicted before valid blocks
- unsigned set = blk->set;
- sets[set].moveToTail(blk);
- }
+ // should be evicted before valid blocks
+ unsigned set = blk->set;
+ sets[set].moveToTail(blk);
}
void
diff -r 5cab5448909c -r a42caed28e1f src/mem/cache/tags/lru.hh
--- a/src/mem/cache/tags/lru.hh Tue Sep 11 09:34:40 2012 -0500
+++ b/src/mem/cache/tags/lru.hh Tue Sep 11 14:14:49 2012 -0400
@@ -127,7 +127,7 @@
* Invalidate the given block.
* @param blk The block to invalidate.
*/
- void invalidateBlk(BlkType *blk);
+ void invalidate(BlkType *blk);
/**
* Access block and update replacement data. May not succeed, in which
case
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev