[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241112160048.951213-6-james.clark@linaro.org>
Date: Tue, 12 Nov 2024 16:00:45 +0000
From: James Clark <james.clark@...aro.org>
To: linux-perf-users@...r.kernel.org,
acme@...nel.org,
namhyung@...nel.org,
irogers@...gle.com,
tim.c.chen@...ux.intel.com
Cc: James Clark <james.clark@...aro.org>,
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: [PATCH v3 5/5] perf stat: Document and clarify outstate members
Not all of these are "state" so separate them into two sections. Rename
and document to make all clearer.
Signed-off-by: James Clark <james.clark@...aro.org>
---
tools/perf/util/stat-display.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index 8377e24602dd..ba79f73e1cf5 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -115,15 +115,29 @@ static void print_running_csv(struct perf_stat_config *config, u64 run, u64 ena)
config->csv_sep, run, config->csv_sep, enabled_percent);
}
struct outstate {
- FILE *fh;
+ /* Std mode: insert a newline before the next metric */
bool newline;
+ /* JSON mode: track need for comma for a previous field or not */
bool first;
+ /* Num CSV separators remaining to pad out when not all fields are printed */
+ int csv_col_pad;
+
+ /*
+ * The following don't track state across fields, but are here as a shortcut to
+ * pass data to the print functions. The alternative would be to update the
+ * function signatures of the entire print stack to pass them through.
+ */
+ /* Place to output to */
+ FILE * const fh;
/* Lines are timestamped in --interval-print mode */
char timestamp[64];
- int nfields;
- int aggr_nr;
+ /* Num items aggregated in current line. See struct perf_stat_aggr.nr */
+ int aggr_nr;
+ /* Core/socket/die etc ID for the current line */
struct aggr_cpu_id id;
+ /* Event for current line */
struct evsel *evsel;
+ /* Cgroup for current line */
struct cgroup *cgrp;
};
@@ -473,7 +487,7 @@ static void new_line_csv(struct perf_stat_config *config, void *ctx)
int i;
__new_line_std_csv(config, os);
- for (i = 0; i < os->nfields; i++)
+ for (i = 0; i < os->csv_col_pad; i++)
fputs(config->csv_sep, os->fh);
}
@@ -550,12 +564,12 @@ static void print_metricgroup_header_csv(struct perf_stat_config *config,
if (!metricgroup_name) {
/* Leave space for running and enabling */
- for (i = 0; i < os->nfields - 2; i++)
+ for (i = 0; i < os->csv_col_pad - 2; i++)
fputs(config->csv_sep, os->fh);
return;
}
- for (i = 0; i < os->nfields; i++)
+ for (i = 0; i < os->csv_col_pad; i++)
fputs(config->csv_sep, os->fh);
fprintf(config->output, "%s", metricgroup_name);
new_line_csv(config, ctx);
@@ -837,7 +851,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
pm = config->metric_only ? print_metric_only_csv : print_metric_csv;
nl = config->metric_only ? NULL : new_line_csv;
pmh = print_metricgroup_header_csv;
- os->nfields = 4 + (counter->cgrp ? 1 : 0);
+ os->csv_col_pad = 4 + (counter->cgrp ? 1 : 0);
} else if (config->json_output) {
pm = config->metric_only ? print_metric_only_json : print_metric_json;
nl = config->metric_only ? NULL : new_line_json;
--
2.34.1
Powered by blists - more mailing lists