From: Mingyuan Date: Mon, 2 Sep 2019 22:48:03 +0000 (-0500) Subject: mem-cache: set the second chance to false when inserting a block X-Git-Tag: v19.0.0.0~453 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aae1ec8a906c2145fdb2bbcb9f2aa9f2e9ca7d03;p=gem5.git 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 Reviewed-by: Daniel Carvalho Maintainer: Jason Lowe-Power --- 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& replacement_data) const +SecondChanceRP::touch(const std::shared_ptr& + replacement_data) const { FIFORP::touch(replacement_data); @@ -72,13 +73,14 @@ SecondChanceRP::touch(const std::shared_ptr& replacement_data) } void -SecondChanceRP::reset(const std::shared_ptr& replacement_data) const +SecondChanceRP::reset(const std::shared_ptr& + replacement_data) const { FIFORP::reset(replacement_data); // Entries are inserted with a second chance std::static_pointer_cast( - replacement_data)->hasSecondChance = true; + replacement_data)->hasSecondChance = false; } ReplaceableEntry*