Linux Power Management development
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Yousef Alhouseen <alhouseenyousef@gmail.com>,
	Len Brown <lenb@kernel.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	linux-pm@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools/power: intel_pstate_tracer: avoid optional imports for help
Date: Wed, 08 Jul 2026 16:33:11 -0700	[thread overview]
Message-ID: <31f103769bc42ad4ab03aea7131fc6d3ceb248d5.camel@linux.intel.com> (raw)
In-Reply-To: <20260624122747.5418-1-alhouseenyousef@gmail.com>

On Wed, 2026-06-24 at 14:27 +0200, Yousef Alhouseen wrote:
> 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>

> ---
>  .../intel_pstate_tracer/intel_pstate_tracer.py | 18 ++++++++++------
> --
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git
> a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> index 38cfbdcde..64001bc80 100755
> --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> @@ -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=","inter
> val=","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 :

      reply	other threads:[~2026-07-08 23:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-24 12:27 [PATCH] tools/power: intel_pstate_tracer: avoid optional imports for help Yousef Alhouseen
2026-07-08 23:33 ` srinivas pandruvada [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31f103769bc42ad4ab03aea7131fc6d3ceb248d5.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=alhouseenyousef@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox