summaryrefslogtreecommitdiff
path: root/src/mem/cache/replacement_policies
diff options
context:
space:
mode:
authorMingyuan <xiang_my@outlook.com>2019-09-02 17:43:59 -0500
committerMingyuan Xiang <mxiang6@wisc.edu>2019-10-12 20:50:48 +0000
commitb8ecd2784c24879712b598fe940d8a73ec6842b1 (patch)
treede38581e1cd4d0279073e8b21e861d9515377c4f /src/mem/cache/replacement_policies
parent75b19403a75f35f19773a387b3da698722d26924 (diff)
downloadgem5-b8ecd2784c24879712b598fe940d8a73ec6842b1.tar.xz
mem-cache: Fixed a bug in MRU replacement policy
The lastTouchTick is set to 0 when instantiate. This will cause the candidate[0] to get evicted over and over again in MRU replacement policy. To resolve this, break the search loop whenever it finds a cold cache line. Change-Id: I33aa57ebe0efca15986f62c3ae10a146bd2b779f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20881 Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
Diffstat (limited to 'src/mem/cache/replacement_policies')
-rw-r--r--src/mem/cache/replacement_policies/mru_rp.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mem/cache/replacement_policies/mru_rp.cc b/src/mem/cache/replacement_policies/mru_rp.cc
index b2e019f9a..534fb52f0 100644
--- a/src/mem/cache/replacement_policies/mru_rp.cc
+++ b/src/mem/cache/replacement_policies/mru_rp.cc
@@ -74,9 +74,14 @@ MRURP::getVictim(const ReplacementCandidates& candidates) const
// Visit all candidates to find victim
ReplaceableEntry* victim = candidates[0];
for (const auto& candidate : candidates) {
- // Update victim entry if necessary
- if (std::static_pointer_cast<MRUReplData>(
- candidate->replacementData)->lastTouchTick >
+ std::shared_ptr<MRUReplData> candidate_replacement_data =
+ std::static_pointer_cast<MRUReplData>(candidate->replacementData);
+
+ // Stop searching entry if a cache line that doesn't warm up is found.
+ if (candidate_replacement_data->lastTouchTick == 0) {
+ victim = candidate;
+ break;
+ } else if (candidate_replacement_data->lastTouchTick >
std::static_pointer_cast<MRUReplData>(
victim->replacementData)->lastTouchTick) {
victim = candidate;