When Xen is testing or tuning, you need to perform a lower level of detail analysis (such as the frequency of statistics vmexit, the type of vmexit, how much CPU time is consumed by vmexit), and then you can use the Xentrace tool.
Xentrace is a tool that comes with the Xen source code and is generated by default when make Tools is compiled. Xentrace generated data is a binary format, the human eye can not directly read, the use of Xentrace_format converted to the human can directly read the information, Xentrace_format after the resolution of the volume of data is generally relatively large, You may also need to write your own parsing tools to extract the data you need.
Using Xentrace/xentrace_format to analyze the vmexit of HVM, you can do the following:
The code is as follows |
Copy Code |
# # Start Xen HVM Guest before this tracing # xentrace-d-E 0x81000-t trace.data # Cat Trace.data | Xentrace_format xen.git/tools/xentrace/formats |./my-xentrace-analyzer.pl |
Wherein-e 0x81000 refers to the trace information of an event such as "Trc_hvm_entryexit", including Vmentry and Vmexit, as well as the number of other event codes, which refer to the reference document at the end of the article; t 30 indicates that trace execution time is 30s.
When using Xentrace_format, you need a format file as an argument, and you can generally choose the Tools/xentrace/formats file in the Xen source code.
In addition, here I have a script to extract the data I am interested in, and get the result example as follows:
The code is as follows |
Copy Code |
Vmexit count:1117671 Type Total TSC TSC Ratio Total Count count Ratio Avg TSC External Interrupt 2427891244 0.17 347544 0.31 6985 Interrupt Window 20988 0.00 10 0.00 2098 HLT 9750387024 0.66 437459 0.39 22288 Vmcall 178912 0.00 10 0.00 17891 CR Access 402600 0.00 72 0.00 5591 I/o instruction 1041358192 0.07 30747 0.03 33868 PAUSE 35244752 0.00 8067 0.01 4369 Virtualized EOI 39250184 0.00 14425 0.01 2720 EPT violation 44358300 0.00 3179 0.00 13953 APIC Write 1333734836 0.09 276158 0.25 4829 |
for various vmexit types, refer to the Appendix Appendix C "VMX Basic Exit reasons" in the Intel SDM 3C. The
Xen Community also makes a tool for parsing xentrace data, called Xenalyze (a repository that is offline maintained in the Xen source code), and I used it, and I'm not familiar with it. The source code for the
Xenalyze can be downloaded from http://xenbits.xen.org/ext/xenalyze/(using the HG clone command).
When used, note that the frequency of the CPU used in the xenalyze, need to be based on the actual frequency of their own CPU to modify, otherwise calculate how many events per second such information is not allowed. Modify the "#define DEFAULT_CPU_HZ 2400000000LL" line in the xenalyze.c file (2.4GHz has already been represented).