Commit 9603aa79 authored by Sandipan Das's avatar Sandipan Das Committed by Peter Zijlstra

perf/x86/amd/core: Refactor branch attributes

AMD processors that are capable of recording branches support either Branch
Sampling (BRS) or Last Branch Record (LBR). In preparation for adding Last
Branch Record Extension Version 2 (LbrExtV2) support, reuse the "branches"
capability to advertise information about both BRS and LBR but make the
"branch-brs" event exclusive to Family 19h processors that support BRS.
Signed-off-by: default avatarSandipan Das <sandipan.das@amd.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/ba4a4cde6db79b1c65c49834027bbdb8a915546b.1660211399.git.sandipan.das@amd.com
parent b40d0156
...@@ -1247,23 +1247,25 @@ static ssize_t branches_show(struct device *cdev, ...@@ -1247,23 +1247,25 @@ static ssize_t branches_show(struct device *cdev,
static DEVICE_ATTR_RO(branches); static DEVICE_ATTR_RO(branches);
static struct attribute *amd_pmu_brs_attrs[] = { static struct attribute *amd_pmu_branches_attrs[] = {
&dev_attr_branches.attr, &dev_attr_branches.attr,
NULL, NULL,
}; };
static umode_t static umode_t
amd_brs_is_visible(struct kobject *kobj, struct attribute *attr, int i) amd_branches_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{ {
return x86_pmu.lbr_nr ? attr->mode : 0; return x86_pmu.lbr_nr ? attr->mode : 0;
} }
static struct attribute_group group_caps_amd_brs = { static struct attribute_group group_caps_amd_branches = {
.name = "caps", .name = "caps",
.attrs = amd_pmu_brs_attrs, .attrs = amd_pmu_branches_attrs,
.is_visible = amd_brs_is_visible, .is_visible = amd_branches_is_visible,
}; };
#ifdef CONFIG_PERF_EVENTS_AMD_BRS
EVENT_ATTR_STR(branch-brs, amd_branch_brs, EVENT_ATTR_STR(branch-brs, amd_branch_brs,
"event=" __stringify(AMD_FAM19H_BRS_EVENT)"\n"); "event=" __stringify(AMD_FAM19H_BRS_EVENT)"\n");
...@@ -1272,15 +1274,26 @@ static struct attribute *amd_brs_events_attrs[] = { ...@@ -1272,15 +1274,26 @@ static struct attribute *amd_brs_events_attrs[] = {
NULL, NULL,
}; };
static umode_t
amd_brs_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return static_cpu_has(X86_FEATURE_BRS) && x86_pmu.lbr_nr ?
attr->mode : 0;
}
static struct attribute_group group_events_amd_brs = { static struct attribute_group group_events_amd_brs = {
.name = "events", .name = "events",
.attrs = amd_brs_events_attrs, .attrs = amd_brs_events_attrs,
.is_visible = amd_brs_is_visible, .is_visible = amd_brs_is_visible,
}; };
#endif /* CONFIG_PERF_EVENTS_AMD_BRS */
static const struct attribute_group *amd_attr_update[] = { static const struct attribute_group *amd_attr_update[] = {
&group_caps_amd_brs, &group_caps_amd_branches,
#ifdef CONFIG_PERF_EVENTS_AMD_BRS
&group_events_amd_brs, &group_events_amd_brs,
#endif
NULL, NULL,
}; };
......
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