mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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: Ian 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.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
62e10d937d
commit
c7551a2e33
3 changed files with 16 additions and 1 deletions
|
@ -168,6 +168,7 @@ static void default_print_metric(void *ps,
|
|||
const char *desc,
|
||||
const char *long_desc,
|
||||
const char *expr,
|
||||
const char *threshold,
|
||||
const char *unit __maybe_unused)
|
||||
{
|
||||
struct print_state *print_state = ps;
|
||||
|
@ -227,6 +228,11 @@ static void default_print_metric(void *ps,
|
|||
wordwrap(expr, 8, pager_get_columns(), 0);
|
||||
printf("]\n");
|
||||
}
|
||||
if (threshold && print_state->detailed) {
|
||||
printf("%*s", 8, "[");
|
||||
wordwrap(threshold, 8, pager_get_columns(), 0);
|
||||
printf("]\n");
|
||||
}
|
||||
}
|
||||
|
||||
struct json_print_state {
|
||||
|
@ -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,
|
||||
const char *name, const char *desc,
|
||||
const char *long_desc, const char *expr,
|
||||
const char *unit)
|
||||
const char *threshold, const char *unit)
|
||||
{
|
||||
struct json_print_state *print_state = ps;
|
||||
bool need_sep = false;
|
||||
|
@ -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);
|
||||
need_sep = true;
|
||||
}
|
||||
if (threshold) {
|
||||
fix_escape_printf(&buf, "%s\t\"MetricThreshold\": \"%S\"", need_sep ? ",\n" : "",
|
||||
threshold);
|
||||
need_sep = true;
|
||||
}
|
||||
if (unit) {
|
||||
fix_escape_printf(&buf, "%s\t\"ScaleUnit\": \"%S\"", need_sep ? ",\n" : "", unit);
|
||||
need_sep = true;
|
||||
|
|
|
@ -368,6 +368,7 @@ struct mep {
|
|||
const char *metric_desc;
|
||||
const char *metric_long_desc;
|
||||
const char *metric_expr;
|
||||
const char *metric_threshold;
|
||||
const char *metric_unit;
|
||||
};
|
||||
|
||||
|
@ -447,6 +448,7 @@ static int metricgroup__add_to_mep_groups(const struct pmu_metric *pm,
|
|||
me->metric_desc = pm->desc;
|
||||
me->metric_long_desc = pm->long_desc;
|
||||
me->metric_expr = pm->metric_expr;
|
||||
me->metric_threshold = pm->metric_threshold;
|
||||
me->metric_unit = pm->unit;
|
||||
}
|
||||
}
|
||||
|
@ -522,6 +524,7 @@ void metricgroup__print(const struct print_callbacks *print_cb, void *print_stat
|
|||
me->metric_desc,
|
||||
me->metric_long_desc,
|
||||
me->metric_expr,
|
||||
me->metric_threshold,
|
||||
me->metric_unit);
|
||||
next = rb_next(node);
|
||||
rblist__remove_node(&groups, node);
|
||||
|
|
|
@ -23,6 +23,7 @@ struct print_callbacks {
|
|||
const char *desc,
|
||||
const char *long_desc,
|
||||
const char *expr,
|
||||
const char *threshold,
|
||||
const char *unit);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue