mem-cache: Fix promoting of targets that need writable
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Sat, 17 Mar 2018 00:52:52 +0000 (00:52 +0000)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Fri, 22 Jun 2018 17:39:16 +0000 (17:39 +0000)
There are cases where a request which does not need a writable copy
gets an response upgraded reponse and fills in a writable copy. When
this happens, we promote deferred MSHR targets that were deferred
because they needed a writable copy to service them immediately.

Previously, we would uncoditionally promote deferred targets. Since
the deferred targets might contain a cache invalidation operation, we
have to make sure that any targets following the cache invalidation is
not promoted.

Change-Id: I1f7b28f7d35f84329e065c8f63117db21852365a
Reviewed-on: https://gem5-review.googlesource.com/11016
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

src/mem/cache/mshr.cc
src/mem/cache/mshr.hh

index d6208dde97621166195726b55fd32ab5f9b3c19c..8ef8a2ca2c4fa81d647677c1bbe269e3f714cef9 100644 (file)
@@ -566,10 +566,20 @@ MSHR::promoteWritable()
         // if any of the deferred targets were upper-level cache
         // requests marked downstreamPending, need to clear that
         assert(!downstreamPending);  // not pending here anymore
-        deferredTargets.clearDownstreamPending();
-        // this clears out deferredTargets too
-        targets.splice(targets.end(), deferredTargets);
-        deferredTargets.resetFlags();
+
+        auto last_it = std::find_if(
+            deferredTargets.begin(), deferredTargets.end(),
+            [](MSHR::Target &t) {
+                assert(t.source == Target::FromCPU);
+                return t.pkt->req->isCacheInvalidate();
+            });
+        deferredTargets.clearDownstreamPending(deferredTargets.begin(),
+                                               last_it);
+        targets.splice(targets.end(), deferredTargets,
+                       deferredTargets.begin(), last_it);
+        // We need to update the flags for the target lists after the
+        // modifications
+        deferredTargets.populateFlags();
     }
 }
 
index f93d3c0f58476886494557de0e7c5a9c5b5258dc..71c2da2c482a949cf18f40e149168f28f6120efa 100644 (file)
@@ -385,6 +385,13 @@ class MSHR : public QueueEntry, public Printable
 
     bool promoteDeferredTargets();
 
+    /**
+     * Promotes deferred targets that do not require writable
+     *
+     * Requests in the deferred target list are moved to the target
+     * list up until the first target that is a cache maintenance
+     * operation or needs a writable copy of the block
+     */
     void promoteWritable();
 
     bool checkFunctional(PacketPtr pkt);