Nikos Nikoleris has uploaded this change for review. ( https://gem5-review.googlesource.com/10430

Change subject: mem-cache: Add helper function to perform evictions
......................................................................

mem-cache: Add helper function to perform evictions

Change-Id: I2df24eb1a8516220bec9b685c8c09bf55be18681
---
M src/mem/cache/cache.cc
M src/mem/cache/cache.hh
2 files changed, 41 insertions(+), 21 deletions(-)



diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 16846ee..3419d1e 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -303,11 +303,7 @@
         // flush and invalidate any existing block
CacheBlk *old_blk(tags->findBlock(pkt->getAddr(), pkt->isSecure()));
         if (old_blk && old_blk->isValid()) {
-            if (old_blk->isDirty() || writebackClean)
-                writebacks.push_back(writebackBlk(old_blk));
-            else
-                writebacks.push_back(cleanEvictBlk(old_blk));
-            invalidateBlock(old_blk);
+            evictBlock(old_blk, writebacks);
         }

         blk = nullptr;
@@ -1246,9 +1242,7 @@
             schedule(writebackTempBlockAtomicEvent, curTick());
         }

-        tempBlockWriteback = (blk->isDirty() || writebackClean) ?
-            writebackBlk(blk) : cleanEvictBlk(blk);
-        invalidateBlock(blk);
+        tempBlockWriteback = evictBlock(blk);
     }

     if (pkt->needsResponse()) {
@@ -1641,10 +1635,7 @@

// if we used temp block, check to see if its valid and then clear it out
     if (blk == tempBlock && tempBlock->isValid()) {
-        PacketPtr wb_pkt = tempBlock->isDirty() || writebackClean ?
-            writebackBlk(blk) : cleanEvictBlk(blk);
-        writebacks.push_back(wb_pkt);
-        invalidateBlock(tempBlock);
+        evictBlock(blk, writebacks);
     }

     const Tick forward_time = clockEdge(forwardLatency) + pkt->headerDelay;
@@ -1656,6 +1647,23 @@
 }

 PacketPtr
+Cache::evictBlock(CacheBlk *blk)
+{
+    PacketPtr pkt = (blk->isDirty() || writebackClean) ?
+        writebackBlk(blk) : cleanEvictBlk(blk);
+
+    invalidateBlock(blk);
+
+    return pkt;
+}
+
+void
+Cache::evictBlock(CacheBlk *blk, PacketList &writebacks)
+{
+    writebacks.push_back(evictBlock(blk));
+}
+
+PacketPtr
 Cache::writebackBlk(CacheBlk *blk)
 {
     chatty_assert(!isReadOnly || writebackClean,
@@ -1848,15 +1856,7 @@
             if (blk->wasPrefetched()) {
                 unusedPrefetches++;
             }
-            // Will send up Writeback/CleanEvict snoops via isCachedAbove
-            // when pushing this writeback list into the write buffer.
-            if (blk->isDirty() || writebackClean) {
-                // Save writeback packet for handling by caller
-                writebacks.push_back(writebackBlk(blk));
-            } else {
-                writebacks.push_back(cleanEvictBlk(blk));
-            }
-            invalidateBlock(blk);
+            evictBlock(blk, writebacks);
             replacements++;
         }
     }
diff --git a/src/mem/cache/cache.hh b/src/mem/cache/cache.hh
index a90ffd5..ad67cde 100644
--- a/src/mem/cache/cache.hh
+++ b/src/mem/cache/cache.hh
@@ -496,6 +496,26 @@
bool is_timing, bool is_deferred, bool pending_inval);

     /**
+     * Evict a cache block.
+     *
+     * Performs a writeback if necesssary and invalidates the block
+     *
+     * @param blk Block to invalidate
+     * @return A packet with the writeback, can be nullptr
+     */
+    virtual PacketPtr evictBlock(CacheBlk *blk);
+
+    /**
+     * Evict a cache block.
+     *
+     * Performs a writeback if necesssary and invalidates the block
+     *
+     * @param blk Block to invalidate
+     * @param writebacks Return a list of packets with writebacks
+     */
+    virtual void evictBlock(CacheBlk *blk, PacketList &writebacks);
+
+    /**
      * Create a writeback request for the given block.
      * @param blk The block to writeback.
      * @return The writeback request for the block.

--
To view, visit https://gem5-review.googlesource.com/10430
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I2df24eb1a8516220bec9b685c8c09bf55be18681
Gerrit-Change-Number: 10430
Gerrit-PatchSet: 1
Gerrit-Owner: Nikos Nikoleris <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to