changeset ace8383f2b7e in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ace8383f2b7e
description:
Cache: Fix the LRU policy for classic memory hierarchy
The LRU policy always evicted the least recently touched way, even if it
contained valid data and another way was invalid, as can happen if a
block has
been invalidated by coherance. This can result in caches never warming
up even
though they are replacing blocks. This modifies the LRU policy to move
blocks
to LRU position on invalidation.
diffstat:
src/mem/cache/tags/cacheset.cc | 24 ++++++++++++++++++++++++
src/mem/cache/tags/cacheset.hh | 6 ++++++
src/mem/cache/tags/lru.cc | 4 ++++
3 files changed, 34 insertions(+), 0 deletions(-)
diffs (61 lines):
diff -r fe8355ca560e -r ace8383f2b7e src/mem/cache/tags/cacheset.cc
--- a/src/mem/cache/tags/cacheset.cc Fri Jun 29 11:19:08 2012 -0400
+++ b/src/mem/cache/tags/cacheset.cc Fri Jun 29 11:21:58 2012 -0400
@@ -66,3 +66,27 @@
} while (next != blk);
}
+void
+CacheSet::moveToTail(CacheBlk *blk)
+{
+ // nothing to do if blk is already tail
+ if (blks[assoc-1] == blk)
+ return;
+
+ // write 'next' block into blks[i], moving from LRU to MRU
+ // until we overwrite the block we moved to tail.
+
+ // start by setting up to write 'blk' into tail
+ int i = assoc - 1;
+ CacheBlk *next = blk;
+
+ do {
+ assert(i >= 0);
+ // swap blks[i] and next
+ CacheBlk *tmp = blks[i];
+ blks[i] = next;
+ next = tmp;
+ --i;
+ } while (next != blk);
+}
+
diff -r fe8355ca560e -r ace8383f2b7e src/mem/cache/tags/cacheset.hh
--- a/src/mem/cache/tags/cacheset.hh Fri Jun 29 11:19:08 2012 -0400
+++ b/src/mem/cache/tags/cacheset.hh Fri Jun 29 11:21:58 2012 -0400
@@ -66,6 +66,12 @@
*/
void moveToHead(CacheBlk *blk);
+ /**
+ * Move the given block to the tail of the list.
+ * @param blk The block to move
+ */
+ void moveToTail(CacheBlk *blk);
+
};
#endif
diff -r fe8355ca560e -r ace8383f2b7e src/mem/cache/tags/lru.cc
--- a/src/mem/cache/tags/lru.cc Fri Jun 29 11:19:08 2012 -0400
+++ b/src/mem/cache/tags/lru.cc Fri Jun 29 11:21:58 2012 -0400
@@ -213,6 +213,10 @@
blk->status = 0;
blk->isTouched = false;
blk->clearLoadLocks();
+
+ // should be evicted before valid blocks
+ unsigned set = blk->set;
+ sets[set].moveToTail(blk);
}
}
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev