cirosantilli / linux-kernel-module-cheat

The perfect emulation setup to study and develop the Linux kernel v5.4.3, kernel modules, QEMU, gem5 and x86_64, ARMv7 and ARMv8 userland and baremetal assembly, ANSI C, C++ and POSIX. GDB step debug and KGDB just work. Powered by Buildroot and crosstool-NG. Highly automated. Thoroughly documented. Automated tests. "Tested" in an Ubuntu 24.04 host.
https://cirosantilli.com/linux-kernel-module-cheat
GNU General Public License v3.0
4.17k stars 604 forks source link

How can I know the request in gem5 is issued by which process ? #303

Open claire8967 opened 7 months ago

claire8967 commented 7 months ago

In gem5, I tried to execute three process simultaneously. And In the DRAMInterface.cc doBurstAccess function, we can know that the Mempacket is the argument. Is any method that I can know this packet is issued by which process ?

cirosantilli commented 6 months ago

Hi,

I don't think there's something built-in that gives the answer immediately.

I don't have the time to look into it specifically, but I'll give an idea.

This type of issue is the prototypical gem5 question: what is causing such or such event?

gem5 is fully event based, one event causes other events and so on. So in principle, it is possible to create an event graph and walk backward to the cause.

So what I would try is through logging and parsing of logs to try and create such an event graph, so that you would be trace "memory IO" events all the way back to "cpu tick events".

Then you also have log which process is running on a given CPU tick. On SE this is easy, on FS you need to understand how the OS represents processes and possibly interpret some registers/parse memory. I don't remember the status of this kind of stuff, but there was already some Linux specific support (e.g. detect crash by symbol), and if there's no thread support, it would be a good addition, though possibly a bit of work.

claire8967 commented 6 months ago

Thanks for your reply ! I know what you say but I have problem with how to know the entire event flow in gem5. Is there any tools that I can use? And I found that I can get the taskid and the requestid, is these id is related to process id ?

claire8967 commented 6 months ago

Hi, I think maybe I can use requestorId to differentiate that packet is come from which process. This article https://www.mail-archive.com/gem5-users@gem5.org/msg21144.html show that requestorId is related to cpu. and I can use mem_pkt->requestorId() in the function doBusrtAccess to get the information I want.