cache stats: account for writebacks and/or device occupancy in the cache.
authorLisa Hsu <Lisa.Hsu@amd.com>
Wed, 24 Feb 2010 21:46:55 +0000 (13:46 -0800)
committerLisa Hsu <Lisa.Hsu@amd.com>
Wed, 24 Feb 2010 21:46:55 +0000 (13:46 -0800)
Plus, a minor bugfix that neglects to update blk->contextSrc in certain cases on a cache insert.

src/mem/cache/tags/base.cc
src/mem/cache/tags/lru.cc

index 8c6c145ca46188ace1cdafb67f8b2b670c902640..41cc11b234ce71813a17ca21634a558499320ec5 100644 (file)
@@ -88,7 +88,7 @@ BaseTags::regStats(const string &name)
         ;
 
     occupancies
-        .init(cache->numCpus())
+        .init(cache->numCpus() + 1)
         .name(name + ".occ_blocks")
         .desc("Average occupied blocks per context")
         .flags(nozero | nonan)
index 0da2a72e926ac9a51f31cb5f8b13d5cedb7b8a9e..0667c5428e767a4d021bc0506b1bb711902217a2 100644 (file)
@@ -162,6 +162,8 @@ LRU::findVictim(Addr addr, PacketList &writebacks)
         if (blk->contextSrc != -1) {
             occupancies[blk->contextSrc % cache->numCpus()]--;
             blk->contextSrc = -1;
+        } else {
+            occupancies[cache->numCpus()]--;
         }
 
         DPRINTF(CacheRepl, "set %x: selecting blk %x for replacement\n",
@@ -188,8 +190,10 @@ LRU::insertBlock(Addr addr, BlkType *blk, int context_src)
     // deal with what we are bringing in
     if (context_src != -1) {
         occupancies[context_src % cache->numCpus()]++;
-        blk->contextSrc = context_src;
+    } else {
+        occupancies[cache->numCpus()]++;
     }
+    blk->contextSrc = context_src;
 
     unsigned set = extractSet(addr);
     sets[set].moveToHead(blk);
@@ -206,6 +210,8 @@ LRU::invalidateBlk(BlkType *blk)
         if (blk->contextSrc != -1) {
             occupancies[blk->contextSrc % cache->numCpus()]--;
             blk->contextSrc = -1;
+        } else {
+            occupancies[cache->numCpus()]--;
         }
     }
 }