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

perf mem: Avoid hybrid PMU list

Add perf_pmu__num_mem_pmus that scans/counts the number of PMUs for
mem events. Switch perf_pmu__for_each_hybrid_pmu to iterating all PMUs
and only handling is_core ones.
Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
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: 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-24-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3d88055f
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
#include "ui/ui.h" #include "ui/ui.h"
#include "ui/progress.h" #include "ui/progress.h"
#include "pmu.h" #include "pmu.h"
#include "pmu-hybrid.h"
#include "string2.h" #include "string2.h"
#include "util/util.h" #include "util/util.h"
...@@ -3259,10 +3258,8 @@ static int perf_c2c__record(int argc, const char **argv) ...@@ -3259,10 +3258,8 @@ static int perf_c2c__record(int argc, const char **argv)
argc = parse_options(argc, argv, options, record_mem_usage, argc = parse_options(argc, argv, options, record_mem_usage,
PARSE_OPT_KEEP_UNKNOWN); PARSE_OPT_KEEP_UNKNOWN);
if (!perf_pmu__has_hybrid()) /* Max number of arguments multiplied by number of PMUs that can support them. */
rec_argc = argc + 11; /* max number of arguments */ rec_argc = argc + 11 * perf_pmu__num_mem_pmus();
else
rec_argc = argc + 11 * perf_pmu__hybrid_pmu_num();
rec_argv = calloc(rec_argc + 1, sizeof(char *)); rec_argv = calloc(rec_argc + 1, sizeof(char *));
if (!rec_argv) if (!rec_argv)
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "util/map.h" #include "util/map.h"
#include "util/symbol.h" #include "util/symbol.h"
#include "util/pmu.h" #include "util/pmu.h"
#include "util/pmu-hybrid.h"
#include "util/sample.h" #include "util/sample.h"
#include "util/string2.h" #include "util/string2.h"
#include "util/util.h" #include "util/util.h"
...@@ -93,10 +92,8 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem) ...@@ -93,10 +92,8 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
argc = parse_options(argc, argv, options, record_mem_usage, argc = parse_options(argc, argv, options, record_mem_usage,
PARSE_OPT_KEEP_UNKNOWN); PARSE_OPT_KEEP_UNKNOWN);
if (!perf_pmu__has_hybrid()) /* Max number of arguments multiplied by number of PMUs that can support them. */
rec_argc = argc + 9; /* max number of arguments */ rec_argc = argc + 9 * perf_pmu__num_mem_pmus();
else
rec_argc = argc + 9 * perf_pmu__hybrid_pmu_num();
if (mem->cpu_list) if (mem->cpu_list)
rec_argc += 2; rec_argc += 2;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "debug.h" #include "debug.h"
#include "symbol.h" #include "symbol.h"
#include "pmu.h" #include "pmu.h"
#include "pmu-hybrid.h"
unsigned int perf_mem_events__loads_ldlat = 30; unsigned int perf_mem_events__loads_ldlat = 30;
...@@ -120,7 +119,6 @@ int perf_mem_events__init(void) ...@@ -120,7 +119,6 @@ int perf_mem_events__init(void)
for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) { for (j = 0; j < PERF_MEM_EVENTS__MAX; j++) {
struct perf_mem_event *e = perf_mem_events__ptr(j); struct perf_mem_event *e = perf_mem_events__ptr(j);
struct perf_pmu *pmu;
char sysfs_name[100]; char sysfs_name[100];
/* /*
...@@ -135,7 +133,12 @@ int perf_mem_events__init(void) ...@@ -135,7 +133,12 @@ int perf_mem_events__init(void)
e->sysfs_name, "cpu"); e->sysfs_name, "cpu");
e->supported = perf_mem_event__supported(mnt, sysfs_name); e->supported = perf_mem_event__supported(mnt, sysfs_name);
} else { } else {
perf_pmu__for_each_hybrid_pmu(pmu) { struct perf_pmu *pmu = NULL;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (!pmu->is_core)
continue;
scnprintf(sysfs_name, sizeof(sysfs_name), scnprintf(sysfs_name, sizeof(sysfs_name),
e->sysfs_name, pmu->name); e->sysfs_name, pmu->name);
e->supported |= perf_mem_event__supported(mnt, sysfs_name); e->supported |= perf_mem_event__supported(mnt, sysfs_name);
...@@ -170,9 +173,12 @@ static void perf_mem_events__print_unsupport_hybrid(struct perf_mem_event *e, ...@@ -170,9 +173,12 @@ static void perf_mem_events__print_unsupport_hybrid(struct perf_mem_event *e,
{ {
const char *mnt = sysfs__mount(); const char *mnt = sysfs__mount();
char sysfs_name[100]; char sysfs_name[100];
struct perf_pmu *pmu; struct perf_pmu *pmu = NULL;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (!pmu->is_core)
continue;
perf_pmu__for_each_hybrid_pmu(pmu) {
scnprintf(sysfs_name, sizeof(sysfs_name), e->sysfs_name, scnprintf(sysfs_name, sizeof(sysfs_name), e->sysfs_name,
pmu->name); pmu->name);
if (!perf_mem_event__supported(mnt, sysfs_name)) { if (!perf_mem_event__supported(mnt, sysfs_name)) {
...@@ -210,7 +216,9 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr, ...@@ -210,7 +216,9 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr,
return -1; return -1;
} }
perf_pmu__for_each_hybrid_pmu(pmu) { while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (!pmu->is_core)
continue;
rec_argv[i++] = "-e"; rec_argv[i++] = "-e";
s = perf_mem_events__name(j, pmu->name); s = perf_mem_events__name(j, pmu->name);
if (s) { if (s) {
......
...@@ -1660,6 +1660,23 @@ bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu) ...@@ -1660,6 +1660,23 @@ bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu)
return !is_pmu_hybrid(pmu->name); return !is_pmu_hybrid(pmu->name);
} }
static bool perf_pmu__is_mem_pmu(const struct perf_pmu *pmu)
{
return pmu->is_core;
}
int perf_pmu__num_mem_pmus(void)
{
struct perf_pmu *pmu = NULL;
int count = 0;
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
if (perf_pmu__is_mem_pmu(pmu))
count++;
}
return count;
}
static bool pmu_alias_is_duplicate(struct sevent *alias_a, static bool pmu_alias_is_duplicate(struct sevent *alias_a,
struct sevent *alias_b) struct sevent *alias_b)
{ {
......
...@@ -231,6 +231,7 @@ bool is_pmu_hybrid(const char *name); ...@@ -231,6 +231,7 @@ bool is_pmu_hybrid(const char *name);
bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu); bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu);
bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu); bool perf_pmu__supports_wildcard_numeric(const struct perf_pmu *pmu);
bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu); bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu);
int perf_pmu__num_mem_pmus(void);
void print_pmu_events(const struct print_callbacks *print_cb, void *print_state); void print_pmu_events(const struct print_callbacks *print_cb, void *print_state);
bool pmu_have_event(const char *pname, const char *name); bool pmu_have_event(const char *pname, const char *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