mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
tools: acrntrace: Make TSC frequency configurable
Originally, acrntrace stores cpu frequency in output file and use it for time-based analysis. Actually, we should use TSC frequency instead of cpu frequency. This patch change to using TSC frequency for time-based analysis and introduce an option "-f --frequency" to let user configure TSC frequency. Signed-off-by: Kaige Fu <kaige.fu@intel.com> Reviewed-by: Yan, Like <like.yan@intel.com> Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com>
This commit is contained in:
parent
0d9b163875
commit
2aa0d4074f
@ -11,6 +11,7 @@ This is the main script of arnalyzer, which:
|
|||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
import os
|
import os
|
||||||
|
import config
|
||||||
from vmexit_analyze import analyze_vm_exit
|
from vmexit_analyze import analyze_vm_exit
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
@ -26,6 +27,7 @@ def usage():
|
|||||||
-h: print this message
|
-h: print this message
|
||||||
-i, --ifile=[string]: input file
|
-i, --ifile=[string]: input file
|
||||||
-o, --ofile=[string]: output file
|
-o, --ofile=[string]: output file
|
||||||
|
-f, --frequency=[unsigned int]: TSC frequency in MHz
|
||||||
--vm_exit: to generate vm_exit report
|
--vm_exit: to generate vm_exit report
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -71,8 +73,8 @@ def main(argv):
|
|||||||
"""
|
"""
|
||||||
inputfile = ''
|
inputfile = ''
|
||||||
outputfile = ''
|
outputfile = ''
|
||||||
opts_short = "hi:o:"
|
opts_short = "hi:o:f:"
|
||||||
opts_long = ["ifile=", "ofile=", "vm_exit"]
|
opts_long = ["ifile=", "ofile=", "frequency=", "vm_exit"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, opts_short, opts_long)
|
opts, args = getopt.getopt(argv, opts_short, opts_long)
|
||||||
@ -88,6 +90,8 @@ def main(argv):
|
|||||||
inputfile = arg
|
inputfile = arg
|
||||||
elif opt in ("-o", "--ofile"):
|
elif opt in ("-o", "--ofile"):
|
||||||
outputfile = arg
|
outputfile = arg
|
||||||
|
elif opt in ("-f", "--frequency"):
|
||||||
|
TSC_FREQ = arg
|
||||||
elif opt == "--vm_exit":
|
elif opt == "--vm_exit":
|
||||||
analyzer = analyze_vm_exit
|
analyzer = analyze_vm_exit
|
||||||
else:
|
else:
|
||||||
|
10
tools/acrntrace/scripts/config.py
Normal file
10
tools/acrntrace/scripts/config.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
This file defines global configuration used by acrnalyze
|
||||||
|
"""
|
||||||
|
|
||||||
|
# TSC frequency in MHz
|
||||||
|
# Default TSC frequency of MRB
|
||||||
|
TSC_FREQ = 1881.6
|
@ -6,6 +6,7 @@ This script defines the function to do the vm_exit analysis
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
|
from config import TSC_FREQ
|
||||||
|
|
||||||
TSC_BEGIN = 0L
|
TSC_BEGIN = 0L
|
||||||
TSC_END = 0L
|
TSC_END = 0L
|
||||||
@ -233,28 +234,6 @@ def generate_report(ofile, freq):
|
|||||||
except IOError as err:
|
except IOError as err:
|
||||||
print "Output File Error: " + str(err)
|
print "Output File Error: " + str(err)
|
||||||
|
|
||||||
def get_freq(ifile):
|
|
||||||
""" get cpu freq from the first line of trace file
|
|
||||||
Args:
|
|
||||||
ifile: input trace data file
|
|
||||||
Return:
|
|
||||||
cpu frequency
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
ifp = open(ifile)
|
|
||||||
line = ifp.readline()
|
|
||||||
freq = float(line[10:])
|
|
||||||
|
|
||||||
except IOError as err:
|
|
||||||
print "Failed to get cpu freq"
|
|
||||||
freq = 1920.00
|
|
||||||
|
|
||||||
finally:
|
|
||||||
if 'ifp' in locals():
|
|
||||||
ifp.close()
|
|
||||||
|
|
||||||
return freq
|
|
||||||
|
|
||||||
def analyze_vm_exit(ifile, ofile):
|
def analyze_vm_exit(ifile, ofile):
|
||||||
"""do the vm exits analysis
|
"""do the vm exits analysis
|
||||||
Args:
|
Args:
|
||||||
@ -267,8 +246,6 @@ def analyze_vm_exit(ifile, ofile):
|
|||||||
print("VM exits analysis started... \n\tinput file: %s\n"
|
print("VM exits analysis started... \n\tinput file: %s\n"
|
||||||
"\toutput file: %s.csv" % (ifile, ofile))
|
"\toutput file: %s.csv" % (ifile, ofile))
|
||||||
|
|
||||||
freq = get_freq(ifile)
|
|
||||||
|
|
||||||
parse_trace_data(ifile)
|
parse_trace_data(ifile)
|
||||||
# save report to the output file
|
# save report to the output file
|
||||||
generate_report(ofile, freq)
|
generate_report(ofile, TSC_FREQ)
|
||||||
|
Loading…
Reference in New Issue
Block a user