mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-15 15:04:27 +08:00
perf stat: Factor out evsel__count_has_error()
It's possible to have 0 enabled/running time for some per-task or per-cgroup events since it's not scheduled on any CPU. Treating the whole event as failed would not work in this case. Thinking again, the code only existed when any CPU-level aggregation is enabled (like per-socket, per-core, ...). To make it clearer, factor out the condition check into the new evsel__count_has_error() function and add some comments. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Link: https://lore.kernel.org/r/20221018020227.85905-11-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f976bc6b6b
commit
049aba09e2
@ -381,6 +381,25 @@ static int check_per_pkg(struct evsel *counter, struct perf_counts_values *vals,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool evsel__count_has_error(struct evsel *evsel,
|
||||||
|
struct perf_counts_values *count,
|
||||||
|
struct perf_stat_config *config)
|
||||||
|
{
|
||||||
|
/* the evsel was failed already */
|
||||||
|
if (evsel->err || evsel->counts->scaled == -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* this is meaningful for CPU aggregation modes only */
|
||||||
|
if (config->aggr_mode == AGGR_GLOBAL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* it's considered ok when it actually ran */
|
||||||
|
if (count->ena != 0 && count->run != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
|
process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
|
||||||
int cpu_map_idx, int thread,
|
int cpu_map_idx, int thread,
|
||||||
@ -420,8 +439,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
|
|||||||
* When any result is bad, make them all to give
|
* When any result is bad, make them all to give
|
||||||
* consistent output in interval mode.
|
* consistent output in interval mode.
|
||||||
*/
|
*/
|
||||||
if (count->ena == 0 || count->run == 0 ||
|
if (evsel__count_has_error(evsel, count, config) && !ps_aggr->failed) {
|
||||||
evsel->counts->scaled == -1) {
|
|
||||||
ps_aggr->counts.val = 0;
|
ps_aggr->counts.val = 0;
|
||||||
ps_aggr->counts.ena = 0;
|
ps_aggr->counts.ena = 0;
|
||||||
ps_aggr->counts.run = 0;
|
ps_aggr->counts.run = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user