From a8ac84cdd39b7a37c0c9966e49eb3927f2e6abec Mon Sep 17 00:00:00 2001 From: Nikos Nikoleris Date: Thu, 10 May 2018 11:49:09 +0100 Subject: mem-cache: Delegate block invalidation to block allocation 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 Reviewed-by: Jason Lowe-Power Reviewed-by: Daniel Carvalho --- src/mem/cache/cache.cc | 1 + src/mem/cache/tags/base.cc | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc index 5d7fcca84..c755fb29c 100644 --- a/src/mem/cache/cache.cc +++ b/src/mem/cache/cache.cc @@ -1858,6 +1858,7 @@ Cache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) } else { writebacks.push_back(cleanEvictBlk(blk)); } + invalidateBlock(blk); replacements++; } } diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc index dfd6976fd..7d0a93989 100644 --- a/src/mem/cache/tags/base.cc +++ b/src/mem/cache/tags/base.cc @@ -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 -- cgit v1.2.3