sim: Move the MemPools object out of System and into SEWorkload.
This removes the need for all the FullSystem checks in the System class, and simplifies that class in general. Change-Id: Ie8a3bc67db9195027d2111009b15ca59221bdeb2 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/50348 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -152,17 +152,11 @@ MemPools::populate(const System &sys)
|
||||
AddrRangeList memories = sys.getPhysMem().getConfAddrRanges();
|
||||
const auto &m5op_range = sys.m5opRange();
|
||||
|
||||
assert(!memories.empty());
|
||||
for (const auto &mem : memories) {
|
||||
assert(!mem.interleaved());
|
||||
if (m5op_range.valid()) {
|
||||
// Make sure the m5op range is not included.
|
||||
for (const auto &range: mem.exclude({m5op_range}))
|
||||
pools.emplace_back(pageShift, range.start(), range.end());
|
||||
} else {
|
||||
pools.emplace_back(pageShift, mem.start(), mem.end());
|
||||
}
|
||||
}
|
||||
if (m5op_range.valid())
|
||||
memories -= m5op_range;
|
||||
|
||||
for (const auto &mem : memories)
|
||||
pools.emplace_back(pageShift, mem.start(), mem.end());
|
||||
|
||||
/*
|
||||
* Set freePage to what it was before Gabe Black's page table changes
|
||||
|
||||
@@ -35,9 +35,17 @@
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
SEWorkload::SEWorkload(const Params &p) : Workload(p)
|
||||
SEWorkload::SEWorkload(const Params &p, Addr page_shift) :
|
||||
Workload(p), memPools(page_shift)
|
||||
{}
|
||||
|
||||
void
|
||||
SEWorkload::setSystem(System *sys)
|
||||
{
|
||||
Workload::setSystem(sys);
|
||||
memPools.populate(*sys);
|
||||
}
|
||||
|
||||
void
|
||||
SEWorkload::syscall(ThreadContext *tc)
|
||||
{
|
||||
@@ -47,19 +55,19 @@ SEWorkload::syscall(ThreadContext *tc)
|
||||
Addr
|
||||
SEWorkload::allocPhysPages(int npages, int pool_id)
|
||||
{
|
||||
return system->allocPhysPages(npages, pool_id);
|
||||
return memPools.allocPhysPages(npages, pool_id);
|
||||
}
|
||||
|
||||
Addr
|
||||
SEWorkload::memSize(int pool_id) const
|
||||
{
|
||||
return system->memSize(pool_id);
|
||||
return memPools.memSize(pool_id);
|
||||
}
|
||||
|
||||
Addr
|
||||
SEWorkload::freeMemSize(int pool_id) const
|
||||
{
|
||||
return system->freeMemSize(pool_id);
|
||||
return memPools.freeMemSize(pool_id);
|
||||
}
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define __SIM_SE_WORKLOAD_HH__
|
||||
|
||||
#include "params/SEWorkload.hh"
|
||||
#include "sim/mem_pool.hh"
|
||||
#include "sim/workload.hh"
|
||||
|
||||
namespace gem5
|
||||
@@ -36,10 +37,16 @@ namespace gem5
|
||||
|
||||
class SEWorkload : public Workload
|
||||
{
|
||||
protected:
|
||||
/** Memory allocation objects for all physical memories in the system. */
|
||||
MemPools memPools;
|
||||
|
||||
public:
|
||||
using Params = SEWorkloadParams;
|
||||
|
||||
SEWorkload(const Params &p);
|
||||
SEWorkload(const Params &p, Addr page_shift=0);
|
||||
|
||||
void setSystem(System *sys) override;
|
||||
|
||||
Addr
|
||||
getEntry() const override
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
#include "params/System.hh"
|
||||
#include "sim/byteswap.hh"
|
||||
#include "sim/debug.hh"
|
||||
#include "sim/full_system.hh"
|
||||
#include "sim/redirect_path.hh"
|
||||
#include "sim/serialize_handlers.hh"
|
||||
|
||||
@@ -199,7 +198,6 @@ int System::numSystemsRunning = 0;
|
||||
System::System(const Params &p)
|
||||
: SimObject(p), _systemPort("system_port", this),
|
||||
multiThread(p.multi_thread),
|
||||
memPools(getPageShift()),
|
||||
init_param(p.init_param),
|
||||
physProxy(_systemPort, p.cache_line_size),
|
||||
workload(p.workload),
|
||||
@@ -222,9 +220,6 @@ System::System(const Params &p)
|
||||
if (workload)
|
||||
workload->setSystem(this);
|
||||
|
||||
if (!FullSystem)
|
||||
memPools.populate(*this);
|
||||
|
||||
// add self to global system list
|
||||
systemList.push_back(this);
|
||||
|
||||
@@ -343,24 +338,9 @@ System::validKvmEnvironment() const
|
||||
}
|
||||
|
||||
Addr
|
||||
System::allocPhysPages(int npages, int pool_id)
|
||||
System::memSize() const
|
||||
{
|
||||
assert(!FullSystem);
|
||||
return memPools.allocPhysPages(npages, pool_id);
|
||||
}
|
||||
|
||||
Addr
|
||||
System::memSize(int pool_id) const
|
||||
{
|
||||
assert(!FullSystem);
|
||||
return memPools.memSize(pool_id);
|
||||
}
|
||||
|
||||
Addr
|
||||
System::freeMemSize(int pool_id) const
|
||||
{
|
||||
assert(!FullSystem);
|
||||
return memPools.freeMemSize(pool_id);
|
||||
return physmem.totalSize();
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -414,8 +394,6 @@ System::serialize(CheckpointOut &cp) const
|
||||
paramOut(cp, csprintf("quiesceEndTick_%d", id), when);
|
||||
}
|
||||
|
||||
memPools.serializeSection(cp, "memPools");
|
||||
|
||||
// also serialize the memories in the system
|
||||
physmem.serializeSection(cp, "physmem");
|
||||
}
|
||||
@@ -436,8 +414,6 @@ System::unserialize(CheckpointIn &cp)
|
||||
# endif
|
||||
}
|
||||
|
||||
memPools.unserializeSection(cp, "memPools");
|
||||
|
||||
// also unserialize the memories in the system
|
||||
physmem.unserializeSection(cp, "physmem");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
#include "mem/port_proxy.hh"
|
||||
#include "params/System.hh"
|
||||
#include "sim/futex_map.hh"
|
||||
#include "sim/mem_pool.hh"
|
||||
#include "sim/redirect_path.hh"
|
||||
#include "sim/se_signal.hh"
|
||||
#include "sim/sim_object.hh"
|
||||
@@ -322,9 +321,6 @@ class System : public SimObject, public PCEventScope
|
||||
bool schedule(PCEvent *event) override;
|
||||
bool remove(PCEvent *event) override;
|
||||
|
||||
/** Memory allocation objects for all physical memories in the system. */
|
||||
MemPools memPools;
|
||||
|
||||
uint64_t init_param;
|
||||
|
||||
/** Port to physical memory used for writing object files into ram at
|
||||
@@ -348,11 +344,8 @@ class System : public SimObject, public PCEventScope
|
||||
memory::PhysicalMemory& getPhysMem() { return physmem; }
|
||||
const memory::PhysicalMemory& getPhysMem() const { return physmem; }
|
||||
|
||||
/** Amount of physical memory that is still free */
|
||||
Addr freeMemSize(int poolID = 0) const;
|
||||
|
||||
/** Amount of physical memory that exists */
|
||||
Addr memSize(int poolID = 0) const;
|
||||
Addr memSize() const;
|
||||
|
||||
/**
|
||||
* Check if a physical address is within a range of a memory that
|
||||
@@ -593,10 +586,6 @@ class System : public SimObject, public PCEventScope
|
||||
|
||||
public:
|
||||
|
||||
/// Allocate npages contiguous unused physical pages
|
||||
/// @return Starting address of first page
|
||||
Addr allocPhysPages(int npages, int poolID = 0);
|
||||
|
||||
void registerThreadContext(
|
||||
ThreadContext *tc, ContextID assigned=InvalidContextID);
|
||||
void replaceThreadContext(ThreadContext *tc, ContextID context_id);
|
||||
|
||||
Reference in New Issue
Block a user