]> Git Repo - linux.git/commitdiff
perf list: Display hybrid PMU events with cpu type
authorJin Yao <[email protected]>
Fri, 3 Sep 2021 02:52:39 +0000 (10:52 +0800)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 25 Oct 2021 16:47:42 +0000 (13:47 -0300)
Add a new option '--cputype' to 'perf list' to display core-only PMU
events or atom-only PMU events.

Each hybrid PMU event has been assigned with a PMU name, this patch
compares the PMU name before listing the result.

For example:

  perf list --cputype atom
  ...
  cache:
    core_reject_l2q.any
         [Counts the number of request that were not accepted into the L2Q because the L2Q is FULL. Unit: cpu_atom]
  ...

The "Unit: cpu_atom" is displayed in the brief description section
to indicate this is an atom event.

Signed-off-by: Jin Yao <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/Documentation/perf-list.txt
tools/perf/builtin-list.c
tools/perf/util/metricgroup.c
tools/perf/util/metricgroup.h
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h
tools/perf/util/pmu.c
tools/perf/util/pmu.h

index 4c7db1da8fccc29364a54b43542bed50d05bda0a..4dc8d0af19df585527f870869715143c26849458 100644 (file)
@@ -39,6 +39,10 @@ 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)
+
 [[EVENT_MODIFIERS]]
 EVENT MODIFIERS
 ---------------
index 10ab5e40a34f8071e28037e0bec57a3cd79cd9c4..468958154ed900da80a64eb5aba7d043316ff8ae 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "util/parse-events.h"
 #include "util/pmu.h"
+#include "util/pmu-hybrid.h"
 #include "util/debug.h"
 #include "util/metricgroup.h"
 #include <subcmd/pager.h>
 
 static bool desc_flag = true;
 static bool details_flag;
+static const char *hybrid_type;
 
 int cmd_list(int argc, const char **argv)
 {
-       int i;
+       int i, ret = 0;
        bool raw_dump = false;
        bool long_desc_flag = false;
        bool deprecated = false;
+       char *pmu_name = NULL;
        struct option list_options[] = {
                OPT_BOOLEAN(0, "raw-dump", &raw_dump, "Dump raw events"),
                OPT_BOOLEAN('d', "desc", &desc_flag,
@@ -37,6 +40,9 @@ 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_INCR(0, "debug", &verbose,
                             "Enable debugging output"),
                OPT_END()
@@ -56,10 +62,16 @@ 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):\n\n");
 
+       if (hybrid_type) {
+               pmu_name = perf_pmu__hybrid_type_to_pmu(hybrid_type);
+               if (!pmu_name)
+                       pr_warning("WARNING: hybrid cputype is not supported!\n");
+       }
+
        if (argc == 0) {
                print_events(NULL, raw_dump, !desc_flag, long_desc_flag,
-                               details_flag, deprecated);
-               return 0;
+                               details_flag, deprecated, pmu_name);
+               goto out;
        }
 
        for (i = 0; i < argc; ++i) {
@@ -82,25 +94,27 @@ int cmd_list(int argc, const char **argv)
                else if (strcmp(argv[i], "pmu") == 0)
                        print_pmu_events(NULL, raw_dump, !desc_flag,
                                                long_desc_flag, details_flag,
-                                               deprecated);
+                                               deprecated, pmu_name);
                else if (strcmp(argv[i], "sdt") == 0)
                        print_sdt_events(NULL, NULL, raw_dump);
                else if (strcmp(argv[i], "metric") == 0 || strcmp(argv[i], "metrics") == 0)
-                       metricgroup__print(true, false, NULL, raw_dump, details_flag);
+                       metricgroup__print(true, false, NULL, raw_dump, details_flag, pmu_name);
                else if (strcmp(argv[i], "metricgroup") == 0 || strcmp(argv[i], "metricgroups") == 0)
-                       metricgroup__print(false, true, NULL, raw_dump, details_flag);
+                       metricgroup__print(false, true, NULL, raw_dump, details_flag, pmu_name);
                else if ((sep = strchr(argv[i], ':')) != NULL) {
                        int sep_idx;
 
                        sep_idx = sep - argv[i];
                        s = strdup(argv[i]);
-                       if (s == NULL)
-                               return -1;
+                       if (s == NULL) {
+                               ret = -1;
+                               goto out;
+                       }
 
                        s[sep_idx] = '\0';
                        print_tracepoint_events(s, s + sep_idx + 1, raw_dump);
                        print_sdt_events(s, s + sep_idx + 1, raw_dump);
-                       metricgroup__print(true, true, s, raw_dump, details_flag);
+                       metricgroup__print(true, true, s, raw_dump, details_flag, pmu_name);
                        free(s);
                } else {
                        if (asprintf(&s, "*%s*", argv[i]) < 0) {
@@ -116,12 +130,16 @@ int cmd_list(int argc, const char **argv)
                        print_pmu_events(s, raw_dump, !desc_flag,
                                                long_desc_flag,
                                                details_flag,
-                                               deprecated);
+                                               deprecated,
+                                               pmu_name);
                        print_tracepoint_events(NULL, s, raw_dump);
                        print_sdt_events(NULL, s, raw_dump);
-                       metricgroup__print(true, true, s, raw_dump, details_flag);
+                       metricgroup__print(true, true, s, raw_dump, details_flag, pmu_name);
                        free(s);
                }
        }
-       return 0;
+
+out:
+       free(pmu_name);
+       return ret;
 }
index c34a3683e71990458b676d91ba433b2f7bbb68c5..4917e97047650dc99ffa80468a4ec1e3280a8bf9 100644 (file)
@@ -11,6 +11,7 @@
 #include "evsel.h"
 #include "strbuf.h"
 #include "pmu.h"
+#include "pmu-hybrid.h"
 #include "expr.h"
 #include "rblist.h"
 #include <string.h>
@@ -535,7 +536,7 @@ static int metricgroup__print_sys_event_iter(const struct pmu_event *pe, void *d
 }
 
 void metricgroup__print(bool metrics, bool metricgroups, char *filter,
-                       bool raw, bool details)
+                       bool raw, bool details, const char *pmu_name)
 {
        const struct pmu_events_map *map = pmu_events_map__find();
        const struct pmu_event *pe;
@@ -561,6 +562,10 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
                        break;
                if (!pe->metric_expr)
                        continue;
+               if (pmu_name && perf_pmu__is_hybrid(pe->pmu) &&
+                   strcmp(pmu_name, pe->pmu)) {
+                       continue;
+               }
                if (metricgroup__print_pmu_event(pe, metricgroups, filter,
                                                 raw, details, &groups,
                                                 metriclist) < 0)
index 3a51a84f440b171f6fab4d53640265b667e054e5..2b42b778d1bfeb22efe67a9043d242e8187dfc3a 100644 (file)
@@ -80,7 +80,7 @@ int metricgroup__parse_groups_test(struct evlist *evlist,
                                   struct rblist *metric_events);
 
 void metricgroup__print(bool metrics, bool groups, char *filter,
-                       bool raw, bool details);
+                       bool raw, bool details, const char *pmu_name);
 bool metricgroup__has_metric(const char *metric);
 int arch_get_runtimeparam(const struct pmu_event *pe __maybe_unused);
 void metricgroup__rblist_exit(struct rblist *metric_events);
index 006a7f72154915a5daeba1685bcc05b0f40a0c9d..278199ed788b9a23e1c7bf9654e5c43b103191a4 100644 (file)
@@ -3089,7 +3089,8 @@ out_enomem:
  * Print the help text for the event symbols:
  */
 void print_events(const char *event_glob, bool name_only, bool quiet_flag,
-                       bool long_desc, bool details_flag, bool deprecated)
+                       bool long_desc, bool details_flag, bool deprecated,
+                       const char *pmu_name)
 {
        print_symbol_events(event_glob, PERF_TYPE_HARDWARE,
                            event_symbols_hw, PERF_COUNT_HW_MAX, name_only);
@@ -3101,7 +3102,7 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
        print_hwcache_events(event_glob, name_only);
 
        print_pmu_events(event_glob, name_only, quiet_flag, long_desc,
-                       details_flag, deprecated);
+                       details_flag, deprecated, pmu_name);
 
        if (event_glob != NULL)
                return;
@@ -3127,7 +3128,8 @@ void print_events(const char *event_glob, bool name_only, bool quiet_flag,
 
        print_sdt_events(NULL, NULL, name_only);
 
-       metricgroup__print(true, true, NULL, name_only, details_flag);
+       metricgroup__print(true, true, NULL, name_only, details_flag,
+                          pmu_name);
 
        print_libpfm_events(name_only, long_desc);
 }
index 07f879e525fe14bdac4ea2b65fcce97ffb0c757d..f60a661a224701efa26df6093940092c563c87b9 100644 (file)
@@ -221,7 +221,8 @@ void parse_events_evlist_error(struct parse_events_state *parse_state,
                               int idx, const char *str);
 
 void print_events(const char *event_glob, bool name_only, bool quiet,
-                 bool long_desc, bool details_flag, bool deprecated);
+                 bool long_desc, bool details_flag, bool deprecated,
+                 const char *pmu_name);
 
 struct event_symbol {
        const char      *symbol;
index 9b5039bf909a99a4ff42602421ad3bd4463c79cd..f3072c71d132f888a70526c8fb404e63fb50a322 100644 (file)
@@ -1608,6 +1608,7 @@ static int cmp_sevent(const void *a, const void *b)
 {
        const struct sevent *as = a;
        const struct sevent *bs = b;
+       int ret;
 
        /* Put extra events last */
        if (!!as->desc != !!bs->desc)
@@ -1623,7 +1624,13 @@ static int cmp_sevent(const void *a, const void *b)
        if (as->is_cpu != bs->is_cpu)
                return bs->is_cpu - as->is_cpu;
 
-       return strcmp(as->name, bs->name);
+       ret = strcmp(as->name, bs->name);
+       if (!ret) {
+               if (as->pmu && bs->pmu)
+                       return strcmp(as->pmu, bs->pmu);
+       }
+
+       return ret;
 }
 
 static void wordwrap(char *s, int start, int max, int corr)
@@ -1653,7 +1660,8 @@ bool is_pmu_core(const char *name)
 }
 
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
-                       bool long_desc, bool details_flag, bool deprecated)
+                       bool long_desc, bool details_flag, bool deprecated,
+                       const char *pmu_name)
 {
        struct perf_pmu *pmu;
        struct perf_pmu_alias *alias;
@@ -1679,10 +1687,16 @@ 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)) {
+                       continue;
+               }
+
                list_for_each_entry(alias, &pmu->aliases, list) {
                        char *name = alias->desc ? alias->name :
                                format_alias(buf, sizeof(buf), pmu, alias);
-                       bool is_cpu = is_pmu_core(pmu->name);
+                       bool is_cpu = is_pmu_core(pmu->name) ||
+                                     perf_pmu__is_hybrid(pmu->name);
 
                        if (alias->deprecated && !deprecated)
                                continue;
@@ -1730,8 +1744,13 @@ void print_pmu_events(const char *event_glob, bool name_only, bool quiet_flag,
        qsort(aliases, len, sizeof(struct sevent), cmp_sevent);
        for (j = 0; j < len; j++) {
                /* Skip duplicates */
-               if (j > 0 && !strcmp(aliases[j].name, aliases[j - 1].name))
-                       continue;
+               if (j > 0 && !strcmp(aliases[j].name, aliases[j - 1].name)) {
+                       if (!aliases[j].pmu || !aliases[j - 1].pmu ||
+                           !strcmp(aliases[j].pmu, aliases[j - 1].pmu)) {
+                               continue;
+                       }
+               }
+
                if (name_only) {
                        printf("%s ", aliases[j].name);
                        continue;
index f9743eab07b6e46142704add6c032fec0e73803c..15bbec3a9959d9feb9a0f2f32906282e2b4ea1a3 100644 (file)
@@ -111,7 +111,7 @@ struct perf_pmu *perf_pmu__scan(struct perf_pmu *pmu);
 bool is_pmu_core(const char *name);
 void print_pmu_events(const char *event_glob, bool name_only, bool quiet,
                      bool long_desc, bool details_flag,
-                     bool deprecated);
+                     bool deprecated, const char *pmu_name);
 bool pmu_have_event(const char *pname, const char *name);
 
 int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt, ...) __scanf(3, 4);
This page took 0.07567 seconds and 4 git commands to generate.