From 09023d4158703a33f483593ffa76001a805d015b Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Sun, 16 Apr 2023 19:36:27 +0000 Subject: [PATCH] mem-ruby: Not flushing data to memory when there's no dirty block Currently, taking a checkpoint with a ruby cache involves moving all the dirty data in cache to memory. This is done by keeping **only** simulating the cache until all dirty data are flushed to the memory before taking the checkpoint. However, when the cache does not have dirty data, it is a problem if we keep simulating the cache. E.g., calling checkpoint caused the gem5 "empty event queue" assertion fault when running the ruby cache in atomic_noncaching mode. Since the mode bypasses the cache, all blocks are invalid and do not contain dirty data. Subsequently, there is no event placed to the event queue when we keep **only** simulating the cache before taking the checkpoint. This patch fixes this problem by checking if there is any actionable item when trying to move dirty data to memory. If there is no block contains dirty data, we simply choose not to continue simulating the cache before taking the checkpoint. Change-Id: Idfa09be51274c7fc8a340e9e33167f5b32d1b866 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69897 Reviewed-by: Jason Lowe-Power Tested-by: kokoro Maintainer: Bobby Bruce --- src/mem/ruby/system/CacheRecorder.cc | 6 ++++++ src/mem/ruby/system/CacheRecorder.hh | 2 ++ src/mem/ruby/system/RubySystem.cc | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/src/mem/ruby/system/CacheRecorder.cc b/src/mem/ruby/system/CacheRecorder.cc index e87b3f20b2..20a8a30ebc 100644 --- a/src/mem/ruby/system/CacheRecorder.cc +++ b/src/mem/ruby/system/CacheRecorder.cc @@ -207,5 +207,11 @@ CacheRecorder::aggregateRecords(uint8_t **buf, uint64_t total_size) return current_size; } +uint64_t +CacheRecorder::getNumRecords() const +{ + return m_records.size(); +} + } // namespace ruby } // namespace gem5 diff --git a/src/mem/ruby/system/CacheRecorder.hh b/src/mem/ruby/system/CacheRecorder.hh index 8dbd67f3ff..be95590313 100644 --- a/src/mem/ruby/system/CacheRecorder.hh +++ b/src/mem/ruby/system/CacheRecorder.hh @@ -85,6 +85,8 @@ class CacheRecorder uint64_t aggregateRecords(uint8_t **data, uint64_t size); + uint64_t getNumRecords() const; + /*! * Function for flushing the memory contents of the caches to the * main memory. It goes through the recorded contents of the caches, diff --git a/src/mem/ruby/system/RubySystem.cc b/src/mem/ruby/system/RubySystem.cc index 5a81513720..b38c903b09 100644 --- a/src/mem/ruby/system/RubySystem.cc +++ b/src/mem/ruby/system/RubySystem.cc @@ -218,6 +218,13 @@ RubySystem::memWriteback() } DPRINTF(RubyCacheTrace, "Cache Trace Complete\n"); + // If there is no dirty block, we don't need to flush the cache + if (m_cache_recorder->getNumRecords() == 0) + { + m_cooldown_enabled = false; + return; + } + // save the current tick value Tick curtick_original = curTick(); DPRINTF(RubyCacheTrace, "Recording current tick %ld\n", curtick_original);