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