Yu-hsin Wang has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/64474?usp=email )

Change subject: systemc: prevent from invalidate callback re-registration
......................................................................

systemc: prevent from invalidate callback re-registration

Remove the redundant callback to save the memory.

Change-Id: Iafa6ada06f62ac2928a580c25ebbcbbe3f195670
---
M src/systemc/tlm_bridge/tlm_to_gem5.cc
M src/systemc/tlm_bridge/tlm_to_gem5.hh
2 files changed, 25 insertions(+), 6 deletions(-)



diff --git a/src/systemc/tlm_bridge/tlm_to_gem5.cc b/src/systemc/tlm_bridge/tlm_to_gem5.cc
index 9fd887d..7aec14f 100644
--- a/src/systemc/tlm_bridge/tlm_to_gem5.cc
+++ b/src/systemc/tlm_bridge/tlm_to_gem5.cc
@@ -285,6 +285,7 @@
 {
     socket->invalidate_direct_mem_ptr(
             backdoor.range().start(), backdoor.range().end());
+    requestedBackdoors.erase(const_cast<gem5::MemBackdoorPtr>(&backdoor));
 }

 template <unsigned int BITWIDTH>
@@ -417,12 +418,16 @@
             access = (access_t)(access | tlm::tlm_dmi::DMI_ACCESS_WRITE);
         dmi_data.set_granted_access(access);

-        backdoor->addInvalidationCallback(
-            [this](const MemBackdoor &backdoor)
-            {
-                invalidateDmi(backdoor);
-            }
-        );
+        // We only need to register the callback at the first time.
+ if (requestedBackdoors.find(backdoor) == requestedBackdoors.end()) {
+            backdoor->addInvalidationCallback(
+                [this](const MemBackdoor &backdoor)
+                {
+                    invalidateDmi(backdoor);
+                }
+            );
+            requestedBackdoors.emplace(backdoor);
+        }
     }

     gem5::Packet::SenderState *senderState = pkt->popSenderState();
diff --git a/src/systemc/tlm_bridge/tlm_to_gem5.hh b/src/systemc/tlm_bridge/tlm_to_gem5.hh
index e452d8b..deb332e 100644
--- a/src/systemc/tlm_bridge/tlm_to_gem5.hh
+++ b/src/systemc/tlm_bridge/tlm_to_gem5.hh
@@ -59,6 +59,7 @@
 #define __SYSTEMC_TLM_BRIDGE_TLM_TO_GEM5_HH__

 #include <functional>
+#include <unordered_set>
 #include <utility>

 #include "mem/port.hh"
@@ -122,6 +123,8 @@

     bool responseInProgress;

+    std::unordered_set<gem5::MemBackdoorPtr> requestedBackdoors;
+
     BridgeRequestPort bmp;
     tlm_utils::simple_target_socket<
         TlmToGem5Bridge<BITWIDTH>, BITWIDTH> socket;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/64474?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iafa6ada06f62ac2928a580c25ebbcbbe3f195670
Gerrit-Change-Number: 64474
Gerrit-PatchSet: 1
Gerrit-Owner: Yu-hsin Wang <yuhsi...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to