summaryrefslogtreecommitdiff
path: root/src/mem/packet.hh
diff options
context:
space:
mode:
authorSascha Bischoff <sascha.bischoff@arm.com>2013-02-19 05:56:06 -0500
committerSascha Bischoff <sascha.bischoff@arm.com>2013-02-19 05:56:06 -0500
commit86a4d092691bdcdc7b60f7cacd7d5b5c54d9a1ca (patch)
tree6fdc88e25bc34f2a5275c21c27e4c72608303cbf /src/mem/packet.hh
parent0622f30961fc32b967bb1ef784afc5a205b16f6e (diff)
downloadgem5-86a4d092691bdcdc7b60f7cacd7d5b5c54d9a1ca.tar.xz
mem: Fix SenderState related cache deadlock
This patch fixes a potential deadlock in the caches. This deadlock could occur when more than one cache is used in a system, and pkt->senderState is modified in between the two caches. This happened as the caches relied on the senderState remaining unchanged, and used it for instantaneous upstream communication with other caches. This issue has been addressed by iterating over the linked list of senderStates until we are either able to cast to a MSHR* or senderState is NULL. If the cast is successful, we know that the packet has previously passed through another cache, and therefore update the downstreamPending flag accordingly. Otherwise, we do nothing.
Diffstat (limited to 'src/mem/packet.hh')
-rw-r--r--src/mem/packet.hh19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mem/packet.hh b/src/mem/packet.hh
index 6da1fe97d..6d9e88b8f 100644
--- a/src/mem/packet.hh
+++ b/src/mem/packet.hh
@@ -454,6 +454,25 @@ class Packet : public Printable
*/
SenderState *popSenderState();
+ /**
+ * Go through the sender state stack and return the first instance
+ * that is of type T (as determined by a dynamic_cast). If there
+ * is no sender state of type T, NULL is returned.
+ *
+ * @return The topmost state of type T
+ */
+ template <typename T>
+ T * findNextSenderState() const
+ {
+ T *t = NULL;
+ SenderState* sender_state = senderState;
+ while (t == NULL && sender_state != NULL) {
+ t = dynamic_cast<T*>(sender_state);
+ sender_state = sender_state->predecessor;
+ }
+ return t;
+ }
+
/// Return the string name of the cmd field (for debugging and
/// tracing).
const std::string &cmdString() const { return cmd.toString(); }