mem-cache: Move unused prefetches counter update
authorDaniel R. Carvalho <odanrc@yahoo.com.br>
Mon, 4 Feb 2019 12:57:25 +0000 (13:57 +0100)
committerDaniel Carvalho <odanrc@yahoo.com.br>
Thu, 12 Dec 2019 14:43:09 +0000 (14:43 +0000)
The number of unused prefetches should be updated every time
a block is invalidated, therefore we move the update to within
the corresponding function.

Change-Id: If3ac2ea43611525bd3c36d628d88382042fcb7dc
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18908
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/base.cc

index ebfb0927513d1fa0dd70766f8bc06006b0762e32..d56fcbeeef1f5d4da3839a6111a81a6800f46122 100644 (file)
@@ -883,9 +883,6 @@ BaseCache::updateCompressionData(CacheBlk *blk, const uint64_t* data,
     // Evict valid blocks
     for (const auto& evict_blk : evict_blks) {
         if (evict_blk->isValid()) {
-            if (evict_blk->wasPrefetched()) {
-                stats.unusedPrefetches++;
-            }
             evictBlock(evict_blk, writebacks);
         }
     }
@@ -1461,11 +1458,6 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
                 DPRINTF(CacheRepl, "Evicting %s (%#llx) to make room for " \
                         "%#llx (%s)\n", blk->print(), regenerateBlkAddr(blk),
                         addr, is_secure);
-
-                if (blk->wasPrefetched()) {
-                    stats.unusedPrefetches++;
-                }
-
                 evictBlock(blk, writebacks);
             }
         }
@@ -1489,6 +1481,11 @@ BaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks)
 void
 BaseCache::invalidateBlock(CacheBlk *blk)
 {
+    // If block is still marked as prefetched, then it hasn't been used
+    if (blk->wasPrefetched()) {
+        stats.unusedPrefetches++;
+    }
+
     // If handling a block present in the Tags, let it do its invalidation
     // process, which will update stats and invalidate the block itself
     if (blk != tempBlock) {