sim: Update stats style of System and Process
authorHoa Nguyen <hoanguyen@ucdavis.edu>
Wed, 25 Nov 2020 09:38:30 +0000 (01:38 -0800)
committerHoa Nguyen <hoanguyen@ucdavis.edu>
Tue, 22 Dec 2020 09:52:36 +0000 (09:52 +0000)
Change-Id: I3af072a61a18f4fbba3f7d4b632c58501e7b7ae8
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37995
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
src/sim/process.cc
src/sim/process.hh
src/sim/system.cc

index 315f86b7e25c8f926df1ee7544e4991888f8c644..7819820caee3c30f46062b53c982966e0e79b33b 100644 (file)
@@ -128,7 +128,8 @@ Process::Process(const ProcessParams &params, EmulationPageTable *pTable,
       _pid(params.pid), _ppid(params.ppid),
       _pgid(params.pgid), drivers(params.drivers),
       fds(make_shared<FDArray>(params.input, params.output, params.errout)),
-      childClearTID(0)
+      childClearTID(0),
+      ADD_STAT(numSyscalls, "Number of system calls")
 {
     if (_pid >= System::maxPID)
         fatal("_pid is too large: %d", _pid);
@@ -251,19 +252,6 @@ Process::clone(ThreadContext *otc, ThreadContext *ntc,
     np->envp.insert(np->envp.end(), envp.begin(), envp.end());
 }
 
-void
-Process::regStats()
-{
-    SimObject::regStats();
-
-    using namespace Stats;
-
-    numSyscalls
-        .name(name() + ".numSyscalls")
-        .desc("Number of system calls")
-        ;
-}
-
 void
 Process::revokeThreadContext(int context_id)
 {
index 2234cb03e66aee9b3c031e5b3d66022023d7f2d4..c9e6a8b752593facd60877ae859d3c40d8b9b27b 100644 (file)
@@ -105,9 +105,6 @@ class Process : public SimObject
     Addr getStartPC();
     ::Loader::ObjectFile *getInterpreter();
 
-    // override of virtual SimObject method: register statistics
-    void regStats() override;
-
     void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
 
     /// Attempt to fix up a fault at vaddr by allocating a page on the stack.
@@ -162,8 +159,6 @@ class Process : public SimObject
     // system object which owns this process
     System *system;
 
-    Stats::Scalar numSyscalls;  // track how many system calls are executed
-
     // flag for using architecture specific page table
     bool useArchPT;
     // running KVM requires special initialization
@@ -286,6 +281,8 @@ class Process : public SimObject
 
     // Process was forked with SIGCHLD set.
     bool *sigchld;
+
+    Stats::Scalar numSyscalls;  // track how many system calls are executed
 };
 
 #endif // __PROCESS_HH__
index de4744a5f962b0f52adb6d3c071c87aea9a0c507..80aa2fb57862acb39da99e8c187bf6be40c960f7 100644 (file)
@@ -483,7 +483,7 @@ System::regStats()
     SimObject::regStats();
 
     for (uint32_t j = 0; j < numWorkIds ; j++) {
-        workItemStats[j] = new Stats::Histogram();
+        workItemStats[j] = new Stats::Histogram(this);
         stringstream namestr;
         ccprintf(namestr, "work_item_type%d", j);
         workItemStats[j]->init(20)