diff options
author | Daniel R. Carvalho <odanrc@yahoo.com.br> | 2018-06-06 14:52:42 +0200 |
---|---|---|
committer | Daniel Carvalho <odanrc@yahoo.com.br> | 2018-06-13 07:58:00 +0000 |
commit | f47e3289f94c2fd24e23566cd5dfcb20e293290e (patch) | |
tree | 3ba530f10075f7839a2438aea0ac0139ca5b8df3 /src/mem/cache/base.cc | |
parent | 285a919dc1067c32e5eac22aaa805f62beaac6c4 (diff) | |
download | gem5-f47e3289f94c2fd24e23566cd5dfcb20e293290e.tar.xz |
mem-cache: Insert on block allocation
When a block is being replaced in an allocation, if successfull,
the block will be inserted. Therefore we move the insertion
functionality to allocateBlock().
allocateBlock's signature has been modified to allow this
modification.
Change-Id: I60d17a83ff4f3021fdc976378868ccde6c7507bc
Reviewed-on: https://gem5-review.googlesource.com/10812
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Diffstat (limited to 'src/mem/cache/base.cc')
-rw-r--r-- | src/mem/cache/base.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mem/cache/base.cc b/src/mem/cache/base.cc index a5ad07d6c..e43c3d920 100644 --- a/src/mem/cache/base.cc +++ b/src/mem/cache/base.cc @@ -970,13 +970,12 @@ BaseCache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, if (!blk) { // need to do a replacement - blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), writebacks); + blk = allocateBlock(pkt, writebacks); if (!blk) { // no replaceable block available: give up, fwd to next level. incMissCount(pkt); return false; } - tags->insertBlock(pkt, blk); blk->status |= (BlkValid | BlkReadable); } @@ -1028,15 +1027,13 @@ BaseCache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, return false; } else { // a writeback that misses needs to allocate a new block - blk = allocateBlock(pkt->getAddr(), pkt->isSecure(), - writebacks); + blk = allocateBlock(pkt, writebacks); if (!blk) { // no replaceable block available: give up, fwd to // next level. incMissCount(pkt); return false; } - tags->insertBlock(pkt, blk); blk->status |= (BlkValid | BlkReadable); } @@ -1124,7 +1121,7 @@ BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, // need to do a replacement if allocating, otherwise we stick // with the temporary storage - blk = allocate ? allocateBlock(addr, is_secure, writebacks) : nullptr; + blk = allocate ? allocateBlock(pkt, writebacks) : nullptr; if (!blk) { // No replaceable block or a mostly exclusive @@ -1135,8 +1132,6 @@ BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, tempBlock->insert(addr, is_secure); DPRINTF(Cache, "using temp block for %#llx (%s)\n", addr, is_secure ? "s" : "ns"); - } else { - tags->insertBlock(pkt, blk); } // we should never be overwriting a valid block @@ -1205,8 +1200,14 @@ BaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, } CacheBlk* -BaseCache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) +BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks) { + // Get address + const Addr addr = pkt->getAddr(); + + // Get secure bit + const bool is_secure = pkt->isSecure(); + // Find replacement victim std::vector<CacheBlk*> evict_blks; CacheBlk *victim = tags->findVictim(addr, is_secure, evict_blks); @@ -1257,6 +1258,9 @@ BaseCache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) } } + // Insert new block at victimized entry + tags->insertBlock(pkt, victim); + return victim; } |