[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fWO3B9HT3oQ_7qtd=pQBpcUK7VRtcpLoBbKkGsnaH1YRA@mail.gmail.com>
Date: Wed, 30 Oct 2024 21:17:52 -0700
From: Ian Rogers <irogers@...gle.com>
To: James Clark <james.clark@...aro.org>
Cc: linux-perf-users@...r.kernel.org, acme@...nel.org, namhyung@...nel.org,
tim.c.chen@...ux.intel.com, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, "Liang, Kan" <kan.liang@...ux.intel.com>,
Yicong Yang <yangyicong@...ilicon.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] perf stat: Also hide metric-units from JSON when
event didn't run
On Wed, Oct 30, 2024 at 4:40 AM James Clark <james.clark@...aro.org> wrote:
>
> We decided to hide NULL metric-units rather than showing it as "(null)"
> when a dependent event for a metric doesn't exist. But on hybrid systems
> if the process doesn't hit a PMU you get an empty string metric unit
> instead. To make it consistent change all empty strings to NULL.
>
> Note that metric-threshold is already hidden in this case without this
> change.
>
> Where a process only runs on cpu_core and never hits cpu_atom:
> Before:
> $ perf stat -j -- true
> ...
> {"counter-value" : "<not counted>", "unit" : "", "event" : "cpu_atom/branch-misses/", "event-runtime" : 0, "pcnt-running" : 0.00, "metric-value" : "0.000000", "metric-unit" : ""}
> {"counter-value" : "6326.000000", "unit" : "", "event" : "cpu_core/branch-misses/", "event-runtime" : 293786, "pcnt-running" : 100.00, "metric-value" : "3.553394", "metric-unit" : "of all branches", "metric-threshold" : "good"}
> ...
>
> After:
> ...
> {"counter-value" : "<not counted>", "unit" : "", "event" : "cpu_atom/branch-misses/", "event-runtime" : 0, "pcnt-running" : 0.00}
> {"counter-value" : "5778.000000", "unit" : "", "event" : "cpu_core/branch-misses/", "event-runtime" : 282240, "pcnt-running" : 100.00, "metric-value" : "3.226797", "metric-unit" : "of all branches", "metric-threshold" : "good"}
> ...
>
> Signed-off-by: James Clark <james.clark@...aro.org>
Reviewed-by: Ian Rogers <irogers@...gle.com>
Thanks,
Ian
> ---
> tools/perf/util/stat-display.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index a5d72f4a515c..0e16eecfbad8 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -854,7 +854,8 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
>
> if (run == 0 || ena == 0 || counter->counts->scaled == -1) {
> if (config->metric_only) {
> - pm(config, os, METRIC_THRESHOLD_UNKNOWN, "", "", 0);
> + pm(config, os, METRIC_THRESHOLD_UNKNOWN, /*format=*/NULL,
> + /*unit=*/NULL, /*val=*/0);
> return;
> }
>
> @@ -909,7 +910,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
> perf_stat__print_shadow_stats(config, counter, uval, aggr_idx,
> &out, &config->metric_events);
> } else {
> - pm(config, os, METRIC_THRESHOLD_UNKNOWN, /*format=*/NULL, /*unit=*/"", /*val=*/0);
> + pm(config, os, METRIC_THRESHOLD_UNKNOWN, /*format=*/NULL, /*unit=*/NULL, /*val=*/0);
> }
>
> if (!config->metric_only) {
> --
> 2.34.1
>
Powered by blists - more mailing lists