perf mem: Add mem_events into the supported perf_pmu
With the mem_events, perf doesn't need to read sysfs for each PMU to find the mem-events-supported PMU. The patch also makes it possible to clean up the related __weak functions later. The patch is only to add the mem_events into the perf_pmu for all ARCHs. It will be used in the later cleanup patches. Reviewed-by: Ian Rogers <irogers@google.com> Reviewed-by: Kajol Jain <kjain@linux.ibm.com> Tested-by: Ravi Bangoria <ravi.bangoria@amd.com> Tested-by: Leo Yan <leo.yan@linaro.org> Tested-by: Kajol Jain <kjain@linux.ibm.com> Suggested-by: Leo Yan <leo.yan@linaro.org> Signed-off-by: Kan Liang <kan.liang@linux.intel.com> Cc: will@kernel.org Cc: mike.leach@linaro.org Cc: renyu.zj@linux.alibaba.com Cc: yuhaixin.yhx@linux.alibaba.com Cc: tmricht@linux.ibm.com Cc: atrajeev@linux.vnet.ibm.com Cc: linux-arm-kernel@lists.infradead.org Cc: john.g.garry@oracle.com Link: https://lore.kernel.org/r/20240123185036.3461837-2-kan.liang@linux.intel.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
68f87f24f9
commit
bb65acdc83
@ -13,6 +13,7 @@
|
|||||||
#include "hisi-ptt.h"
|
#include "hisi-ptt.h"
|
||||||
#include "../../../util/pmu.h"
|
#include "../../../util/pmu.h"
|
||||||
#include "../../../util/cs-etm.h"
|
#include "../../../util/cs-etm.h"
|
||||||
|
#include "../../arm64/util/mem-events.h"
|
||||||
|
|
||||||
void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
||||||
{
|
{
|
||||||
@ -26,6 +27,8 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
|||||||
pmu->selectable = true;
|
pmu->selectable = true;
|
||||||
pmu->is_uncore = false;
|
pmu->is_uncore = false;
|
||||||
pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
|
pmu->perf_event_attr_init_default = arm_spe_pmu_default_config;
|
||||||
|
if (!strcmp(pmu->name, "arm_spe_0"))
|
||||||
|
pmu->mem_events = perf_mem_events_arm;
|
||||||
} else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) {
|
} else if (strstarts(pmu->name, HISI_PTT_PMU_NAME)) {
|
||||||
pmu->selectable = true;
|
pmu->selectable = true;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "map_symbol.h"
|
#include "util/map_symbol.h"
|
||||||
|
#include "util/mem-events.h"
|
||||||
#include "mem-events.h"
|
#include "mem-events.h"
|
||||||
|
|
||||||
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
||||||
|
|
||||||
static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
|
struct perf_mem_event perf_mem_events_arm[PERF_MEM_EVENTS__MAX] = {
|
||||||
E("spe-load", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/", "arm_spe_0"),
|
E("spe-load", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/", "arm_spe_0"),
|
||||||
E("spe-store", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/", "arm_spe_0"),
|
E("spe-store", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/", "arm_spe_0"),
|
||||||
E("spe-ldst", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/", "arm_spe_0"),
|
E("spe-ldst", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/", "arm_spe_0"),
|
||||||
@ -17,7 +18,7 @@ struct perf_mem_event *perf_mem_events__ptr(int i)
|
|||||||
if (i >= PERF_MEM_EVENTS__MAX)
|
if (i >= PERF_MEM_EVENTS__MAX)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return &perf_mem_events[i];
|
return &perf_mem_events_arm[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *perf_mem_events__name(int i, const char *pmu_name __maybe_unused)
|
const char *perf_mem_events__name(int i, const char *pmu_name __maybe_unused)
|
||||||
|
7
tools/perf/arch/arm64/util/mem-events.h
Normal file
7
tools/perf/arch/arm64/util/mem-events.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _ARM64_MEM_EVENTS_H
|
||||||
|
#define _ARM64_MEM_EVENTS_H
|
||||||
|
|
||||||
|
extern struct perf_mem_event perf_mem_events_arm[PERF_MEM_EVENTS__MAX];
|
||||||
|
|
||||||
|
#endif /* _ARM64_MEM_EVENTS_H */
|
@ -16,13 +16,13 @@ static char mem_stores_name[100];
|
|||||||
|
|
||||||
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
||||||
|
|
||||||
static struct perf_mem_event perf_mem_events_intel[PERF_MEM_EVENTS__MAX] = {
|
struct perf_mem_event perf_mem_events_intel[PERF_MEM_EVENTS__MAX] = {
|
||||||
E("ldlat-loads", "%s/mem-loads,ldlat=%u/P", "%s/events/mem-loads"),
|
E("ldlat-loads", "%s/mem-loads,ldlat=%u/P", "%s/events/mem-loads"),
|
||||||
E("ldlat-stores", "%s/mem-stores/P", "%s/events/mem-stores"),
|
E("ldlat-stores", "%s/mem-stores/P", "%s/events/mem-stores"),
|
||||||
E(NULL, NULL, NULL),
|
E(NULL, NULL, NULL),
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = {
|
struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = {
|
||||||
E(NULL, NULL, NULL),
|
E(NULL, NULL, NULL),
|
||||||
E(NULL, NULL, NULL),
|
E(NULL, NULL, NULL),
|
||||||
E("mem-ldst", "ibs_op//", "ibs_op"),
|
E("mem-ldst", "ibs_op//", "ibs_op"),
|
||||||
|
9
tools/perf/arch/x86/util/mem-events.h
Normal file
9
tools/perf/arch/x86/util/mem-events.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
#ifndef _X86_MEM_EVENTS_H
|
||||||
|
#define _X86_MEM_EVENTS_H
|
||||||
|
|
||||||
|
extern struct perf_mem_event perf_mem_events_intel[PERF_MEM_EVENTS__MAX];
|
||||||
|
|
||||||
|
extern struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX];
|
||||||
|
|
||||||
|
#endif /* _X86_MEM_EVENTS_H */
|
@ -15,6 +15,7 @@
|
|||||||
#include "../../../util/pmu.h"
|
#include "../../../util/pmu.h"
|
||||||
#include "../../../util/fncache.h"
|
#include "../../../util/fncache.h"
|
||||||
#include "../../../util/pmus.h"
|
#include "../../../util/pmus.h"
|
||||||
|
#include "mem-events.h"
|
||||||
#include "env.h"
|
#include "env.h"
|
||||||
|
|
||||||
void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
||||||
@ -30,6 +31,12 @@ void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
|||||||
pmu->selectable = true;
|
pmu->selectable = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (x86__is_amd_cpu()) {
|
||||||
|
if (!strcmp(pmu->name, "ibs_op"))
|
||||||
|
pmu->mem_events = perf_mem_events_amd;
|
||||||
|
} else if (pmu->is_core)
|
||||||
|
pmu->mem_events = perf_mem_events_intel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int perf_pmus__num_mem_pmus(void)
|
int perf_pmus__num_mem_pmus(void)
|
||||||
|
@ -19,7 +19,7 @@ unsigned int perf_mem_events__loads_ldlat = 30;
|
|||||||
|
|
||||||
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
|
||||||
|
|
||||||
static struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
|
struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX] = {
|
||||||
E("ldlat-loads", "cpu/mem-loads,ldlat=%u/P", "cpu/events/mem-loads"),
|
E("ldlat-loads", "cpu/mem-loads,ldlat=%u/P", "cpu/events/mem-loads"),
|
||||||
E("ldlat-stores", "cpu/mem-stores/P", "cpu/events/mem-stores"),
|
E("ldlat-stores", "cpu/mem-stores/P", "cpu/events/mem-stores"),
|
||||||
E(NULL, NULL, NULL),
|
E(NULL, NULL, NULL),
|
||||||
|
@ -34,6 +34,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern unsigned int perf_mem_events__loads_ldlat;
|
extern unsigned int perf_mem_events__loads_ldlat;
|
||||||
|
extern struct perf_mem_event perf_mem_events[PERF_MEM_EVENTS__MAX];
|
||||||
|
|
||||||
int perf_mem_events__parse(const char *str);
|
int perf_mem_events__parse(const char *str);
|
||||||
int perf_mem_events__init(void);
|
int perf_mem_events__init(void);
|
||||||
|
@ -986,8 +986,10 @@ static int pmu_max_precise(int dirfd, struct perf_pmu *pmu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void __weak
|
void __weak
|
||||||
perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused)
|
perf_pmu__arch_init(struct perf_pmu *pmu)
|
||||||
{
|
{
|
||||||
|
if (pmu->is_core)
|
||||||
|
pmu->mem_events = perf_mem_events;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char *name)
|
struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char *name)
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "parse-events.h"
|
#include "parse-events.h"
|
||||||
#include "pmu-events/pmu-events.h"
|
#include "pmu-events/pmu-events.h"
|
||||||
|
#include "map_symbol.h"
|
||||||
|
#include "mem-events.h"
|
||||||
|
|
||||||
struct evsel_config_term;
|
struct evsel_config_term;
|
||||||
struct perf_cpu_map;
|
struct perf_cpu_map;
|
||||||
@ -162,6 +164,11 @@ struct perf_pmu {
|
|||||||
*/
|
*/
|
||||||
bool exclude_guest;
|
bool exclude_guest;
|
||||||
} missing_features;
|
} missing_features;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mem_events: List of the supported mem events
|
||||||
|
*/
|
||||||
|
struct perf_mem_event *mem_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @perf_pmu__fake: A special global PMU used for testing. */
|
/** @perf_pmu__fake: A special global PMU used for testing. */
|
||||||
|
Loading…
Reference in New Issue
Block a user