How can a specific application be monitored by perf inside the kvm?

对着背影说爱祢 提交于 2019-12-13 01:38:11

问题


I have an application which I want to monitor it via perf stat when running inside a kvm VM. After Googling I have found that perf kvm stat can do this. However there is an error by running the command:

sudo perf kvm stat record  -p appPID

which results in help representation ...

usage: perf kvm stat record [<options>]

-p, --pid <pid>       record events on existing process id
-t, --tid <tid>       record events on existing thread id
-r, --realtime <n>    collect data with this RT SCHED_FIFO priority
    --no-buffering    collect data without buffering
-a, --all-cpus        system-wide collection from all CPUs
-C, --cpu <cpu>       list of cpus to monitor
-c, --count <n>       event period to sample
-o, --output <file>   output file name
-i, --no-inherit      child tasks do not inherit counters
-m, --mmap-pages <pages[,pages]>
                      number of mmap data pages and AUX area tracing mmap pages
-v, --verbose         be more verbose (show counter open errors, etc)
-q, --quiet           don't print any message

Does any one know what is the problem?


回答1:


Use kvm with vPMU (virtualization of PMU counters) - https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Tuning_and_Optimization_Guide/sect-Virtualization_Tuning_Optimization_Guide-Monitoring_Tools-vPMU.html "2.2. VIRTUAL PERFORMANCE MONITORING UNIT (VPMU)"). Then run perf record -p $pid and perf stat -p $pid inside the guest.

Host system has no knowledge (tables) of guest processes (they are managed by guest kernel, which can be non Linux, or different version of linux with incompatible table format), so host kernel can't profile some specific guest process. It only can profile whole guest (and there is perf kvm command - https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Tuning_and_Optimization_Guide/chap-Virtualization_Tuning_Optimization_Guide-Monitoring_Tools.html#sect-Virtualization_Tuning_Optimization_Guide-Monitoring_Tools-perf_kvm)



来源:https://stackoverflow.com/questions/35997809/how-can-a-specific-application-be-monitored-by-perf-inside-the-kvm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!