mem-cache: Delegate block invalidation to block allocation
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 10 May 2018 10:49:09 +0000 (11:49 +0100)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 31 May 2018 15:11:04 +0000 (15:11 +0000)
For a block replacement we first select a victim block, we invalidate
it and then populate it with the new information. Prior to this change
BaseTags::insertBlock() did the invalidation and filled in the block
with the new information. Now that the replacements stat is moved to
the BaseCache, insertBlock does not need to perform the invalidation
and as a result we can unify the block eviction code in BaseCache.

Change-Id: I5bdf00b2dab2752ed2137ab7201ed1dc451333b3
Reviewed-on: https://gem5-review.googlesource.com/10429
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
src/mem/cache/cache.cc
src/mem/cache/tags/base.cc

index 5d7fcca84d8b40438f6ba60ce95e0bb78d6d20d9..c755fb29ce366c2848e789c1425ca9abbe4e5c0d 100644 (file)
@@ -1858,6 +1858,7 @@ Cache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks)
             } else {
                 writebacks.push_back(cleanEvictBlk(blk));
             }
+            invalidateBlock(blk);
             replacements++;
         }
     }
index dfd6976fd80223d6deb0163cd3a46a93e5256df6..7d0a939898ff2feaa0f99ab5c40dbf7d36e0cf62 100644 (file)
@@ -75,13 +75,11 @@ BaseTags::setCache(BaseCache *_cache)
 void
 BaseTags::insertBlock(PacketPtr pkt, CacheBlk *blk)
 {
+    assert(!blk->isValid());
+
     // Get address
     Addr addr = pkt->getAddr();
 
-    if (blk->isValid()) {
-        invalidate(blk);
-    }
-
     // Previous block, if existed, has been removed, and now we have
     // to insert the new one