]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf stat: Remove "unit" workarounds for metric-only
authorIan Rogers <irogers@google.com>
Tue, 11 Nov 2025 21:21:58 +0000 (13:21 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 12 Nov 2025 00:48:35 +0000 (16:48 -0800)
Remove code that tested the "unit" as in KB/sec for certain hard coded
metric values and did workarounds.

Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/stat-display.c

index eabeab5e661459ca159a1c596985bc9f1bbe85b0..b3596f9f5cdd81f50bc4860d075f35bd369c0e68 100644 (file)
@@ -592,42 +592,18 @@ static void print_metricgroup_header_std(struct perf_stat_config *config,
        fprintf(config->output, "%*s", MGROUP_LEN - n - 1, "");
 }
 
-/* Filter out some columns that don't work well in metrics only mode */
-
-static bool valid_only_metric(const char *unit)
-{
-       if (!unit)
-               return false;
-       if (strstr(unit, "/sec") ||
-           strstr(unit, "CPUs utilized"))
-               return false;
-       return true;
-}
-
-static const char *fixunit(char *buf, struct evsel *evsel,
-                          const char *unit)
-{
-       if (!strncmp(unit, "of all", 6)) {
-               snprintf(buf, 1024, "%s %s", evsel__name(evsel),
-                        unit);
-               return buf;
-       }
-       return unit;
-}
-
 static void print_metric_only(struct perf_stat_config *config,
                              void *ctx, enum metric_threshold_classify thresh,
                              const char *fmt, const char *unit, double val)
 {
        struct outstate *os = ctx;
        FILE *out = os->fh;
-       char buf[1024], str[1024];
+       char str[1024];
        unsigned mlen = config->metric_only_len;
        const char *color = metric_threshold_classify__color(thresh);
 
-       if (!valid_only_metric(unit))
-               return;
-       unit = fixunit(buf, os->evsel, unit);
+       if (!unit)
+               unit = "";
        if (mlen < strlen(unit))
                mlen = strlen(unit) + 1;
 
@@ -643,16 +619,15 @@ static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused
                                  void *ctx,
                                  enum metric_threshold_classify thresh __maybe_unused,
                                  const char *fmt,
-                                 const char *unit, double val)
+                                 const char *unit __maybe_unused, double val)
 {
        struct outstate *os = ctx;
        FILE *out = os->fh;
        char buf[64], *vals, *ends;
-       char tbuf[1024];
 
-       if (!valid_only_metric(unit))
+       if (!unit)
                return;
-       unit = fixunit(tbuf, os->evsel, unit);
+
        snprintf(buf, sizeof(buf), fmt ?: "", val);
        ends = vals = skip_spaces(buf);
        while (isdigit(*ends) || *ends == '.')
@@ -670,13 +645,9 @@ static void print_metric_only_json(struct perf_stat_config *config __maybe_unuse
 {
        struct outstate *os = ctx;
        char buf[64], *ends;
-       char tbuf[1024];
        const char *vals;
 
-       if (!valid_only_metric(unit))
-               return;
-       unit = fixunit(tbuf, os->evsel, unit);
-       if (!unit[0])
+       if (!unit || !unit[0])
                return;
        snprintf(buf, sizeof(buf), fmt ?: "", val);
        vals = ends = skip_spaces(buf);
@@ -695,7 +666,6 @@ static void print_metric_header(struct perf_stat_config *config,
                                const char *unit, double val __maybe_unused)
 {
        struct outstate *os = ctx;
-       char tbuf[1024];
 
        /* In case of iostat, print metric header for first root port only */
        if (config->iostat_run &&
@@ -705,9 +675,8 @@ static void print_metric_header(struct perf_stat_config *config,
        if (os->evsel->cgrp != os->cgrp)
                return;
 
-       if (!valid_only_metric(unit))
+       if (!unit)
                return;
-       unit = fixunit(tbuf, os->evsel, unit);
 
        if (config->json_output)
                return;