From 7f3cd9a9fd636c1e48dcec20de3f6c14214d0ce4 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Wed, 24 Feb 2010 13:46:55 -0800 Subject: [PATCH] cache stats: account for writebacks and/or device occupancy in the cache. Plus, a minor bugfix that neglects to update blk->contextSrc in certain cases on a cache insert. --- src/mem/cache/tags/base.cc | 2 +- src/mem/cache/tags/lru.cc | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mem/cache/tags/base.cc b/src/mem/cache/tags/base.cc index 8c6c145ca..41cc11b23 100644 --- a/src/mem/cache/tags/base.cc +++ b/src/mem/cache/tags/base.cc @@ -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) diff --git a/src/mem/cache/tags/lru.cc b/src/mem/cache/tags/lru.cc index 0da2a72e9..0667c5428 100644 --- a/src/mem/cache/tags/lru.cc +++ b/src/mem/cache/tags/lru.cc @@ -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()]--; } } } -- 2.30.2