Commit 7e3a0096 authored by Kan Liang's avatar Kan Liang Committed by Yunying Sun
Browse files

perf/x86/intel/cstate: Cleanup duplicate attr_groups

mainline inclusion
from mainline-v6.8-rc1
commit 243218ca93037631f0224fdbefea045912cb761a
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8YVW5
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=243218ca93037631f0224fdbefea045912cb761a



-------------------------------------

The events of the cstate_core and cstate_pkg PMU have the same format.
They both need to create a "events" group (with empty attrs). The
attr_groups can be shared.

Remove the dedicated attr_groups for each cstate PMU. Use the shared
cstate_attr_groups to replace.

Intel-SIG: commit 243218ca9303 perf/x86/intel/cstate: Cleanup duplicate attr_groups
Backport SRF/GRR perf cstate support to kernel 5.10.

Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231116142245.1233485-1-kan.liang@linux.intel.com


Signed-off-by: default avatarYunying Sun <yunying.sun@intel.com>
parent 2c02ef08
Loading
Loading
Loading
Loading
+11 −33
Original line number Diff line number Diff line
@@ -189,20 +189,20 @@ static struct attribute *attrs_empty[] = {
 * "events" group (with empty attrs) before updating
 * it with detected events.
 */
static struct attribute_group core_events_attr_group = {
static struct attribute_group cstate_events_attr_group = {
	.name = "events",
	.attrs = attrs_empty,
};

DEFINE_CSTATE_FORMAT_ATTR(core_event, event, "config:0-63");
static struct attribute *core_format_attrs[] = {
	&format_attr_core_event.attr,
DEFINE_CSTATE_FORMAT_ATTR(cstate_event, event, "config:0-63");
static struct attribute *cstate_format_attrs[] = {
	&format_attr_cstate_event.attr,
	NULL,
};

static struct attribute_group core_format_attr_group = {
static struct attribute_group cstate_format_attr_group = {
	.name = "format",
	.attrs = core_format_attrs,
	.attrs = cstate_format_attrs,
};

static cpumask_t cstate_core_cpu_mask;
@@ -217,9 +217,9 @@ static struct attribute_group cpumask_attr_group = {
	.attrs = cstate_cpumask_attrs,
};

static const struct attribute_group *core_attr_groups[] = {
	&core_events_attr_group,
	&core_format_attr_group,
static const struct attribute_group *cstate_attr_groups[] = {
	&cstate_events_attr_group,
	&cstate_format_attr_group,
	&cpumask_attr_group,
	NULL,
};
@@ -268,30 +268,8 @@ static struct perf_msr pkg_msr[] = {
	[PERF_CSTATE_PKG_C10_RES] = { MSR_PKG_C10_RESIDENCY,	&group_cstate_pkg_c10,	test_msr },
};

static struct attribute_group pkg_events_attr_group = {
	.name = "events",
	.attrs = attrs_empty,
};

DEFINE_CSTATE_FORMAT_ATTR(pkg_event, event, "config:0-63");
static struct attribute *pkg_format_attrs[] = {
	&format_attr_pkg_event.attr,
	NULL,
};
static struct attribute_group pkg_format_attr_group = {
	.name = "format",
	.attrs = pkg_format_attrs,
};

static cpumask_t cstate_pkg_cpu_mask;

static const struct attribute_group *pkg_attr_groups[] = {
	&pkg_events_attr_group,
	&pkg_format_attr_group,
	&cpumask_attr_group,
	NULL,
};

static ssize_t cstate_get_attr_cpumask(struct device *dev,
				       struct device_attribute *attr,
				       char *buf)
@@ -477,7 +455,7 @@ static const struct attribute_group *pkg_attr_update[] = {
};

static struct pmu cstate_core_pmu = {
	.attr_groups	= core_attr_groups,
	.attr_groups	= cstate_attr_groups,
	.attr_update	= core_attr_update,
	.name		= "cstate_core",
	.task_ctx_nr	= perf_invalid_context,
@@ -492,7 +470,7 @@ static struct pmu cstate_core_pmu = {
};

static struct pmu cstate_pkg_pmu = {
	.attr_groups	= pkg_attr_groups,
	.attr_groups	= cstate_attr_groups,
	.attr_update	= pkg_attr_update,
	.name		= "cstate_pkg",
	.task_ctx_nr	= perf_invalid_context,