Commit c7551a2e authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf list: Support for printing metric thresholds

Add to json output by default. For regular output, only enable with
the --detail flag.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Florian Fischer <florian.fischer@muhq.space>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Link: https://lore.kernel.org/r/20230219092848.639226-36-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 62e10d93
...@@ -168,6 +168,7 @@ static void default_print_metric(void *ps, ...@@ -168,6 +168,7 @@ static void default_print_metric(void *ps,
const char *desc, const char *desc,
const char *long_desc, const char *long_desc,
const char *expr, const char *expr,
const char *threshold,
const char *unit __maybe_unused) const char *unit __maybe_unused)
{ {
struct print_state *print_state = ps; struct print_state *print_state = ps;
...@@ -227,6 +228,11 @@ static void default_print_metric(void *ps, ...@@ -227,6 +228,11 @@ static void default_print_metric(void *ps,
wordwrap(expr, 8, pager_get_columns(), 0); wordwrap(expr, 8, pager_get_columns(), 0);
printf("]\n"); printf("]\n");
} }
if (threshold && print_state->detailed) {
printf("%*s", 8, "[");
wordwrap(threshold, 8, pager_get_columns(), 0);
printf("]\n");
}
} }
struct json_print_state { struct json_print_state {
...@@ -367,7 +373,7 @@ static void json_print_event(void *ps, const char *pmu_name, const char *topic, ...@@ -367,7 +373,7 @@ static void json_print_event(void *ps, const char *pmu_name, const char *topic,
static void json_print_metric(void *ps __maybe_unused, const char *group, static void json_print_metric(void *ps __maybe_unused, const char *group,
const char *name, const char *desc, const char *name, const char *desc,
const char *long_desc, const char *expr, const char *long_desc, const char *expr,
const char *unit) const char *threshold, const char *unit)
{ {
struct json_print_state *print_state = ps; struct json_print_state *print_state = ps;
bool need_sep = false; bool need_sep = false;
...@@ -388,6 +394,11 @@ static void json_print_metric(void *ps __maybe_unused, const char *group, ...@@ -388,6 +394,11 @@ static void json_print_metric(void *ps __maybe_unused, const char *group,
fix_escape_printf(&buf, "%s\t\"MetricExpr\": \"%S\"", need_sep ? ",\n" : "", expr); fix_escape_printf(&buf, "%s\t\"MetricExpr\": \"%S\"", need_sep ? ",\n" : "", expr);
need_sep = true; need_sep = true;
} }
if (threshold) {
fix_escape_printf(&buf, "%s\t\"MetricThreshold\": \"%S\"", need_sep ? ",\n" : "",
threshold);
need_sep = true;
}
if (unit) { if (unit) {
fix_escape_printf(&buf, "%s\t\"ScaleUnit\": \"%S\"", need_sep ? ",\n" : "", unit); fix_escape_printf(&buf, "%s\t\"ScaleUnit\": \"%S\"", need_sep ? ",\n" : "", unit);
need_sep = true; need_sep = true;
......
...@@ -368,6 +368,7 @@ struct mep { ...@@ -368,6 +368,7 @@ struct mep {
const char *metric_desc; const char *metric_desc;
const char *metric_long_desc; const char *metric_long_desc;
const char *metric_expr; const char *metric_expr;
const char *metric_threshold;
const char *metric_unit; const char *metric_unit;
}; };
...@@ -447,6 +448,7 @@ static int metricgroup__add_to_mep_groups(const struct pmu_metric *pm, ...@@ -447,6 +448,7 @@ static int metricgroup__add_to_mep_groups(const struct pmu_metric *pm,
me->metric_desc = pm->desc; me->metric_desc = pm->desc;
me->metric_long_desc = pm->long_desc; me->metric_long_desc = pm->long_desc;
me->metric_expr = pm->metric_expr; me->metric_expr = pm->metric_expr;
me->metric_threshold = pm->metric_threshold;
me->metric_unit = pm->unit; me->metric_unit = pm->unit;
} }
} }
...@@ -522,6 +524,7 @@ void metricgroup__print(const struct print_callbacks *print_cb, void *print_stat ...@@ -522,6 +524,7 @@ void metricgroup__print(const struct print_callbacks *print_cb, void *print_stat
me->metric_desc, me->metric_desc,
me->metric_long_desc, me->metric_long_desc,
me->metric_expr, me->metric_expr,
me->metric_threshold,
me->metric_unit); me->metric_unit);
next = rb_next(node); next = rb_next(node);
rblist__remove_node(&groups, node); rblist__remove_node(&groups, node);
......
...@@ -23,6 +23,7 @@ struct print_callbacks { ...@@ -23,6 +23,7 @@ struct print_callbacks {
const char *desc, const char *desc,
const char *long_desc, const char *long_desc,
const char *expr, const char *expr,
const char *threshold,
const char *unit); const char *unit);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment