Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/44615 )

Change subject: cpu,sim: Set ThreadContext's ContextID right away.
......................................................................

cpu,sim: Set ThreadContext's ContextID right away.

The code which registers thread contexts originally returned the ID that
it had chosen, and let the CPU actually set the ID in the object itself.
That opened a window where calling contextId() on the ThreadContext
would return the wrong answer.

Instead, we can just set the ID immediately after it's decided. This
also localizes that logic and removes plumbing for the ID between that
decision and where it's actually applied.

Change-Id: I31ad84c3f9bf6f5b6f72457ca640ea929b24f6a0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/44615
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Reviewed-by: Boris Shingarov <shinga...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
---
M src/cpu/base.cc
M src/sim/system.cc
M src/sim/system.hh
3 files changed, 9 insertions(+), 11 deletions(-)

Approvals:
  Boris Shingarov: Looks good to me, approved
  Daniel Carvalho: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index f98837c..c40c001 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -431,9 +431,9 @@
         ThreadContext *tc = threadContexts[tid];

         if (system->multiThread) {
-            tc->setContextId(system->registerThreadContext(tc));
+            system->registerThreadContext(tc);
         } else {
-            tc->setContextId(system->registerThreadContext(tc, _cpuId));
+            system->registerThreadContext(tc, _cpuId);
         }

         if (!FullSystem)
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 0c42256..7a3e248 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -98,7 +98,7 @@
         workload->recordQuiesce();
 }

-ContextID
+void
 System::Threads::insert(ThreadContext *tc, ContextID id)
 {
     if (id == InvalidContextID) {
@@ -108,6 +108,8 @@
         }
     }

+    tc->setContextId(id);
+
     if (id >= size())
         threads.resize(id + 1);

@@ -129,8 +131,6 @@
         t.gdb->listen();
     }
 #   endif
-
-    return id;
 }

 void
@@ -296,15 +296,13 @@
     memoryMode = mode;
 }

-ContextID
+void
 System::registerThreadContext(ThreadContext *tc, ContextID assigned)
 {
-    ContextID id = threads.insert(tc, assigned);
+    threads.insert(tc, assigned);

     for (auto *e: liveEvents)
         tc->schedule(e);
-
-    return id;
 }

 bool
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 480b523..6613217 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -142,7 +142,7 @@
             return threads[id];
         }

-        ContextID insert(ThreadContext *tc, ContextID id=InvalidContextID);
+        void insert(ThreadContext *tc, ContextID id=InvalidContextID);
         void replace(ThreadContext *tc, ContextID id);

         friend class System;
@@ -586,7 +586,7 @@
     /// @return Starting address of first page
     Addr allocPhysPages(int npages);

-    ContextID registerThreadContext(
+    void registerThreadContext(
             ThreadContext *tc, ContextID assigned=InvalidContextID);
     void replaceThreadContext(ThreadContext *tc, ContextID context_id);




1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/44615
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: I31ad84c3f9bf6f5b6f72457ca640ea929b24f6a0
Gerrit-Change-Number: 44615
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Boris Shingarov <shinga...@gmail.com>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to