~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/arch/x86/util/evlist.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <stdio.h>
  3 #include "util/pmu.h"
  4 #include "util/pmus.h"
  5 #include "util/evlist.h"
  6 #include "util/parse-events.h"
  7 #include "util/event.h"
  8 #include "topdown.h"
  9 #include "evsel.h"
 10 
 11 static int ___evlist__add_default_attrs(struct evlist *evlist,
 12                                         struct perf_event_attr *attrs,
 13                                         size_t nr_attrs)
 14 {
 15         LIST_HEAD(head);
 16         size_t i = 0;
 17 
 18         for (i = 0; i < nr_attrs; i++)
 19                 event_attr_init(attrs + i);
 20 
 21         if (perf_pmus__num_core_pmus() == 1)
 22                 return evlist__add_attrs(evlist, attrs, nr_attrs);
 23 
 24         for (i = 0; i < nr_attrs; i++) {
 25                 struct perf_pmu *pmu = NULL;
 26 
 27                 if (attrs[i].type == PERF_TYPE_SOFTWARE) {
 28                         struct evsel *evsel = evsel__new(attrs + i);
 29 
 30                         if (evsel == NULL)
 31                                 goto out_delete_partial_list;
 32                         list_add_tail(&evsel->core.node, &head);
 33                         continue;
 34                 }
 35 
 36                 while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
 37                         struct perf_cpu_map *cpus;
 38                         struct evsel *evsel;
 39 
 40                         evsel = evsel__new(attrs + i);
 41                         if (evsel == NULL)
 42                                 goto out_delete_partial_list;
 43                         evsel->core.attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT;
 44                         cpus = perf_cpu_map__get(pmu->cpus);
 45                         evsel->core.cpus = cpus;
 46                         evsel->core.own_cpus = perf_cpu_map__get(cpus);
 47                         evsel->pmu_name = strdup(pmu->name);
 48                         list_add_tail(&evsel->core.node, &head);
 49                 }
 50         }
 51 
 52         evlist__splice_list_tail(evlist, &head);
 53 
 54         return 0;
 55 
 56 out_delete_partial_list:
 57         {
 58                 struct evsel *evsel, *n;
 59 
 60                 __evlist__for_each_entry_safe(&head, n, evsel)
 61                         evsel__delete(evsel);
 62         }
 63         return -1;
 64 }
 65 
 66 int arch_evlist__add_default_attrs(struct evlist *evlist,
 67                                    struct perf_event_attr *attrs,
 68                                    size_t nr_attrs)
 69 {
 70         if (!nr_attrs)
 71                 return 0;
 72 
 73         return ___evlist__add_default_attrs(evlist, attrs, nr_attrs);
 74 }
 75 
 76 int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
 77 {
 78         if (topdown_sys_has_perf_metrics() &&
 79             (arch_evsel__must_be_in_group(lhs) || arch_evsel__must_be_in_group(rhs))) {
 80                 /* Ensure the topdown slots comes first. */
 81                 if (strcasestr(lhs->name, "slots") && !strcasestr(lhs->name, "uops_retired.slots"))
 82                         return -1;
 83                 if (strcasestr(rhs->name, "slots") && !strcasestr(rhs->name, "uops_retired.slots"))
 84                         return 1;
 85                 /* Followed by topdown events. */
 86                 if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown"))
 87                         return -1;
 88                 if (!strcasestr(lhs->name, "topdown") && strcasestr(rhs->name, "topdown"))
 89                         return 1;
 90         }
 91 
 92         /* Default ordering by insertion index. */
 93         return lhs->core.idx - rhs->core.idx;
 94 }
 95 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php