mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
perf_pmus__has_hybrid was used to detect when there was >1 core PMU, this can be achieved with perf_pmus__num_core_pmus that doesn't depend upon is_pmu_hybrid and PMU name comparisons. When modifying the function calls take the opportunity to improve comments, enable/simplify tests that were previously failing for hybrid but now pass and to simplify generic code. Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ali Saidi <alisaidi@amazon.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: Huacai Chen <chenhuacai@kernel.org> 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: Kang Minchul <tegongkang@gmail.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> 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: Sean Christopherson <seanjc@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230527072210.2900565-34-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
94 lines
2.3 KiB
C
94 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <stdio.h>
|
|
#include "util/pmu.h"
|
|
#include "util/pmus.h"
|
|
#include "util/evlist.h"
|
|
#include "util/parse-events.h"
|
|
#include "util/event.h"
|
|
#include "topdown.h"
|
|
#include "evsel.h"
|
|
|
|
static int ___evlist__add_default_attrs(struct evlist *evlist,
|
|
struct perf_event_attr *attrs,
|
|
size_t nr_attrs)
|
|
{
|
|
LIST_HEAD(head);
|
|
size_t i = 0;
|
|
|
|
for (i = 0; i < nr_attrs; i++)
|
|
event_attr_init(attrs + i);
|
|
|
|
if (perf_pmus__num_core_pmus() == 1)
|
|
return evlist__add_attrs(evlist, attrs, nr_attrs);
|
|
|
|
for (i = 0; i < nr_attrs; i++) {
|
|
struct perf_pmu *pmu = NULL;
|
|
|
|
if (attrs[i].type == PERF_TYPE_SOFTWARE) {
|
|
struct evsel *evsel = evsel__new(attrs + i);
|
|
|
|
if (evsel == NULL)
|
|
goto out_delete_partial_list;
|
|
list_add_tail(&evsel->core.node, &head);
|
|
continue;
|
|
}
|
|
|
|
while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
|
|
struct perf_cpu_map *cpus;
|
|
struct evsel *evsel;
|
|
|
|
evsel = evsel__new(attrs + i);
|
|
if (evsel == NULL)
|
|
goto out_delete_partial_list;
|
|
evsel->core.attr.config |= (__u64)pmu->type << PERF_PMU_TYPE_SHIFT;
|
|
cpus = perf_cpu_map__get(pmu->cpus);
|
|
evsel->core.cpus = cpus;
|
|
evsel->core.own_cpus = perf_cpu_map__get(cpus);
|
|
evsel->pmu_name = strdup(pmu->name);
|
|
list_add_tail(&evsel->core.node, &head);
|
|
}
|
|
}
|
|
|
|
evlist__splice_list_tail(evlist, &head);
|
|
|
|
return 0;
|
|
|
|
out_delete_partial_list:
|
|
{
|
|
struct evsel *evsel, *n;
|
|
|
|
__evlist__for_each_entry_safe(&head, n, evsel)
|
|
evsel__delete(evsel);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int arch_evlist__add_default_attrs(struct evlist *evlist,
|
|
struct perf_event_attr *attrs,
|
|
size_t nr_attrs)
|
|
{
|
|
if (!nr_attrs)
|
|
return 0;
|
|
|
|
return ___evlist__add_default_attrs(evlist, attrs, nr_attrs);
|
|
}
|
|
|
|
int arch_evlist__cmp(const struct evsel *lhs, const struct evsel *rhs)
|
|
{
|
|
if (topdown_sys_has_perf_metrics() && evsel__sys_has_perf_metrics(lhs)) {
|
|
/* Ensure the topdown slots comes first. */
|
|
if (strcasestr(lhs->name, "slots"))
|
|
return -1;
|
|
if (strcasestr(rhs->name, "slots"))
|
|
return 1;
|
|
/* Followed by topdown events. */
|
|
if (strcasestr(lhs->name, "topdown") && !strcasestr(rhs->name, "topdown"))
|
|
return -1;
|
|
if (!strcasestr(lhs->name, "topdown") && strcasestr(rhs->name, "topdown"))
|
|
return 1;
|
|
}
|
|
|
|
/* Default ordering by insertion index. */
|
|
return lhs->core.idx - rhs->core.idx;
|
|
}
|