Search code examples
profilingvirtualizationkvmperf

How to profile an app running inside KVM guest


Is there any way to profile an application running inside KVM guest using a tool like perf_events?

I've tried to do that using

perf kvm --guestkallsyms=.. --guestmodules=.. --guest record -a

but information in report is pretty useless:

# ========
#
# Samples: 627  of event 'cache-misses'
# Event count (approx.): 295421
#
# Overhead  Command     Shared Object                  Symbol
# ........  .......  ................  ......................
#
    73.18%   :15661  [x_tables]        [g] 0xffffffff8176bc80
    26.82%   :15661  [unknown]         [u] 0x00000000004004fe


#
# (For a higher level overview, try: perf report --sort comm,dso)
#

Solution

  • No.

    The perf tool runs in the host and does not have any way to get information about the applications in the guest. I think the attribution of samples to guest-kernelspace or guest-userspace is based on the cpu-mode at the time the sample was taken (not on higher-level information about what the guest is doing).

    You can get some profiling information by running perf directly in the guest. Use perf list to see the options (they are probably all in the 'software' category).