summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingyuan <xiang_my@outlook.com>2019-09-02 17:48:03 -0500
committerMingyuan Xiang <mxiang6@wisc.edu>2019-10-13 16:41:33 +0000
commitaae1ec8a906c2145fdb2bbcb9f2aa9f2e9ca7d03 (patch)
tree51b07ee6d5dd6738873f21d7197b7f57638d135c
parentb8ecd2784c24879712b598fe940d8a73ec6842b1 (diff)
downloadgem5-aae1ec8a906c2145fdb2bbcb9f2aa9f2e9ca7d03.tar.xz
mem-cache: set the second chance to false when inserting a block
Modify second chance replacement policy so that entries are inserted without a second chance. Previously, the second chance bit was set to true when a cache line was inserted. So the cache line would gain its second chance when inserting. This is wrong because the cache block will only get a second chance when it hits. Here's a quoted citation for the second chance replacement policy: "Whenever the algorithm examines a page entry, it extracts the associated usage bit and enters it into the high-order position of a k-bit shift register after shifting the contents of the register one bit-position lower. Then if the shift register is nonzero, the page is retained; if the shift register is zero, the page is replaced by the new page. In either case the usage bit for the page is turned off and the circular list pointer is advanced." (A Paging Experiment with the Multics System, FJ Corbato, 1968) Change-Id: I0d07e56aa16c67dd36e0d490c3f457f91e46f320 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20882 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <jason@lowepower.com>
-rw-r--r--src/mem/cache/replacement_policies/second_chance_rp.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mem/cache/replacement_policies/second_chance_rp.cc b/src/mem/cache/replacement_policies/second_chance_rp.cc
index 64e667fe6..dda6f50cd 100644
--- a/src/mem/cache/replacement_policies/second_chance_rp.cc
+++ b/src/mem/cache/replacement_policies/second_chance_rp.cc
@@ -62,7 +62,8 @@ SecondChanceRP::invalidate(
}
void
-SecondChanceRP::touch(const std::shared_ptr<ReplacementData>& replacement_data) const
+SecondChanceRP::touch(const std::shared_ptr<ReplacementData>&
+ replacement_data) const
{
FIFORP::touch(replacement_data);
@@ -72,13 +73,14 @@ SecondChanceRP::touch(const std::shared_ptr<ReplacementData>& replacement_data)
}
void
-SecondChanceRP::reset(const std::shared_ptr<ReplacementData>& replacement_data) const
+SecondChanceRP::reset(const std::shared_ptr<ReplacementData>&
+ replacement_data) const
{
FIFORP::reset(replacement_data);
// Entries are inserted with a second chance
std::static_pointer_cast<SecondChanceReplData>(
- replacement_data)->hasSecondChance = true;
+ replacement_data)->hasSecondChance = false;
}
ReplaceableEntry*