cirosantilli2 / issues

Hello! If you have anything to say to me, feel free to open an issue, and I will reply. For gem5 issues, prefer asking on Stack Overflow or the mailing list: https://www.gem5.org/mailing_lists/ or: https://github.com/cirosantilli2/gem5-issues
1 stars 0 forks source link

Add event to PUM in ARM simulated in Gem5 #13

Open 1Husin-Alhaj opened 3 years ago

1Husin-Alhaj commented 3 years ago

Regarding this Using perf_event with the ARM PMU inside gem5

I need to use perf_event to access pmu in Arm processor in Gem5. According to many web pages and stackoverflow posts, and some help from Gem5 users, I have to create, or modify the script file to tell the gem5 to create an entry for pmu in the DTB file for which the kernel will be able to find pmu.

Regarding the full system simulation, I need to modify the starter_fs.py file and add the below code to enable pmu:

   for cpu in system.cpu_cluster.cpus:
    for isa in cpu.isa:
        isa.pmu = ArmPMU(interrupt=ArmPPI(num=20))
        # Add the implemented architectural events of gem5. We can
        # discover which events is implemented by looking at the file
        # "ArmPMU.py".
        isa.pmu.addArchEvents(
            cpu=cpu, dtb=cpu.dtb, itb=cpu.itb,
            icache=getattr(cpu, "icache", None),
            dcache=getattr(cpu, "dcache", None),
            l2cache=getattr(system.cpu_cluster, "l2", None))

However, I got this error while trying to boot system ...

    for cpu in system.cpu_cluster.cpus:
AttributeError: 'SimObjectVector' object has no attribute 'cpus'

I don't know what is the correct place inside the starter_fs.py file to append the mentioned code (I'm not a python user)

Any help? thanks

cirosantilli2 commented 3 years ago

Hi Husin,

Note that as mentioned in that answer, you don't need to do anything to the DTB anymore BTW, it should get automatically generated on develop.

Every script has a slightly different SimObject tree. The easiest way is to do a normal run without PMU patches, and then look at the m5out/config.ini file to see what the tree looks like. Then using that information you can adapt the patch to use the correct object locations, see also: https://cirosantilli.com/linux-kernel-module-cheat/#gem5-config-ini

I've also added a fs.py example at: https://stackoverflow.com/questions/63988672/using-perf-event-with-the-arm-pmu-inside-gem5/65058284#65058284

Let me know if you still don't manage after looking into config.ini.

1Husin-Alhaj commented 3 years ago

Hi Ciro, Thank you very much for your help and valuable clarification, and sorry for delay ... I used the fs.py file you mentioned in the provided link (but I removed all thinks about pmu listener), and it is worked correctly. the same code, I moved it to starter_fs.py, but it doesn't work. BTW, thank you very much, now I can access the pmu and can perform profiling process by monitoring the available events supported by Gem5.