Daniel Carvalho has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/22606 )

Change subject: mem-cache: Add multiple eviction stats
......................................................................

mem-cache: Add multiple eviction stats

Add stats to inform how many blocks were evicted due to a sector
replacement/eviction.

Change-Id: I886365506016d0888f835d182b3b65a808a9dccd
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22606
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Nikos Nikoleris <nikos.nikole...@arm.com>
Maintainer: Nikos Nikoleris <nikos.nikole...@arm.com>
---
M src/mem/cache/tags/compressed_tags.cc
M src/mem/cache/tags/sector_tags.cc
M src/mem/cache/tags/sector_tags.hh
3 files changed, 48 insertions(+), 3 deletions(-)

Approvals:
  Nikos Nikoleris: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/mem/cache/tags/compressed_tags.cc b/src/mem/cache/tags/compressed_tags.cc
index 1871a7a..d2ab7cf 100644
--- a/src/mem/cache/tags/compressed_tags.cc
+++ b/src/mem/cache/tags/compressed_tags.cc
@@ -138,7 +138,9 @@

// The whole superblock must be evicted to make room for the new one
         for (const auto& blk : victim_superblock->blks){
-            evict_blks.push_back(blk);
+            if (blk->isValid()) {
+                evict_blks.push_back(blk);
+            }
         }
     }

@@ -159,6 +161,9 @@
         }
     }

+    // Update number of sub-blocks evicted due to a replacement
+    sectorStats.evictionsReplacement[evict_blks.size()]++;
+
     return victim;
 }

diff --git a/src/mem/cache/tags/sector_tags.cc b/src/mem/cache/tags/sector_tags.cc
index 610cba8..d2fcd76 100644
--- a/src/mem/cache/tags/sector_tags.cc
+++ b/src/mem/cache/tags/sector_tags.cc
@@ -53,7 +53,8 @@
       replacementPolicy(p->replacement_policy),
       numBlocksPerSector(p->num_blocks_per_sector),
       numSectors(numBlocks / numBlocksPerSector),
-      sectorShift(floorLog2(blkSize)), sectorMask(numBlocksPerSector - 1)
+      sectorShift(floorLog2(blkSize)), sectorMask(numBlocksPerSector - 1),
+      sectorStats(stats, *this)
 {
     // Check parameters
     fatal_if(blkSize < 4 || !isPowerOf2(blkSize),
@@ -260,10 +261,15 @@
     } else {
         // The whole sector must be evicted to make room for the new sector
         for (const auto& blk : victim_sector->blks){
-            evict_blks.push_back(blk);
+            if (blk->isValid()) {
+                evict_blks.push_back(blk);
+            }
         }
     }

+    // Update number of sub-blocks evicted due to a replacement
+    sectorStats.evictionsReplacement[evict_blks.size()]++;
+
     return victim;
 }

@@ -282,6 +288,27 @@
     return sec_addr | ((Addr)blk_cast->getSectorOffset() << sectorShift);
 }

+SectorTags::SectorTagsStats::SectorTagsStats(BaseTagStats &base_group,
+    SectorTags& _tags)
+  : Stats::Group(&base_group), tags(_tags),
+    evictionsReplacement(this, "evictions_replacement",
+        "Number of blocks evicted due to a replacement")
+{
+}
+
+void
+SectorTags::SectorTagsStats::regStats()
+{
+    Stats::Group::regStats();
+
+    evictionsReplacement.init(tags.numBlocksPerSector + 1);
+    for (unsigned i = 0; i <= tags.numBlocksPerSector; ++i) {
+        evictionsReplacement.subname(i, std::to_string(i));
+ evictionsReplacement.subdesc(i, "Number of replacements that caused " \
+            "the eviction of " + std::to_string(i) + " blocks");
+    }
+}
+
 void
 SectorTags::forEachBlk(std::function<void(CacheBlk &)> visitor)
 {
diff --git a/src/mem/cache/tags/sector_tags.hh b/src/mem/cache/tags/sector_tags.hh
index 905a87a..3ad59e3 100644
--- a/src/mem/cache/tags/sector_tags.hh
+++ b/src/mem/cache/tags/sector_tags.hh
@@ -40,6 +40,7 @@
 #include <string>
 #include <vector>

+#include "base/statistics.hh"
 #include "mem/cache/tags/base.hh"
 #include "mem/cache/tags/sector_blk.hh"
 #include "mem/packet.hh"
@@ -88,6 +89,18 @@
     /** Mask out all bits that aren't part of the sector tag. */
     const unsigned sectorMask;

+    struct SectorTagsStats : public Stats::Group
+    {
+        const SectorTags& tags;
+
+        SectorTagsStats(BaseTagStats &base_group, SectorTags& _tags);
+
+        void regStats() override;
+
+        /** Number of sub-blocks evicted due to a replacement. */
+        Stats::Vector evictionsReplacement;
+    } sectorStats;
+
   public:
     /** Convenience typedef. */
      typedef SectorTagsParams Params;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/22606
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I886365506016d0888f835d182b3b65a808a9dccd
Gerrit-Change-Number: 22606
Gerrit-PatchSet: 5
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to