Wednesday, May 25, 2022

[SOLVED] Best way to test a custom kernel for hardware performance counters

Issue

I would like to modify an official linux kernel to test some possibilities for perf linux module (I need to modify some files in kernel/events/..., not only tools/perf/...).

Naively, I though of using a VM or Docker but I need to test my custom version with hardware performance counters (HPC); and it's a big problem :

  • Docker can take HPC but I understood but only by my host kernel, I can't test directly a custom kernel without installing it on my system (correct me if I am wrong)
  • The VM can't take HPC because it can't emulate it

What is the best way to test a custom kernel linux without installing directly the kernel on my ubuntu system ? And if I have to, what is the most elegant way to do these tests ? Thank you.


Solution

I found a solution : KVM + QEMU emulator.

To use PMU, I changed this parameter in the VM parameters (XML format) :

<cpu mode='host-passthrough'/>

Or you can add this option in cmd line :

-cpu host

I followed in part this page for building the kernel on qemu and for the counters this page.



Answered By - Matthmatth03
Answer Checked By - Timothy Miller (WPSolving Admin)