[gem5-dev] Change in gem5/gem5[develop]: sim: Fix Mempool overrides during checkpoint

2022-03-29 Thread Jordi Vaquero (Gerrit) via gem5-dev
Jordi Vaquero has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/56969 )


Change subject: sim: Fix Mempool overrides during checkpoint
..

sim: Fix Mempool overrides during checkpoint

This patch fixes the problem during checkpoing where the mempool is not
restored, but using only the one specified in the config file as a new
execution.
In order to fix that this changes modifyies the serialize/unserialize
functions for mempools and create new funcionts on se_workload to make
sure mempools ends up in the m5.cpt.
We change as well the unserialize mempool function to update
according the checkpoint file so the execution starts with the same
free pages and free pointers.

JIRA: https://gem5.atlassian.net/browse/GEM5-1191

Change-Id: I289bf91eb4f01d9c01a31a39b968e30f8b8d2bdc
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56969
Reviewed-by: Giacomo Travaglini 
Maintainer: Giacomo Travaglini 
Tested-by: kokoro 
---
M src/sim/mem_pool.cc
M src/sim/process.cc
M src/sim/se_workload.cc
M src/sim/se_workload.hh
4 files changed, 46 insertions(+), 0 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/sim/mem_pool.cc b/src/sim/mem_pool.cc
index 20b6eda..d58399d 100644
--- a/src/sim/mem_pool.cc
+++ b/src/sim/mem_pool.cc
@@ -169,6 +169,7 @@
 void
 MemPools::serialize(CheckpointOut ) const
 {
+ScopedCheckpointSection sec(cp, "mempools");
 int num_pools = pools.size();
 SERIALIZE_SCALAR(num_pools);

@@ -179,6 +180,10 @@
 void
 MemPools::unserialize(CheckpointIn )
 {
+// Delete previous mem_pools
+pools.clear();
+
+ScopedCheckpointSection sec(cp, "mempools");
 int num_pools = 0;
 UNSERIALIZE_SCALAR(num_pools);

diff --git a/src/sim/process.cc b/src/sim/process.cc
index 3a631a5..97130bd 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -388,6 +388,7 @@
 memState->unserialize(cp);
 pTable->unserialize(cp);
 fds->unserialize(cp);
+
 /**
  * Checkpoints for pipes, device drivers or sockets currently
  * do not work. Need to come back and fix them at a later date.
diff --git a/src/sim/se_workload.cc b/src/sim/se_workload.cc
index d3c8570..4d2bd54 100644
--- a/src/sim/se_workload.cc
+++ b/src/sim/se_workload.cc
@@ -54,6 +54,18 @@
 }

 void
+SEWorkload::serialize(CheckpointOut ) const
+{
+memPools.serialize(cp);
+}
+
+void
+SEWorkload::unserialize(CheckpointIn )
+{
+memPools.unserialize(cp);
+}
+
+void
 SEWorkload::syscall(ThreadContext *tc)
 {
 tc->getProcessPtr()->syscall(tc);
diff --git a/src/sim/se_workload.hh b/src/sim/se_workload.hh
index 5bc597f..e212ad6 100644
--- a/src/sim/se_workload.hh
+++ b/src/sim/se_workload.hh
@@ -81,6 +81,9 @@
 panic("No workload symbol table for syscall emulation mode.");
 }

+void serialize(CheckpointOut ) const override;
+void unserialize(CheckpointIn ) override;
+
 void syscall(ThreadContext *tc) override;

 // For now, assume the only type of events are system calls.

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56969
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: I289bf91eb4f01d9c01a31a39b968e30f8b8d2bdc
Gerrit-Change-Number: 56969
Gerrit-PatchSet: 6
Gerrit-Owner: Jordi Vaquero 
Gerrit-Reviewer: Bobby Bruce 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jason Lowe-Power 
Gerrit-Reviewer: Jordi Vaquero 
Gerrit-Reviewer: kokoro 
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

[gem5-dev] Change in gem5/gem5[develop]: sim: Fix Mempool overrides during checkpoint

2022-02-18 Thread Jordi Vaquero (Gerrit) via gem5-dev
Jordi Vaquero has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/56969 )



Change subject: sim: Fix Mempool overrides during checkpoint
..

sim: Fix Mempool overrides during checkpoint

This patch fixes the problem during checkpoing where the mempool is not
restored, but using only the one specified in the config file as a new
execution.
In order to fix that this changes modifyies the serialize/unserialize
functions for mempools and create new funcionts on se_workload to make
sure mempools ends up in the m5.cpt.
We change as well the unserialize mempool function to update the values for
and already createt pool, so the execution picks up right in the same place
for the checkpoint.

JIRA: https://gem5.atlassian.net/browse/GEM5-1191

Change-Id: I289bf91eb4f01d9c01a31a39b968e30f8b8d2bdc
---
M src/sim/mem_pool.cc
M src/sim/mem_pool.hh
M src/sim/process.cc
M src/sim/se_workload.hh
4 files changed, 78 insertions(+), 4 deletions(-)



diff --git a/src/sim/mem_pool.cc b/src/sim/mem_pool.cc
index 20b6eda..26190a6 100644
--- a/src/sim/mem_pool.cc
+++ b/src/sim/mem_pool.cc
@@ -123,6 +123,26 @@
 return return_addr;
 }

+bool
+MemPool::overlaps(MemPool& other)
+{
+Addr end_page_num = startPageNum + totalPages();
+if (startPageNum <= other.startPageNum &&
+end_page_num > other.startPageNum)
+return true;
+else
+return false;
+}
+
+void
+MemPool::update(MemPool & other)
+{
+pageShift = other.pageShift;
+startPageNum = other.startPageNum;
+freePageNum = other.freePageNum;
+_totalPages = other._totalPages;
+}
+
 void
 MemPool::serialize(CheckpointOut ) const
 {
@@ -166,26 +186,42 @@
 return pools[pool_id].freeBytes();
 }

+bool
+MemPools::checkDuplicate(MemPool& pool)
+{
+for (auto : pools) {
+if (p.overlaps(pool)) {
+p.update(pool);
+return true;
+}
+}
+return false;
+}
+
 void
 MemPools::serialize(CheckpointOut ) const
 {
+ScopedCheckpointSection sec(cp, "mempools");
 int num_pools = pools.size();
 SERIALIZE_SCALAR(num_pools);

 for (int i = 0; i < num_pools; i++)
-pools[i].serializeSection(cp, csprintf("pool%d", i));
+pools[i].serializeSection(cp, csprintf("mempools.pool%d", i));
 }

 void
 MemPools::unserialize(CheckpointIn )
 {
+ScopedCheckpointSection sec(cp, "mempools");
 int num_pools = 0;
 UNSERIALIZE_SCALAR(num_pools);

 for (int i = 0; i < num_pools; i++) {
 MemPool pool;
-pool.unserializeSection(cp, csprintf("pool%d", i));
-pools.push_back(pool);
+pool.unserializeSection(cp, csprintf("mempools.pool%d", i));
+if (!checkDuplicate(pool)) {
+pools.push_back(pool);
+}
 }
 }

diff --git a/src/sim/mem_pool.hh b/src/sim/mem_pool.hh
index f35fdbc..452507a 100644
--- a/src/sim/mem_pool.hh
+++ b/src/sim/mem_pool.hh
@@ -79,6 +79,9 @@

 Addr allocate(Addr npages);

+bool overlaps(MemPool& other);
+void update(MemPool& other);
+
 void serialize(CheckpointOut ) const override;
 void unserialize(CheckpointIn ) override;
 };
@@ -105,6 +108,8 @@
 /** Amount of physical memory that is still free in a pool. */
 Addr freeMemSize(int pool_id=0) const;

+bool checkDuplicate(MemPool& pool);
+
 void serialize(CheckpointOut ) const override;
 void unserialize(CheckpointIn ) override;
 };
diff --git a/src/sim/process.cc b/src/sim/process.cc
index 3a631a5..64fdca4 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -373,7 +373,7 @@
 memState->serialize(cp);
 pTable->serialize(cp);
 fds->serialize(cp);
-
+seWorkload->serialize(cp);
 /**
  * Checkpoints for pipes, device drivers or sockets currently
  * do not work. Need to come back and fix them at a later date.
@@ -388,6 +388,7 @@
 memState->unserialize(cp);
 pTable->unserialize(cp);
 fds->unserialize(cp);
+seWorkload->unserialize(cp);
 /**
  * Checkpoints for pipes, device drivers or sockets currently
  * do not work. Need to come back and fix them at a later date.
diff --git a/src/sim/se_workload.hh b/src/sim/se_workload.hh
index 5bc597f..117fbe0 100644
--- a/src/sim/se_workload.hh
+++ b/src/sim/se_workload.hh
@@ -81,6 +81,17 @@
 panic("No workload symbol table for syscall emulation mode.");
 }

+void
+serialize(CheckpointOut ) const override
+{
+memPools.serialize(cp);
+}
+void
+unserialize(CheckpointIn ) override
+{
+memPools.unserialize(cp);
+}
+
 void syscall(ThreadContext *tc) override;

 // For now, assume the only type of events are system calls.

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


Gerrit-Project: public/gem5
Gerrit-Branch: develop