mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-05 21:52:08 +00:00
tools: Fix the non-effective option -f --frequency
We use global variable TSC_FREQ defined in config.py in each of the analyzers. And the value set to TSC_FREQ through option -f/--frequency doesn't take effect. This patch fix it by adding one parameter to each of the analyzers and pass the value set by -f/--frequency to it instead of use the global one. Tracked-On: #3085 Signed-off-by: Kaige Fu <kaige.fu@intel.com> Acked-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
parent
1f93f7f46c
commit
21b82d8815
@ -10,7 +10,6 @@ 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
|
||||||
from irq_analyze import analyze_irq
|
from irq_analyze import analyze_irq
|
||||||
|
|
||||||
@ -32,20 +31,21 @@ def usage():
|
|||||||
--irq: to generate irq related report
|
--irq: to generate irq related report
|
||||||
''')
|
''')
|
||||||
|
|
||||||
def do_analysis(ifile, ofile, analyzer):
|
def do_analysis(ifile, ofile, analyzer, freq):
|
||||||
"""do the specific analysis
|
"""do the specific analysis
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
ifile: input trace data file
|
ifile: input trace data file
|
||||||
ofile: output analysis report file
|
ofile: output analysis report file
|
||||||
analyzer: a function do the specific analysis
|
analyzer: a function do the specific analysis
|
||||||
|
freq: TSC frequency of the host where we capture the trace data
|
||||||
Returns:
|
Returns:
|
||||||
None
|
None
|
||||||
Raises:
|
Raises:
|
||||||
NA
|
NA
|
||||||
"""
|
"""
|
||||||
for alyer in analyzer:
|
for alyer in analyzer:
|
||||||
alyer(ifile, ofile)
|
alyer(ifile, ofile, freq)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
"""Main enterance function
|
"""Main enterance function
|
||||||
@ -59,6 +59,8 @@ def main(argv):
|
|||||||
"""
|
"""
|
||||||
inputfile = ''
|
inputfile = ''
|
||||||
outputfile = ''
|
outputfile = ''
|
||||||
|
# Default TSC frequency of MRB in MHz
|
||||||
|
freq = 1881.6
|
||||||
opts_short = "hi:o:f:"
|
opts_short = "hi:o:f:"
|
||||||
opts_long = ["ifile=", "ofile=", "frequency=", "vm_exit", "irq"]
|
opts_long = ["ifile=", "ofile=", "frequency=", "vm_exit", "irq"]
|
||||||
analyzer = []
|
analyzer = []
|
||||||
@ -78,7 +80,7 @@ def main(argv):
|
|||||||
elif opt in ("-o", "--ofile"):
|
elif opt in ("-o", "--ofile"):
|
||||||
outputfile = arg
|
outputfile = arg
|
||||||
elif opt in ("-f", "--frequency"):
|
elif opt in ("-f", "--frequency"):
|
||||||
TSC_FREQ = arg
|
freq = arg
|
||||||
elif opt == "--vm_exit":
|
elif opt == "--vm_exit":
|
||||||
analyzer.append(analyze_vm_exit)
|
analyzer.append(analyze_vm_exit)
|
||||||
elif opt == "--irq":
|
elif opt == "--irq":
|
||||||
@ -90,7 +92,7 @@ def main(argv):
|
|||||||
assert outputfile != '', "output file is required"
|
assert outputfile != '', "output file is required"
|
||||||
assert analyzer != '', 'MUST contain one of analyzer: ''vm_exit'
|
assert analyzer != '', 'MUST contain one of analyzer: ''vm_exit'
|
||||||
|
|
||||||
do_analysis(inputfile, outputfile, analyzer)
|
do_analysis(inputfile, outputfile, analyzer, freq)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#!/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
|
|
@ -7,7 +7,6 @@ This script defines the function to do the irq related analysis
|
|||||||
|
|
||||||
import csv
|
import csv
|
||||||
import struct
|
import struct
|
||||||
from config import TSC_FREQ
|
|
||||||
|
|
||||||
TSC_BEGIN = 0
|
TSC_BEGIN = 0
|
||||||
TSC_END = 0
|
TSC_END = 0
|
||||||
@ -90,11 +89,12 @@ 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 analyze_irq(ifile, ofile):
|
def analyze_irq(ifile, ofile, freq):
|
||||||
"""do the vm exits analysis
|
"""do the vm exits analysis
|
||||||
Args:
|
Args:
|
||||||
ifile: input trace data file
|
ifile: input trace data file
|
||||||
ofile: output report file
|
ofile: output report file
|
||||||
|
freq: TSC frequency of the host where we capture the trace data
|
||||||
Return:
|
Return:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
@ -104,4 +104,4 @@ def analyze_irq(ifile, ofile):
|
|||||||
|
|
||||||
parse_trace(ifile)
|
parse_trace(ifile)
|
||||||
# save report to the output file
|
# save report to the output file
|
||||||
generate_report(ofile, TSC_FREQ)
|
generate_report(ofile, freq)
|
||||||
|
@ -7,7 +7,6 @@ This script defines the function to do the vm_exit analysis
|
|||||||
|
|
||||||
import csv
|
import csv
|
||||||
import struct
|
import struct
|
||||||
from config import TSC_FREQ
|
|
||||||
|
|
||||||
TSC_BEGIN = 0
|
TSC_BEGIN = 0
|
||||||
TSC_END = 0
|
TSC_END = 0
|
||||||
@ -163,13 +162,13 @@ def generate_report(ofile, freq):
|
|||||||
total_exit_time += TIME_IN_EXIT[event]
|
total_exit_time += TIME_IN_EXIT[event]
|
||||||
|
|
||||||
print ("Total run time: %d cycles" % (rt_cycle))
|
print ("Total run time: %d cycles" % (rt_cycle))
|
||||||
print ("TSC Freq: %f MHz" % (freq))
|
print ("TSC Freq: %s MHz" % (freq))
|
||||||
print ("Total run time: %d sec" % (rt_sec))
|
print ("Total run time: %d sec" % (rt_sec))
|
||||||
|
|
||||||
f_csv.writerow(['Run time(cycles)', 'Run time(Sec)', 'Freq(MHz)'])
|
f_csv.writerow(['Run time(cycles)', 'Run time(Sec)', 'Freq(MHz)'])
|
||||||
f_csv.writerow(['%d' % (rt_cycle),
|
f_csv.writerow(['%d' % (rt_cycle),
|
||||||
'%.3f' % (rt_sec),
|
'%.3f' % (rt_sec),
|
||||||
'%d' % (freq)])
|
'%s' % (freq)])
|
||||||
|
|
||||||
print ("%-28s\t%-12s\t%-12s\t%-24s\t%-16s" % ("Event", "NR_Exit",
|
print ("%-28s\t%-12s\t%-12s\t%-24s\t%-16s" % ("Event", "NR_Exit",
|
||||||
"NR_Exit/Sec", "Time Consumed(cycles)", "Time percentage"))
|
"NR_Exit/Sec", "Time Consumed(cycles)", "Time percentage"))
|
||||||
@ -200,11 +199,12 @@ 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 analyze_vm_exit(ifile, ofile):
|
def analyze_vm_exit(ifile, ofile, freq):
|
||||||
"""do the vm exits analysis
|
"""do the vm exits analysis
|
||||||
Args:
|
Args:
|
||||||
ifile: input trace data file
|
ifile: input trace data file
|
||||||
ofile: output report file
|
ofile: output report file
|
||||||
|
freq: TSC frequency of the host where we capture the trace data
|
||||||
Return:
|
Return:
|
||||||
None
|
None
|
||||||
"""
|
"""
|
||||||
@ -214,4 +214,4 @@ def analyze_vm_exit(ifile, ofile):
|
|||||||
|
|
||||||
parse_trace_data(ifile)
|
parse_trace_data(ifile)
|
||||||
# save report to the output file
|
# save report to the output file
|
||||||
generate_report(ofile, TSC_FREQ)
|
generate_report(ofile, freq)
|
||||||
|
Loading…
Reference in New Issue
Block a user