Ivan Stalev <ids103 <at> psu.edu> writes:
>
> Hello,
> I am running a SPEC2006 multiprogrammed workload in Full System mode on
X86. My overall goal is to figure out how many instructions each individual
process has executed. For example, if I am running 4 applications on a
single core, I want to know how much "work" each application did compared to
the others.
>
>
>
> Previous similar posts have led me to look at src/arch/x86/stacktrace.cc
where there seem to be functions which return the process name and process
ID. To do a simple test, I was thinking to put a snippet of code such as
this inside the access function in src/mem/cache/cache_impl.hh:
>
>
>
> ThreadContext *tc = system->getThreadContext(pkt->req->threadId());
> Addr stackPtr = tc->readIntReg(30);
> X86ISA::ProcessInfo* procInfo = new X86ISA::ProcessInfo(tc);
>
> int pid = procInfo->pid(stackPtr);
> printf("\npid: %d\n", pid);
> printf("name: %s\n", procInfo->name(stackPtr).c_str());
> delete procInfo;
>
>
>
> However, I am unsure what number to pass to readIntReg, i.e. the x86 stack
pointer register. I would probably also need to figure out when context
switches occur in order to figure out how many instructions each process has
executed.
>
>
> Any help would be greatly appreciated!
>
> Thank you,
>
> Ivan
>
>
> _______________________________________________
> gem5-users mailing list
> gem5-users <at> gem5.org
> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
Update:
I was able to get this to work with the following code snippet:
ThreadContext *tc = system->getThreadContext(thread->threadId());
Addr stackPtr = tc->readIntReg(StackPointerReg);
X86ISA::ProcessInfo* procInfo = new X86ISA::ProcessInfo(tc);
int pid = procInfo->pid(stackPtr);
However, you first need to add in the thread info struct definition to your
kernel and re-compile the kernel: http://repo.m5sim.org/linux-
patches/file/0ab58d9bd9a5/m5/m5struct.diff
Also, be sure that you only call this code after the system is fully booted,
or else you will get a vtophys translation error.
-Ivan
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users