mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-01 20:05:30 +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 getopt
|
||||
import os
|
||||
import config
|
||||
from vmexit_analyze import analyze_vm_exit
|
||||
|
||||
def usage():
|
||||
@ -26,6 +27,7 @@ def usage():
|
||||
-h: print this message
|
||||
-i, --ifile=[string]: input file
|
||||
-o, --ofile=[string]: output file
|
||||
-f, --frequency=[unsigned int]: TSC frequency in MHz
|
||||
--vm_exit: to generate vm_exit report
|
||||
'''
|
||||
|
||||
@ -71,8 +73,8 @@ def main(argv):
|
||||
"""
|
||||
inputfile = ''
|
||||
outputfile = ''
|
||||
opts_short = "hi:o:"
|
||||
opts_long = ["ifile=", "ofile=", "vm_exit"]
|
||||
opts_short = "hi:o:f:"
|
||||
opts_long = ["ifile=", "ofile=", "frequency=", "vm_exit"]
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, opts_short, opts_long)
|
||||
@ -88,6 +90,8 @@ def main(argv):
|
||||
inputfile = arg
|
||||
elif opt in ("-o", "--ofile"):
|
||||
outputfile = arg
|
||||
elif opt in ("-f", "--frequency"):
|
||||
TSC_FREQ = arg
|
||||
elif opt == "--vm_exit":
|
||||
analyzer = analyze_vm_exit
|
||||
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
|
||||
from config import TSC_FREQ
|
||||
|
||||
TSC_BEGIN = 0L
|
||||
TSC_END = 0L
|
||||
@ -233,28 +234,6 @@ def generate_report(ofile, freq):
|
||||
except IOError as 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):
|
||||
"""do the vm exits analysis
|
||||
Args:
|
||||
@ -267,8 +246,6 @@ def analyze_vm_exit(ifile, ofile):
|
||||
print("VM exits analysis started... \n\tinput file: %s\n"
|
||||
"\toutput file: %s.csv" % (ifile, ofile))
|
||||
|
||||
freq = get_freq(ifile)
|
||||
|
||||
parse_trace_data(ifile)
|
||||
# save report to the output file
|
||||
generate_report(ofile, freq)
|
||||
generate_report(ofile, TSC_FREQ)
|
||||
|
Loading…
Reference in New Issue
Block a user