From 95350cbed593326b785434bb468634fe41264c26 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 10 May 2016 19:41:21 +0100 Subject: [PATCH 1/5] libs/utils/trace_analysis: allows to plot even just a single signal A single signal can still be interesting to represent, fix the checks to enable this kind of plots. Signed-off-by: Patrick Bellasi --- libs/utils/trace_analysis.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/utils/trace_analysis.py b/libs/utils/trace_analysis.py index de0b39575..ef0bb8405 100644 --- a/libs/utils/trace_analysis.py +++ b/libs/utils/trace_analysis.py @@ -432,7 +432,7 @@ class TraceAnalysis(object): signals_to_plot = {'load_avg', 'util_avg', 'boosted_util', 'sched_overutilized'} signals_to_plot = list(signals_to_plot.intersection(signals)) - if len(signals_to_plot) > 1: + if len(signals_to_plot) > 0: axes = plt.subplot(gs[plot_id,0]); plot_id = plot_id + 1 is_last = (plot_id == plots_count) @@ -442,7 +442,7 @@ class TraceAnalysis(object): # Plot CPUs residency signals_to_plot = {'residencies', 'sched_overutilized'} signals_to_plot = list(signals_to_plot.intersection(signals)) - if len(signals_to_plot) > 1: + if len(signals_to_plot) > 0: axes = plt.subplot(gs[plot_id,0]); plot_id = plot_id + 1 is_last = (plot_id == plots_count) @@ -454,7 +454,7 @@ class TraceAnalysis(object): 'load_sum', 'util_sum', 'period_contrib', 'sched_overutilized'} signals_to_plot = list(signals_to_plot.intersection(signals)) - if len(signals_to_plot) > 1: + if len(signals_to_plot) > 0: axes = plt.subplot(gs[plot_id,0]); self._plotTaskPelt(df, axes, task_name, signals_to_plot) plot_id = plot_id + 1 -- GitLab From 9fbe85d634e80c7ec861034d5cb59df2cf9add30 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 10 May 2016 19:45:01 +0100 Subject: [PATCH 2/5] libs/utils/trace_analysis: allows to plot tasks on demand If a set of tasks is not specified when the TraceAnalysis object is created the plotTask refuses to honour its own "tasks" input parameter. Let plotTask specify a custom and different set of tasks to be plotted. This can be useful to exploit Filters functions output to get a list of tasks of interest to be plotted. Signed-off-by: Patrick Bellasi --- libs/utils/trace_analysis.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/utils/trace_analysis.py b/libs/utils/trace_analysis.py index ef0bb8405..1a2682c2a 100644 --- a/libs/utils/trace_analysis.py +++ b/libs/utils/trace_analysis.py @@ -398,9 +398,13 @@ class TraceAnalysis(object): return df = self.trace.df('sched_load_avg_task') self.trace.getTasks(df, tasks) - tasks_to_plot = sorted(self.tasks) if tasks: tasks_to_plot = tasks + elif self.tasks: + tasks_to_plot = sorted(self.tasks) + else: + raise ValueError('No tasks to plot specified') + # Compute number of plots to produce plots_count = 0 -- GitLab From aca8c6c3ff885ac2244e098cb2770281673f9233 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 10 May 2016 19:46:49 +0100 Subject: [PATCH 3/5] libs/utils/trace_analysis: allows plots of tasks with a "/" in their name Some tasks, e.g. kernel threads, can use a "/" in their name, which confuses the filepath creation. This patch convert taskname's "/" into "_" to get a valid filename to store the generated plot. Signed-off-by: Patrick Bellasi --- libs/utils/trace_analysis.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/utils/trace_analysis.py b/libs/utils/trace_analysis.py index 1a2682c2a..dcf16b87e 100644 --- a/libs/utils/trace_analysis.py +++ b/libs/utils/trace_analysis.py @@ -464,7 +464,8 @@ class TraceAnalysis(object): plot_id = plot_id + 1 # Save generated plots into datadir - figname = '{}/{}task_util_{}.png'.format(self.plotsdir, self.prefix, task_name) + figname = '{}/{}task_util_{}.png'.format( + self.plotsdir, self.prefix, task_name.replace('/', '_')) pl.savefig(figname, bbox_inches='tight') def plotEDiffTime(self, tasks=None, -- GitLab From 1d66527135c1de29a4b2cea652a84c7da673f46d Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 10 May 2016 19:50:11 +0100 Subject: [PATCH 4/5] libs/utils/trace_analysis: ensure a valid range is defined by default When a trace is parse with normalize_time=False, the time axis uses absolute timestamps collected from the trace. This patch ensure that the XRange matches the start/end absolute times specified by the trace. Signed-off-by: Patrick Bellasi --- libs/utils/trace_analysis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/utils/trace_analysis.py b/libs/utils/trace_analysis.py index dcf16b87e..83f4a33bc 100644 --- a/libs/utils/trace_analysis.py +++ b/libs/utils/trace_analysis.py @@ -53,7 +53,9 @@ class TraceAnalysis(object): self.x_max = self.trace.time_range # Reset x axis time range to full scale - self.setXTimeRange() + t_min = self.trace.window[0] + t_max = self.trace.window[1] + self.setXTimeRange(t_min, t_max) def setXTimeRange(self, t_min=None, t_max=None): if t_min is None: -- GitLab From 59125cff05d07d0a8c5e25a6be4c39f141ef3984 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 10 May 2016 19:52:32 +0100 Subject: [PATCH 5/5] libs/utils/trace_analysis: warn on missing data Let's generate at least a warning when no frequency events are present in a trace. This usually means that we are using a fixed frequency governor and the trace has been collected without fake cpu_frequency events injection at the begin and end of the trace (e.g. using systrace/atrace) Signed-off-by: Patrick Bellasi --- libs/utils/trace_analysis.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/utils/trace_analysis.py b/libs/utils/trace_analysis.py index 83f4a33bc..a708513d2 100644 --- a/libs/utils/trace_analysis.py +++ b/libs/utils/trace_analysis.py @@ -128,6 +128,8 @@ class TraceAnalysis(object): if len(bfreq) > 0: bfreq['frequency'].plot(style=['r-'], ax=axes, drawstyle='steps-post', alpha=0.4); + else: + logging.warn('NO big CPUs frequency events to plot') axes.set_xlim(self.x_min, self.x_max); axes.set_ylabel('MHz') axes.grid(True); @@ -146,6 +148,8 @@ class TraceAnalysis(object): if len(lfreq) > 0: lfreq['frequency'].plot(style=['b-'], ax=axes, drawstyle='steps-post', alpha=0.4); + else: + logging.warn('NO LITTLE CPUs frequency events to plot') axes.set_xlim(self.x_min, self.x_max); axes.set_ylabel('MHz') axes.grid(True); -- GitLab