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

perf list: Generalize limiting to a PMU name

Deprecate the --cputype option and add a --unit option where '--unit
cpu_atom' behaves like '--cputype atom'. The --unit option can be used
with arbitrary PMUs, for example:

```
$ perf list --unit msr pmu

List of pre-defined events (to be used in -e or -M):

  msr/aperf/                                         [Kernel PMU event]
  msr/cpu_thermal_margin/                            [Kernel PMU event]
  msr/mperf/                                         [Kernel PMU event]
  msr/pperf/                                         [Kernel PMU event]
  msr/smi/                                           [Kernel PMU event]
  msr/tsc/                                           [Kernel PMU event]
```
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: Caleb Biggers <caleb.biggers@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
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: 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: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xin Gao <gaoxin@cdjrlc.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: http://lore.kernel.org/lkml/20221114210723.2749751-6-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d74060c0
......@@ -39,9 +39,9 @@ any extra expressions computed by perf stat.
--deprecated::
Print deprecated events. By default the deprecated events are hidden.
--cputype::
Print events applying cpu with this type for hybrid platform
(e.g. --cputype core or --cputype atom)
--unit::
Print PMU events and metrics limited to the specific PMU name.
(e.g. --unit cpu, --unit msr, --unit cpu_core, --unit cpu_atom)
[[EVENT_MODIFIERS]]
EVENT MODIFIERS
......
......@@ -21,7 +21,6 @@
static bool desc_flag = true;
static bool details_flag;
static const char *hybrid_type;
int cmd_list(int argc, const char **argv)
{
......@@ -30,6 +29,8 @@ int cmd_list(int argc, const char **argv)
bool long_desc_flag = false;
bool deprecated = false;
char *pmu_name = NULL;
const char *hybrid_name = NULL;
const char *unit_name = NULL;
struct option list_options[] = {
OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
OPT_BOOLEAN('d', "desc", &desc_flag,
......@@ -40,9 +41,10 @@ int cmd_list(int argc, const char **argv)
"Print information on the perf event names and expressions used internally by events."),
OPT_BOOLEAN(0, "deprecated", &deprecated,
"Print deprecated events."),
OPT_STRING(0, "cputype", &hybrid_type, "hybrid cpu type",
"Print events applying cpu with this type for hybrid platform "
"(e.g. core or atom)"),
OPT_STRING(0, "cputype", &hybrid_name, "hybrid cpu type",
"Limit PMU or metric printing to the given hybrid PMU (e.g. core or atom)."),
OPT_STRING(0, "unit", &unit_name, "PMU name",
"Limit PMU or metric printing to the specified PMU."),
OPT_INCR(0, "debug", &verbose,
"Enable debugging output"),
OPT_END()
......@@ -53,6 +55,8 @@ int cmd_list(int argc, const char **argv)
};
set_option_flag(list_options, 0, "raw-dump", PARSE_OPT_HIDDEN);
/* Hide hybrid flag for the more generic 'unit' flag. */
set_option_flag(list_options, 0, "cputype", PARSE_OPT_HIDDEN);
argc = parse_options(argc, argv, list_options, list_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
......@@ -62,8 +66,10 @@ int cmd_list(int argc, const char **argv)
if (!raw_dump && pager_in_use())
printf("\nList of pre-defined events (to be used in -e or -M):\n\n");
if (hybrid_type) {
pmu_name = perf_pmu__hybrid_type_to_pmu(hybrid_type);
if (unit_name)
pmu_name = strdup(unit_name);
else if (hybrid_name) {
pmu_name = perf_pmu__hybrid_type_to_pmu(hybrid_name);
if (!pmu_name)
pr_warning("WARNING: hybrid cputype is not supported!\n");
}
......
......@@ -556,11 +556,12 @@ static int metricgroup__print_callback(const struct pmu_event *pe,
void *vdata)
{
struct metricgroup_print_data *data = vdata;
const char *pmu = pe->pmu ?: "cpu";
if (!pe->metric_expr)
return 0;
if (data->pmu_name && perf_pmu__is_hybrid(pe->pmu) && strcmp(data->pmu_name, pe->pmu))
if (data->pmu_name && strcmp(data->pmu_name, pmu))
return 0;
return metricgroup__print_pmu_event(pe, data->metricgroups, data->filter,
......
......@@ -1695,10 +1695,8 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
pmu = NULL;
j = 0;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (pmu_name && perf_pmu__is_hybrid(pmu->name) &&
strcmp(pmu_name, pmu->name)) {
if (pmu_name && pmu->name && strcmp(pmu_name, pmu->name))
continue;
}
list_for_each_entry(alias, &pmu->aliases, list) {
char *name = alias->desc ? alias->name :
......
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