mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:59:29 +02:00
tools/power: intel_pstate_tracer: avoid optional imports for help
intel_pstate_tracer imports Gnuplot and numpy before parsing command-line options. As a result, even "-h" fails if those optional runtime modules are not installed. Move the imports to the paths that need them. This lets the help and invalid-argument paths describe usage without requiring plotting/data dependencies. While there, fix a typo in the help text and matching comments. Signed-off-by: Yousef Alhouseen <alhouseenyousef@gmail.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20260624122747.5418-1-alhouseenyousef@gmail.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
1590cf0329
commit
87bc1e3498
@@ -32,8 +32,6 @@ import re
|
||||
import signal
|
||||
import sys
|
||||
import getopt
|
||||
import Gnuplot
|
||||
from numpy import *
|
||||
from decimal import *
|
||||
|
||||
__author__ = "Srinivas Pandruvada"
|
||||
@@ -88,8 +86,8 @@ def print_help(driver_name):
|
||||
print(' kbytes: Kilo bytes of memory per CPU to allocate to the trace buffer. Default: 10240')
|
||||
print(' Output:')
|
||||
print(' If not already present, creates a "results/test_name" folder in the current working directory with:')
|
||||
print(' cpu.csv - comma seperated values file with trace contents and some additional calculations.')
|
||||
print(' cpu???.csv - comma seperated values file for CPU number ???.')
|
||||
print(' cpu.csv - comma separated values file with trace contents and some additional calculations.')
|
||||
print(' cpu???.csv - comma separated values file for CPU number ???.')
|
||||
print(' *.png - a variety of PNG format plot files created from the trace contents and the additional calculations.')
|
||||
print(' Notes:')
|
||||
print(' Avoid the use of _ (underscore) in test names, because in gnuplot it is a subscript directive.')
|
||||
@@ -295,6 +293,8 @@ def common_all_gnuplot_settings(output_png):
|
||||
def common_gnuplot_settings():
|
||||
""" common gnuplot settings. """
|
||||
|
||||
import Gnuplot
|
||||
|
||||
g_plot = Gnuplot.Gnuplot(persist=1)
|
||||
# The following line is for rigor only. It seems to be assumed for .csv files
|
||||
g_plot('set datafile separator \",\"')
|
||||
@@ -343,7 +343,7 @@ def store_csv(cpu_int, time_pre_dec, time_post_dec, core_busy, scaled, _from, _t
|
||||
graph_data_present = True;
|
||||
|
||||
def split_csv(current_max_cpu, cpu_mask):
|
||||
""" seperate the all csv file into per CPU csv files. """
|
||||
""" separate the main csv file into per CPU csv files. """
|
||||
|
||||
if os.path.exists('cpu.csv'):
|
||||
for index in range(0, current_max_cpu + 1):
|
||||
@@ -482,7 +482,7 @@ def read_trace_data(filename, cpu_mask):
|
||||
if cpu_int > current_max_cpu:
|
||||
current_max_cpu = cpu_int
|
||||
# End of for each trace line loop
|
||||
# Now seperate the main overall csv file into per CPU csv files.
|
||||
# Now separate the main overall csv file into per CPU csv files.
|
||||
split_csv(current_max_cpu, cpu_mask)
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
@@ -508,8 +508,6 @@ if __name__ == "__main__":
|
||||
valid1 = False
|
||||
valid2 = False
|
||||
|
||||
cpu_mask = zeros((MAX_CPUS,), dtype=int)
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:],"ht:i:c:n:m:",["help","trace_file=","interval=","cpu=","name=","memory="])
|
||||
except getopt.GetoptError:
|
||||
@@ -538,6 +536,10 @@ if __name__ == "__main__":
|
||||
print_help('intel_pstate')
|
||||
sys.exit()
|
||||
|
||||
from numpy import zeros
|
||||
|
||||
cpu_mask = zeros((MAX_CPUS,), dtype=int)
|
||||
|
||||
if cpu_list:
|
||||
for p in re.split("[,]", cpu_list):
|
||||
if int(p) < MAX_CPUS :
|
||||
|
||||
Reference in New Issue
Block a user