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:
@@ -35,6 +35,7 @@
|
||||
#define __ARCH_ARM_FREEBSD_SE_WORKLOAD_HH__
|
||||
|
||||
#include "arch/arm/freebsd/freebsd.hh"
|
||||
#include "arch/arm/page_size.hh"
|
||||
#include "arch/arm/regs/cc.hh"
|
||||
#include "arch/arm/regs/int.hh"
|
||||
#include "arch/arm/se_workload.hh"
|
||||
@@ -52,7 +53,7 @@ class EmuFreebsd : public SEWorkload
|
||||
public:
|
||||
using Params = ArmEmuFreebsdParams;
|
||||
|
||||
EmuFreebsd(const Params &p) : SEWorkload(p) {}
|
||||
EmuFreebsd(const Params &p) : SEWorkload(p, PageShift) {}
|
||||
|
||||
struct BaseSyscallABI {};
|
||||
struct SyscallABI32 : public SEWorkload::SyscallABI32,
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define __ARCH_ARM_LINUX_SE_WORKLOAD_HH__
|
||||
|
||||
#include "arch/arm/linux/linux.hh"
|
||||
#include "arch/arm/page_size.hh"
|
||||
#include "arch/arm/regs/int.hh"
|
||||
#include "arch/arm/se_workload.hh"
|
||||
#include "params/ArmEmuLinux.hh"
|
||||
@@ -45,7 +46,7 @@ class EmuLinux : public SEWorkload
|
||||
public:
|
||||
using Params = ArmEmuLinuxParams;
|
||||
|
||||
EmuLinux(const Params &p) : SEWorkload(p) {}
|
||||
EmuLinux(const Params &p) : SEWorkload(p, PageShift) {}
|
||||
|
||||
struct BaseSyscallABI {};
|
||||
struct SyscallABI32 : public SEWorkload::SyscallABI32,
|
||||
|
||||
@@ -44,7 +44,9 @@ class SEWorkload : public gem5::SEWorkload
|
||||
public:
|
||||
using Params = ArmSEWorkloadParams;
|
||||
|
||||
SEWorkload(const Params &p) : gem5::SEWorkload(p) {}
|
||||
SEWorkload(const Params &p, Addr page_shift) :
|
||||
gem5::SEWorkload(p, page_shift)
|
||||
{}
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define __ARCH_MIPS_LINUX_SE_WORKLOAD_HH__
|
||||
|
||||
#include "arch/mips/linux/linux.hh"
|
||||
#include "arch/mips/page_size.hh"
|
||||
#include "arch/mips/se_workload.hh"
|
||||
#include "params/MipsEmuLinux.hh"
|
||||
#include "sim/syscall_desc.hh"
|
||||
@@ -49,7 +50,7 @@ class EmuLinux : public SEWorkload
|
||||
public:
|
||||
using Params = MipsEmuLinuxParams;
|
||||
|
||||
EmuLinux(const Params &p) : SEWorkload(p) {}
|
||||
EmuLinux(const Params &p) : SEWorkload(p, PageShift) {}
|
||||
|
||||
void syscall(ThreadContext *tc) override;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,9 @@ class SEWorkload : public gem5::SEWorkload
|
||||
public:
|
||||
using Params = MipsSEWorkloadParams;
|
||||
|
||||
SEWorkload(const Params &p) : gem5::SEWorkload(p) {}
|
||||
SEWorkload(const Params &p, Addr page_shift) :
|
||||
gem5::SEWorkload(p, page_shift)
|
||||
{}
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define __ARCH_POWER_LINUX_SE_WORKLOAD_HH__
|
||||
|
||||
#include "arch/power/linux/linux.hh"
|
||||
#include "arch/power/page_size.hh"
|
||||
#include "arch/power/se_workload.hh"
|
||||
#include "params/PowerEmuLinux.hh"
|
||||
#include "sim/syscall_desc.hh"
|
||||
@@ -50,7 +51,7 @@ class EmuLinux : public SEWorkload
|
||||
public:
|
||||
using Params = PowerEmuLinuxParams;
|
||||
|
||||
EmuLinux(const Params &p) : SEWorkload(p) {}
|
||||
EmuLinux(const Params &p) : SEWorkload(p, PageShift) {}
|
||||
|
||||
void syscall(ThreadContext *tc) override;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,9 @@ class SEWorkload : public gem5::SEWorkload
|
||||
{
|
||||
public:
|
||||
using Params = PowerSEWorkloadParams;
|
||||
SEWorkload(const Params &p) : gem5::SEWorkload(p) {}
|
||||
SEWorkload(const Params &p, Addr page_shift) :
|
||||
gem5::SEWorkload(p, page_shift)
|
||||
{}
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define __ARCH_RISCV_LINUX_SE_WORKLOAD_HH__
|
||||
|
||||
#include "arch/riscv/linux/linux.hh"
|
||||
#include "arch/riscv/page_size.hh"
|
||||
#include "arch/riscv/se_workload.hh"
|
||||
#include "params/RiscvEmuLinux.hh"
|
||||
#include "sim/syscall_desc.hh"
|
||||
@@ -54,7 +55,7 @@ class EmuLinux : public SEWorkload
|
||||
public:
|
||||
using Params = RiscvEmuLinuxParams;
|
||||
|
||||
EmuLinux(const Params &p) : SEWorkload(p) {}
|
||||
EmuLinux(const Params &p) : SEWorkload(p, PageShift) {}
|
||||
|
||||
void syscall(ThreadContext *tc) override;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,9 @@ class SEWorkload : public gem5::SEWorkload
|
||||
public:
|
||||
using Params = RiscvSEWorkloadParams;
|
||||
|
||||
SEWorkload(const Params &p) : gem5::SEWorkload(p) {}
|
||||
SEWorkload(const Params &p, Addr page_shift) :
|
||||
gem5::SEWorkload(p, page_shift)
|
||||
{}
|
||||
|
||||
void
|
||||
setSystem(System *sys) override
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "arch/sparc/page_size.hh"
|
||||
#include "arch/sparc/process.hh"
|
||||
#include "base/loader/object_file.hh"
|
||||
#include "base/trace.hh"
|
||||
@@ -76,7 +77,7 @@ LinuxLoader linuxLoader;
|
||||
namespace SparcISA
|
||||
{
|
||||
|
||||
EmuLinux::EmuLinux(const Params &p) : SEWorkload(p)
|
||||
EmuLinux::EmuLinux(const Params &p) : SEWorkload(p, PageShift)
|
||||
{}
|
||||
|
||||
void
|
||||
|
||||
@@ -93,7 +93,7 @@ LinuxLoader linuxLoader;
|
||||
namespace X86ISA
|
||||
{
|
||||
|
||||
EmuLinux::EmuLinux(const Params &p) : SEWorkload(p)
|
||||
EmuLinux::EmuLinux(const Params &p) : SEWorkload(p, PageShift)
|
||||
{}
|
||||
|
||||
const std::vector<IntRegIndex> EmuLinux::SyscallABI64::ArgumentRegs = {
|
||||
|
||||
@@ -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);
|
||||
|
||||
32
util/cpt_upgraders/mempool-to-seworkload.py
Normal file
32
util/cpt_upgraders/mempool-to-seworkload.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# This upgrader moves memory pools from the system object to the SE workload
|
||||
# object.
|
||||
def upgrader(cpt):
|
||||
systems = {}
|
||||
|
||||
# Find sections with 'num_mem_pools' options, and assume those are system
|
||||
# objects which host MemPools.
|
||||
for sec in cpt.sections():
|
||||
num_mem_pools = cpt.get(sec, 'num_mem_pools', fallback=None)
|
||||
if num_mem_pools is not None:
|
||||
systems[sec] = num_mem_pools
|
||||
|
||||
for sec, num_mem_pools in systems.items():
|
||||
# Transfer num_mem_pools to the new location.
|
||||
cpt.remove_option(sec, 'num_mem_pools')
|
||||
cpt.set(f'{sec}.workload', 'num_mem_pools', num_mem_pools)
|
||||
|
||||
for idx in range(int(num_mem_pools)):
|
||||
old_name = f'{sec}.memPool{idx}'
|
||||
new_name = f'{sec}.workload.memPool{idx}'
|
||||
|
||||
# Create the new section.
|
||||
cpt.add_section(new_name)
|
||||
|
||||
# Copy items from the old section into it.
|
||||
for item in cpt.items(old_name):
|
||||
cpt.set(new_name, *item)
|
||||
|
||||
# Delete the old section.
|
||||
cpt.remove_section(old_name)
|
||||
|
||||
depends = 'mempool-sections'
|
||||
Reference in New Issue
Block a user