[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250610040536.2390060-1-tianyou.li@intel.com>
Date: Tue, 10 Jun 2025 12:04:22 +0800
From: Tianyou Li <tianyou.li@...el.com>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Cc: Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>,
tianyou.li@...el.com,
wangyang.guo@...el.com,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] Read perf data file header from the file user specified with -i option for perf script flamegraph
If specify the perf data file with -i option, the script will try to read the header information
regardless of the file name specified, instead it will try to access the perf.data. This simple
patch use the file name from -i option for command perf report --header-only to read the header.
Signed-off-by: Tianyou Li <tianyou.li@...el.com>
Reviewed-by: Pan Deng <pan.deng@...el.com>
Reviewed-by: Zhiguo Zhou <zhiguo.zhou@...el.com>
Reviewed-by: Wangyang Guo <wangyang.guo@...el.com>
Reviewed-by: Tim Chen <tim.c.chen@...ux.intel.com>
---
tools/perf/scripts/python/flamegraph.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/flamegraph.py b/tools/perf/scripts/python/flamegraph.py
index cf7ce8229a6c..4f82dfea0a70 100755
--- a/tools/perf/scripts/python/flamegraph.py
+++ b/tools/perf/scripts/python/flamegraph.py
@@ -123,7 +123,13 @@ class FlameGraphCLI:
return ""
try:
- output = subprocess.check_output(["perf", "report", "--header-only"])
+ # if the file name other than perf.data is given,
+ # we read the header of that file
+ if self.args.input:
+ output = subprocess.check_output(["perf", "report", "--header-only", "-i", self.args.input])
+ else:
+ output = subprocess.check_output(["perf", "report", "--header-only"])
+
return output.decode("utf-8")
except Exception as err: # pylint: disable=broad-except
print("Error reading report header: {}".format(err), file=sys.stderr)
--
2.47.1
Powered by blists - more mailing lists