cpu,sim: Delegate PCEvent scheduling from Systems to ThreadContexts.
authorGabe Black <gabeblack@google.com>
Thu, 10 Oct 2019 05:07:27 +0000 (22:07 -0700)
committerGabe Black <gabeblack@google.com>
Fri, 25 Oct 2019 22:42:31 +0000 (22:42 +0000)
The System keeps track of what events are live so new ThreadContexts
can have the same set of events as the other ThreadContexts.

Change-Id: Id22bfa0af7592a43d97be1564ca067b08ac1de7c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22106
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/cpu/checker/cpu_impl.hh
src/cpu/minor/execute.cc
src/cpu/o3/commit_impl.hh
src/cpu/simple/base.cc
src/sim/system.cc
src/sim/system.hh

index 81bf4c100b0ce77ec06bc34c3059bc8d7978d3ed..9e4bdcd5296a06ce281e78f492ef50d22371bd09 100644 (file)
@@ -412,7 +412,6 @@ Checker<Impl>::verify(const DynInstPtr &completed_inst)
             int count = 0;
             do {
                 oldpc = thread->instAddr();
-                system->pcEventQueue.service(oldpc, tc);
                 thread->pcEventQueue.service(oldpc, tc);
                 count++;
             } while (oldpc != thread->instAddr());
index 5bf3120c2a7735729f2a8e2ba4d01ff7355e460d..24506fcebef649bfe1989906d5b72558941a1675 100644 (file)
@@ -841,7 +841,6 @@ Execute::tryPCEvents(ThreadID thread_id)
     Addr oldPC;
     do {
         oldPC = thread->instAddr();
-        cpu.system->pcEventQueue.service(oldPC, thread);
         cpu.threads[thread_id]->pcEventQueue.service(oldPC, thread);
         num_pc_event_checks++;
     } while (oldPC != thread->instAddr());
index 23f10fe2ab67b280af6496595cea8dde31d71330..fa2d72494c910cb4a32e49c026e4761020a05b96 100644 (file)
@@ -1112,8 +1112,6 @@ DefaultCommit<Impl>::commitInsts()
                            !thread[tid]->trapPending);
                     do {
                         oldpc = pc[tid].instAddr();
-                        cpu->system->pcEventQueue.service(
-                                oldpc, thread[tid]->getTC());
                         thread[tid]->pcEventQueue.service(
                                 oldpc, thread[tid]->getTC());
                         count++;
index 8cecf70e4f5e994236abfbb2aff5c57ce23120d7..248494b4076af7e711bcfa13ac83294bb0074a1e 100644 (file)
@@ -144,7 +144,6 @@ BaseSimpleCPU::checkPcEventQueue()
     Addr oldpc, pc = threadInfo[curThread]->thread->instAddr();
     do {
         oldpc = pc;
-        system->pcEventQueue.service(oldpc, threadContexts[curThread]);
         threadInfo[curThread]->thread->pcEventQueue.service(
                 oldpc, threadContexts[curThread]);
         pc = threadInfo[curThread]->thread->instAddr();
index e993a738f6b892d595040b765cc628143007cde2..f2bbd8cbc613ce59b98f3bbc2d6c5e2dbc68c244 100644 (file)
@@ -265,6 +265,8 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
              "Cannot have two CPUs with the same id (%d)\n", id);
 
     threadContexts[id] = tc;
+    for (auto *e: liveEvents)
+        tc->schedule(e);
 
 #if THE_ISA != NULL_ISA
     int port = getRemoteGDBPort();
@@ -295,13 +297,21 @@ System::registerThreadContext(ThreadContext *tc, ContextID assigned)
 bool
 System::schedule(PCEvent *event)
 {
-    return pcEventQueue.schedule(event);
+    bool all = true;
+    liveEvents.push_back(event);
+    for (auto *tc: threadContexts)
+        all = tc->schedule(event) && all;
+    return all;
 }
 
 bool
 System::remove(PCEvent *event)
 {
-    return pcEventQueue.remove(event);
+    bool all = true;
+    liveEvents.remove(event);
+    for (auto *tc: threadContexts)
+        all = tc->remove(event) && all;
+    return all;
 }
 
 int
@@ -363,6 +373,10 @@ System::replaceThreadContext(ThreadContext *tc, ContextID context_id)
               context_id, threadContexts.size());
     }
 
+    for (auto *e: liveEvents) {
+        threadContexts[context_id]->remove(e);
+        tc->schedule(e);
+    }
     threadContexts[context_id] = tc;
     if (context_id < remoteGDB.size())
         remoteGDB[context_id]->replaceThreadContext(tc);
index 8c0660376423f211a54cbd9df96f7532ce44c9b9..d205ffb7ac0b2e6835a9b10f0f42ea04358e0332 100644 (file)
@@ -99,6 +99,7 @@ class System : public SimObject, public PCEventScope
         { panic("SystemPort does not expect retry!\n"); }
     };
 
+    std::list<PCEvent *> liveEvents;
     SystemPort _systemPort;
 
   public:
@@ -186,8 +187,6 @@ class System : public SimObject, public PCEventScope
      */
     unsigned int cacheLineSize() const { return _cacheLineSize; }
 
-    PCEventQueue pcEventQueue;
-
     std::vector<ThreadContext *> threadContexts;
     const bool multiThread;