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.
This commit is contained in:
parent
fe5deb4a22
commit
584eba3ab6
8 changed files with 53 additions and 38 deletions
10
src/mem/cache/blk.hh
vendored
10
src/mem/cache/blk.hh
vendored
|
@ -188,6 +188,16 @@ class CacheBlk
|
|||
return (status & BlkValid) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
34
src/mem/cache/cache_impl.hh
vendored
34
src/mem/cache/cache_impl.hh
vendored
|
@ -170,7 +170,9 @@ Cache<TagStore>::satisfyCpuSideRequest(PacketPtr pkt, BlkType *blk,
|
|||
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 @@ Cache<TagStore>::satisfyCpuSideRequest(PacketPtr pkt, BlkType *blk,
|
|||
// 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 @@ Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk,
|
|||
} else if (pkt->isWrite()) {
|
||||
blk = tags->findBlock(pkt->getAddr());
|
||||
if (blk != NULL) {
|
||||
tags->invalidateBlk(blk);
|
||||
tags->invalidate(blk);
|
||||
blk->invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +449,8 @@ Cache<TagStore>::timingAccess(PacketPtr pkt)
|
|||
} 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 @@ Cache<TagStore>::atomicAccess(PacketPtr pkt)
|
|||
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 @@ Cache<TagStore>::handleResponse(PacketPtr pkt)
|
|||
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 @@ Cache<TagStore>::handleResponse(PacketPtr pkt)
|
|||
if (blk->isDirty()) {
|
||||
allocateWriteBuffer(writebackBlk(blk), time, true);
|
||||
}
|
||||
blk->status &= ~BlkValid;
|
||||
tags->invalidateBlk(blk);
|
||||
blk->invalidate();
|
||||
}
|
||||
|
||||
delete pkt;
|
||||
|
@ -1087,8 +1095,8 @@ Cache<TagStore>::handleFill(PacketPtr pkt, BlkType *blk,
|
|||
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 @@ Cache<TagStore>::handleSnoop(PacketPtr pkt, BlkType *blk,
|
|||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
9
src/mem/cache/tags/fa_lru.cc
vendored
9
src/mem/cache/tags/fa_lru.cc
vendored
|
@ -152,13 +152,10 @@ FALRU::hashLookup(Addr addr) const
|
|||
}
|
||||
|
||||
void
|
||||
FALRU::invalidateBlk(FALRU::BlkType *blk)
|
||||
FALRU::invalidate(FALRU::BlkType *blk)
|
||||
{
|
||||
if (blk) {
|
||||
blk->status = 0;
|
||||
blk->isTouched = false;
|
||||
tagsInUse--;
|
||||
}
|
||||
assert(blk);
|
||||
tagsInUse--;
|
||||
}
|
||||
|
||||
FALRUBlk*
|
||||
|
|
2
src/mem/cache/tags/fa_lru.hh
vendored
2
src/mem/cache/tags/fa_lru.hh
vendored
|
@ -168,7 +168,7 @@ public:
|
|||
* 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
|
||||
|
|
2
src/mem/cache/tags/iic.cc
vendored
2
src/mem/cache/tags/iic.cc
vendored
|
@ -617,7 +617,7 @@ IIC::secondaryChain(Addr tag, unsigned long chain_ptr,
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
2
src/mem/cache/tags/iic.hh
vendored
2
src/mem/cache/tags/iic.hh
vendored
|
@ -408,7 +408,7 @@ class IIC : public BaseTags
|
|||
* 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
|
||||
|
|
30
src/mem/cache/tags/lru.cc
vendored
30
src/mem/cache/tags/lru.cc
vendored
|
@ -92,7 +92,7 @@ LRU::LRU(unsigned _numSets, unsigned _blkSize, unsigned _assoc,
|
|||
++blkIndex;
|
||||
|
||||
// invalidate new cache block
|
||||
blk->status = 0;
|
||||
blk->invalidate();
|
||||
|
||||
//EGH Fix Me : do we need to initialize blk?
|
||||
|
||||
|
@ -186,8 +186,11 @@ LRU::insertBlock(Addr addr, BlkType *blk, int master_id)
|
|||
// 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 @@ LRU::insertBlock(Addr addr, BlkType *blk, int master_id)
|
|||
}
|
||||
|
||||
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
|
||||
|
|
2
src/mem/cache/tags/lru.hh
vendored
2
src/mem/cache/tags/lru.hh
vendored
|
@ -127,7 +127,7 @@ public:
|
|||
* 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
|
||||
|
|
Loading…
Reference in a new issue