arch,kern: Rename some function events to have better names.

Rename many of the Event classes to have more succinct or
consistent names, and fix various style issues.

Change-Id: Ib322da31d81e7a245a00d21786c2aa417c9f2cde
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26703
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Gabe Black
2020-03-13 03:44:43 -07:00
parent dfbef4b1f5
commit e387833613
11 changed files with 111 additions and 106 deletions

View File

@@ -56,20 +56,20 @@ FsFreebsd::FsFreebsd(Params *p) : ArmISA::FsWorkload(p),
enableContextSwitchStatsDump(p->enable_context_switch_stats_dump)
{
if (p->panic_on_panic) {
kernelPanicEvent = addKernelFuncEventOrPanic<PanicPCEvent>(
kernelPanic = addKernelFuncEventOrPanic<PanicPCEvent>(
"panic", "Kernel panic in simulated kernel");
} else {
#ifndef NDEBUG
kernelPanicEvent = addKernelFuncEventOrPanic<BreakPCEvent>("panic");
kernelPanic = addKernelFuncEventOrPanic<BreakPCEvent>("panic");
#endif
}
if (p->panic_on_oops) {
kernelOopsEvent = addKernelFuncEventOrPanic<PanicPCEvent>(
kernelOops = addKernelFuncEventOrPanic<PanicPCEvent>(
"oops_exit", "Kernel oops in guest");
}
uDelaySkipEvent = addKernelFuncEvent<UDelayEvent<ArmISA::SkipFunc>>(
skipUDelay = addKernelFuncEvent<SkipUDelay<ArmISA::SkipFunc>>(
"DELAY", "DELAY", 1000, 0);
}
@@ -123,7 +123,7 @@ FsFreebsd::initState()
FsFreebsd::~FsFreebsd()
{
delete uDelaySkipEvent;
delete skipUDelay;
}
} // namespace ArmISA

View File

@@ -78,17 +78,17 @@ class FsFreebsd : public ArmISA::FsWorkload
private:
/** Event to halt the simulator if the kernel calls panic() */
PCEvent *kernelPanicEvent = nullptr;
PCEvent *kernelPanic = nullptr;
/** Event to halt the simulator if the kernel calls oopses */
PCEvent *kernelOopsEvent = nullptr;
PCEvent *kernelOops = nullptr;
/**
* PC based event to skip udelay(<time>) calls and quiesce the
* processor for the appropriate amount of time. This is not functionally
* required but does speed up simulation.
*/
FreeBSD::UDelayEvent<SkipFunc> *uDelaySkipEvent = nullptr;
FreeBSD::SkipUDelay<SkipFunc> *skipUDelay = nullptr;
/** These variables store addresses of important data structures
* that are normaly kept coherent at boot with cache mainetence operations.

View File

@@ -169,11 +169,13 @@ FsLinux::initState()
FsLinux::~FsLinux()
{
delete uDelaySkipEvent;
delete constUDelaySkipEvent;
delete skipUDelay;
delete skipConstUDelay;
delete kernelOops;
delete kernelPanic;
delete dumpStatsPCEvent;
delete debugPrintkEvent;
delete dumpStats;
delete debugPrintk;
}
void
@@ -183,15 +185,12 @@ FsLinux::startup()
auto *arm_sys = dynamic_cast<ArmSystem *>(system);
if (enableContextSwitchStatsDump) {
if (!arm_sys->highestELIs64()) {
dumpStatsPCEvent =
addKernelFuncEvent<DumpStatsPCEvent>("__switch_to");
} else {
dumpStatsPCEvent =
addKernelFuncEvent<DumpStatsPCEvent64>("__switch_to");
}
if (!arm_sys->highestELIs64())
dumpStats = addKernelFuncEvent<DumpStats>("__switch_to");
else
dumpStats = addKernelFuncEvent<DumpStats64>("__switch_to");
panic_if(!dumpStatsPCEvent, "dumpStatsPCEvent not created!");
panic_if(!dumpStats, "dumpStats not created!");
std::string task_filename = "tasks.txt";
taskFile = simout.create(name() + "." + task_filename);
@@ -207,40 +206,39 @@ FsLinux::startup()
const std::string dmesg_output = name() + ".dmesg";
if (params()->panic_on_panic) {
kernelPanicEvent = addKernelFuncEventOrPanic<Linux::KernelPanicEvent>(
kernelPanic = addKernelFuncEventOrPanic<Linux::KernelPanic>(
"panic", "Kernel panic in simulated kernel", dmesg_output);
} else {
kernelPanicEvent = addKernelFuncEventOrPanic<Linux::DmesgDumpEvent>(
kernelPanic = addKernelFuncEventOrPanic<Linux::DmesgDump>(
"panic", "Kernel panic in simulated kernel", dmesg_output);
}
if (params()->panic_on_oops) {
kernelOopsEvent = addKernelFuncEventOrPanic<Linux::KernelPanicEvent>(
kernelOops = addKernelFuncEventOrPanic<Linux::KernelPanic>(
"oops_exit", "Kernel oops in guest", dmesg_output);
} else {
kernelOopsEvent = addKernelFuncEventOrPanic<Linux::DmesgDumpEvent>(
kernelOops = addKernelFuncEventOrPanic<Linux::DmesgDump>(
"oops_exit", "Kernel oops in guest", dmesg_output);
}
// With ARM udelay() is #defined to __udelay
// newer kernels use __loop_udelay and __loop_const_udelay symbols
uDelaySkipEvent = addKernelFuncEvent<UDelayEvent<SkipFunc>>(
skipUDelay = addKernelFuncEvent<SkipUDelay<SkipFunc>>(
"__loop_udelay", "__udelay", 1000, 0);
if (!uDelaySkipEvent)
uDelaySkipEvent = addKernelFuncEventOrPanic<UDelayEvent<SkipFunc>>(
if (!skipUDelay)
skipUDelay = addKernelFuncEventOrPanic<SkipUDelay<SkipFunc>>(
"__udelay", "__udelay", 1000, 0);
// constant arguments to udelay() have some precomputation done ahead of
// time. Constant comes from code.
constUDelaySkipEvent = addKernelFuncEvent<UDelayEvent<SkipFunc>>(
skipConstUDelay = addKernelFuncEvent<SkipUDelay<SkipFunc>>(
"__loop_const_udelay", "__const_udelay", 1000, 107374);
if (!constUDelaySkipEvent)
constUDelaySkipEvent =
addKernelFuncEventOrPanic<UDelayEvent<SkipFunc>>(
"__const_udelay", "__const_udelay", 1000, 107374);
if (!skipConstUDelay) {
skipConstUDelay = addKernelFuncEventOrPanic<SkipUDelay<SkipFunc>>(
"__const_udelay", "__const_udelay", 1000, 107374);
}
debugPrintkEvent =
addKernelFuncEvent<DebugPrintkEvent<SkipFunc>>("dprintk");
debugPrintk = addKernelFuncEvent<DebugPrintk<SkipFunc>>("dprintk");
}
void
@@ -274,7 +272,7 @@ FsLinux::dumpDmesg()
* r2 = thread_info of the next process to run
*/
void
DumpStatsPCEvent::getTaskDetails(ThreadContext *tc, uint32_t &pid,
DumpStats::getTaskDetails(ThreadContext *tc, uint32_t &pid,
uint32_t &tgid, std::string &next_task_str, int32_t &mm) {
Linux::ThreadInfo ti(tc);
@@ -296,7 +294,7 @@ DumpStatsPCEvent::getTaskDetails(ThreadContext *tc, uint32_t &pid,
* r1 = task_struct of next process to run
*/
void
DumpStatsPCEvent64::getTaskDetails(ThreadContext *tc, uint32_t &pid,
DumpStats64::getTaskDetails(ThreadContext *tc, uint32_t &pid,
uint32_t &tgid, std::string &next_task_str, int32_t &mm) {
Linux::ThreadInfo ti(tc);
@@ -314,7 +312,7 @@ DumpStatsPCEvent64::getTaskDetails(ThreadContext *tc, uint32_t &pid,
* "__switch_to" is called to change running tasks.
*/
void
DumpStatsPCEvent::process(ThreadContext *tc)
DumpStats::process(ThreadContext *tc)
{
uint32_t pid = 0;
uint32_t tgid = 0;

View File

@@ -54,7 +54,7 @@
namespace ArmISA
{
class DumpStatsPCEvent;
class DumpStats;
class FsLinux : public ArmISA::FsWorkload
{
@@ -63,9 +63,9 @@ class FsLinux : public ArmISA::FsWorkload
* PC based event to skip the dprink() call and emulate its
* functionality
*/
Linux::DebugPrintkEvent<SkipFunc> *debugPrintkEvent = nullptr;
Linux::DebugPrintk<SkipFunc> *debugPrintk = nullptr;
DumpStatsPCEvent *dumpStatsPCEvent = nullptr;
DumpStats *dumpStats = nullptr;
public:
/** Boilerplate params code */
@@ -109,31 +109,30 @@ class FsLinux : public ArmISA::FsWorkload
private:
/** Event to halt the simulator if the kernel calls panic() */
PCEvent *kernelPanicEvent = nullptr;
PCEvent *kernelPanic = nullptr;
/** Event to halt the simulator if the kernel calls oopses */
PCEvent *kernelOopsEvent = nullptr;
PCEvent *kernelOops = nullptr;
/**
* PC based event to skip udelay(<time>) calls and quiesce the
* processor for the appropriate amount of time. This is not functionally
* required but does speed up simulation.
*/
Linux::UDelayEvent<SkipFunc> *uDelaySkipEvent = nullptr;
Linux::SkipUDelay<SkipFunc> *skipUDelay = nullptr;
/** Another PC based skip event for const_udelay(). Similar to the udelay
* skip, but this function precomputes the first multiply that is done
* in the generic case since the parameter is known at compile time.
* Thus we need to do some division to get back to us.
*/
Linux::UDelayEvent<SkipFunc> *constUDelaySkipEvent = nullptr;
Linux::SkipUDelay<SkipFunc> *skipConstUDelay = nullptr;
};
class DumpStatsPCEvent : public PCEvent
class DumpStats : public PCEvent
{
public:
DumpStatsPCEvent(PCEventScope *s, const std::string &desc, Addr addr)
DumpStats(PCEventScope *s, const std::string &desc, Addr addr)
: PCEvent(s, desc, addr)
{}
@@ -144,12 +143,11 @@ class DumpStatsPCEvent : public PCEvent
};
class DumpStatsPCEvent64 : public DumpStatsPCEvent
class DumpStats64 : public DumpStats
{
public:
DumpStatsPCEvent64(PCEventScope *s, const std::string &desc, Addr addr)
: DumpStatsPCEvent(s, desc, addr)
{}
using DumpStats::DumpStats;
private:
void getTaskDetails(ThreadContext *tc, uint32_t &pid, uint32_t &tgid,
std::string &next_task_str, int32_t &mm) override;

View File

@@ -75,7 +75,7 @@ LinuxMipsSystem::setDelayLoop(ThreadContext *tc)
void
LinuxMipsSystem::SkipDelayLoopEvent::process(ThreadContext *tc)
LinuxMipsSystem::SkipDelayLoop::process(ThreadContext *tc)
{
MipsISA::SkipFunc::process(tc);
// calculate and set loops_per_jiffy

View File

@@ -49,20 +49,22 @@ class LinuxMipsSystem : public MipsSystem
private:
using SkipFunc = MipsISA::SkipFunc;
class SkipDelayLoopEvent : public SkipFunc
class SkipDelayLoop : public SkipFunc
{
public:
SkipDelayLoopEvent(PCEventScope *s, const std::string &desc, Addr addr)
: SkipFunc(s, desc, addr) {}
virtual void process(ThreadContext *tc);
SkipDelayLoop(PCEventScope *s, const std::string &desc, Addr addr) :
SkipFunc(s, desc, addr)
{}
void process(ThreadContext *tc) override;
};
class PrintThreadInfo : public PCEvent
{
public:
PrintThreadInfo(PCEventScope *s, const std::string &desc, Addr addr)
: PCEvent(s, desc, addr) {}
virtual void process(ThreadContext *tc);
PrintThreadInfo(PCEventScope *s, const std::string &desc, Addr addr) :
PCEvent(s, desc, addr)
{}
void process(ThreadContext *tc) override;
};

View File

@@ -42,20 +42,17 @@
#include "sim/arguments.hh"
#include "sim/system.hh"
namespace FreeBSD {
namespace FreeBSD
{
void
onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
{
int arg_num;
arg_num = 0;
int arg_num = 0;
// Get the time in native size
uint64_t time = TheISA::getArgument(tc, arg_num, (uint16_t)-1, false);
//DPRINTFN("DELAY(%d)\n", time);
// convert parameter to ns
if (div)
time /= div;

View File

@@ -35,7 +35,8 @@
#include "kern/system_events.hh"
namespace FreeBSD {
namespace FreeBSD
{
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
@@ -45,7 +46,7 @@ void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
* See descriptions of argDivToNs and argMultToNs below.
*/
template <typename Base>
class UDelayEvent : public Base
class SkipUDelay : public Base
{
private:
/** value to divide arg by to create ns. This is present beacues the linux
@@ -60,9 +61,10 @@ class UDelayEvent : public Base
uint64_t argMultToNs;
public:
UDelayEvent(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div)
: Base(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
SkipUDelay(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div) :
Base(s, desc, addr), argDivToNs(div), argMultToNs(mult)
{}
void
process(ThreadContext *tc) override

View File

@@ -55,7 +55,8 @@
#include "sim/core.hh"
#include "sim/system.hh"
namespace Linux {
namespace Linux
{
void
onDebugPrintk(ThreadContext *tc)
@@ -70,7 +71,7 @@ onDebugPrintk(ThreadContext *tc)
}
void
DmesgDumpEvent::process(ThreadContext *tc)
DmesgDump::process(ThreadContext *tc)
{
inform("Dumping kernel dmesg buffer to %s...\n", fname);
OutputStream *os = simout.create(fname);
@@ -81,7 +82,7 @@ DmesgDumpEvent::process(ThreadContext *tc)
}
void
KernelPanicEvent::process(ThreadContext *tc)
KernelPanic::process(ThreadContext *tc)
{
inform("Dumping kernel dmesg buffer to %s...\n", fname);
OutputStream *os = simout.create(fname);

View File

@@ -43,18 +43,18 @@
#include "kern/system_events.hh"
namespace Linux {
namespace Linux
{
void onDebugPrintk(ThreadContext *tc);
template <typename Base>
class DebugPrintkEvent : public Base
class DebugPrintk : public Base
{
public:
DebugPrintkEvent(PCEventScope *s, const std::string &desc, Addr addr)
: Base(s, desc, addr) {}
virtual void
process(ThreadContext *tc)
using Base::Base;
void
process(ThreadContext *tc) override
{
onDebugPrintk(tc);
Base::process(tc);
@@ -69,16 +69,17 @@ class DebugPrintkEvent : public Base
* limitations. Most importantly, the kernel's address mappings must
* be available to the translating proxy.
*/
class DmesgDumpEvent : public PCEvent
class DmesgDump : public PCEvent
{
protected:
std::string fname;
public:
DmesgDumpEvent(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname)
: PCEvent(s, desc, addr), fname(_fname) {}
virtual void process(ThreadContext *tc);
DmesgDump(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname) :
PCEvent(s, desc, addr), fname(_fname)
{}
void process(ThreadContext *tc) override;
};
/**
@@ -89,16 +90,17 @@ class DmesgDumpEvent : public PCEvent
* limitations. Most importantly, the kernel's address mappings must
* be available to the translating proxy.
*/
class KernelPanicEvent : public PCEvent
class KernelPanic : public PCEvent
{
protected:
std::string fname;
public:
KernelPanicEvent(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname)
: PCEvent(s, desc, addr), fname(_fname) {}
virtual void process(ThreadContext *tc);
KernelPanic(PCEventScope *s, const std::string &desc, Addr addr,
const std::string &_fname) :
PCEvent(s, desc, addr), fname(_fname)
{}
void process(ThreadContext *tc) override;
};
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
@@ -110,33 +112,38 @@ void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
* See descriptions of argDivToNs and argMultToNs below.
*/
template <typename Base>
class UDelayEvent : public Base
class SkipUDelay : public Base
{
private:
/** value to divide arg by to create ns. This is present beacues the linux
/**
* Value to divide arg by to create ns. This is present beacues the linux
* kernel code sometime precomputes the first multiply that is done in
* udelay() if the parameter is a constant. We need to undo it so here is
* how. */
* how.
*/
uint64_t argDivToNs;
/** value to multiple arg by to create ns. Nominally, this is 1000 to
/**
* Value to multiple arg by to create ns. Nominally, this is 1000 to
* convert us to ns, but since linux can do some preprocessing of constant
* values something else might be required. */
* values something else might be required.
*/
uint64_t argMultToNs;
public:
UDelayEvent(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div)
: Base(s, desc, addr), argDivToNs(div), argMultToNs(mult) {}
SkipUDelay(PCEventScope *s, const std::string &desc, Addr addr,
uint64_t mult, uint64_t div) :
Base(s, desc, addr), argDivToNs(div), argMultToNs(mult)
{}
virtual void
process(ThreadContext *tc)
void
process(ThreadContext *tc) override
{
onUDelay(tc, argDivToNs, argMultToNs);
Base::process(tc);
}
};
}
} // namespace Linux
#endif
#endif // __KERN_LINUX_EVENTS_HH__

View File

@@ -26,8 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SYSTEM_EVENTS_HH__
#define __SYSTEM_EVENTS_HH__
#ifndef __KERN_SYSTEM_EVENTS_HH__
#define __KERN_SYSTEM_EVENTS_HH__
#include "cpu/pc_event.hh"
@@ -37,11 +37,11 @@ class SkipFuncBase : public PCEvent
virtual void returnFromFuncIn(ThreadContext *tc) = 0;
public:
SkipFuncBase(PCEventScope *s, const std::string &desc, Addr addr)
: PCEvent(s, desc, addr)
SkipFuncBase(PCEventScope *s, const std::string &desc, Addr addr) :
PCEvent(s, desc, addr)
{}
void process(ThreadContext *tc) override;
};
#endif // __SYSTEM_EVENTS_HH__
#endif // __KERN_SYSTEM_EVENTS_HH__