Commit 58ae30c2 authored by Kan Liang's avatar Kan Liang Committed by Peter Zijlstra

perf/x86/intel: Add attr_update for Hybrid PMUs

The attribute_group for Hybrid PMUs should be different from the
previous
cpu PMU. For example, cpumask is required for a Hybrid PMU. The PMU type
should be included in the event and format attribute.

Add hybrid_attr_update for the Hybrid PMU.
Check the PMU type in is_visible() function. Only display the event or
format for the matched Hybrid PMU.
Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
Link: https://lkml.kernel.org/r/1618237865-33448-19-git-send-email-kan.liang@linux.intel.com
parent a9c81ccd
......@@ -5118,6 +5118,106 @@ static const struct attribute_group *attr_update[] = {
NULL,
};
static bool is_attr_for_this_pmu(struct kobject *kobj, struct attribute *attr)
{
struct device *dev = kobj_to_dev(kobj);
struct x86_hybrid_pmu *pmu =
container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
struct perf_pmu_events_hybrid_attr *pmu_attr =
container_of(attr, struct perf_pmu_events_hybrid_attr, attr.attr);
return pmu->cpu_type & pmu_attr->pmu_type;
}
static umode_t hybrid_events_is_visible(struct kobject *kobj,
struct attribute *attr, int i)
{
return is_attr_for_this_pmu(kobj, attr) ? attr->mode : 0;
}
static inline int hybrid_find_supported_cpu(struct x86_hybrid_pmu *pmu)
{
int cpu = cpumask_first(&pmu->supported_cpus);
return (cpu >= nr_cpu_ids) ? -1 : cpu;
}
static umode_t hybrid_tsx_is_visible(struct kobject *kobj,
struct attribute *attr, int i)
{
struct device *dev = kobj_to_dev(kobj);
struct x86_hybrid_pmu *pmu =
container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
int cpu = hybrid_find_supported_cpu(pmu);
return (cpu >= 0) && is_attr_for_this_pmu(kobj, attr) && cpu_has(&cpu_data(cpu), X86_FEATURE_RTM) ? attr->mode : 0;
}
static umode_t hybrid_format_is_visible(struct kobject *kobj,
struct attribute *attr, int i)
{
struct device *dev = kobj_to_dev(kobj);
struct x86_hybrid_pmu *pmu =
container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
struct perf_pmu_format_hybrid_attr *pmu_attr =
container_of(attr, struct perf_pmu_format_hybrid_attr, attr.attr);
int cpu = hybrid_find_supported_cpu(pmu);
return (cpu >= 0) && (pmu->cpu_type & pmu_attr->pmu_type) ? attr->mode : 0;
}
static struct attribute_group hybrid_group_events_td = {
.name = "events",
.is_visible = hybrid_events_is_visible,
};
static struct attribute_group hybrid_group_events_mem = {
.name = "events",
.is_visible = hybrid_events_is_visible,
};
static struct attribute_group hybrid_group_events_tsx = {
.name = "events",
.is_visible = hybrid_tsx_is_visible,
};
static struct attribute_group hybrid_group_format_extra = {
.name = "format",
.is_visible = hybrid_format_is_visible,
};
static ssize_t intel_hybrid_get_attr_cpus(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct x86_hybrid_pmu *pmu =
container_of(dev_get_drvdata(dev), struct x86_hybrid_pmu, pmu);
return cpumap_print_to_pagebuf(true, buf, &pmu->supported_cpus);
}
static DEVICE_ATTR(cpus, S_IRUGO, intel_hybrid_get_attr_cpus, NULL);
static struct attribute *intel_hybrid_cpus_attrs[] = {
&dev_attr_cpus.attr,
NULL,
};
static struct attribute_group hybrid_group_cpus = {
.attrs = intel_hybrid_cpus_attrs,
};
static const struct attribute_group *hybrid_attr_update[] = {
&hybrid_group_events_td,
&hybrid_group_events_mem,
&hybrid_group_events_tsx,
&group_caps_gen,
&group_caps_lbr,
&hybrid_group_format_extra,
&group_default,
&hybrid_group_cpus,
NULL,
};
static struct attribute *empty_attrs;
static void intel_pmu_check_num_counters(int *num_counters,
......@@ -5861,14 +5961,22 @@ __init int intel_pmu_init(void)
snprintf(pmu_name_str, sizeof(pmu_name_str), "%s", name);
if (!is_hybrid()) {
group_events_td.attrs = td_attr;
group_events_mem.attrs = mem_attr;
group_events_tsx.attrs = tsx_attr;
group_format_extra.attrs = extra_attr;
group_format_extra_skl.attrs = extra_skl_attr;
group_events_td.attrs = td_attr;
group_events_mem.attrs = mem_attr;
group_events_tsx.attrs = tsx_attr;
group_format_extra.attrs = extra_attr;
group_format_extra_skl.attrs = extra_skl_attr;
x86_pmu.attr_update = attr_update;
} else {
hybrid_group_events_td.attrs = td_attr;
hybrid_group_events_mem.attrs = mem_attr;
hybrid_group_events_tsx.attrs = tsx_attr;
hybrid_group_format_extra.attrs = extra_attr;
x86_pmu.attr_update = attr_update;
x86_pmu.attr_update = hybrid_attr_update;
}
intel_pmu_check_num_counters(&x86_pmu.num_counters,
&x86_pmu.num_counters_fixed,
......
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