Skip to content

Commit 243218c

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel/cstate: Cleanup duplicate attr_groups
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. Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 652ffc2 commit 243218c

File tree

1 file changed

+11
-33
lines changed

1 file changed

+11
-33
lines changed

arch/x86/events/intel/cstate.c

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,20 @@ static struct attribute *attrs_empty[] = {
189189
* "events" group (with empty attrs) before updating
190190
* it with detected events.
191191
*/
192-
static struct attribute_group core_events_attr_group = {
192+
static struct attribute_group cstate_events_attr_group = {
193193
.name = "events",
194194
.attrs = attrs_empty,
195195
};
196196

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

203-
static struct attribute_group core_format_attr_group = {
203+
static struct attribute_group cstate_format_attr_group = {
204204
.name = "format",
205-
.attrs = core_format_attrs,
205+
.attrs = cstate_format_attrs,
206206
};
207207

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

220-
static const struct attribute_group *core_attr_groups[] = {
221-
&core_events_attr_group,
222-
&core_format_attr_group,
220+
static const struct attribute_group *cstate_attr_groups[] = {
221+
&cstate_events_attr_group,
222+
&cstate_format_attr_group,
223223
&cpumask_attr_group,
224224
NULL,
225225
};
@@ -268,30 +268,8 @@ static struct perf_msr pkg_msr[] = {
268268
[PERF_CSTATE_PKG_C10_RES] = { MSR_PKG_C10_RESIDENCY, &group_cstate_pkg_c10, test_msr },
269269
};
270270

271-
static struct attribute_group pkg_events_attr_group = {
272-
.name = "events",
273-
.attrs = attrs_empty,
274-
};
275-
276-
DEFINE_CSTATE_FORMAT_ATTR(pkg_event, event, "config:0-63");
277-
static struct attribute *pkg_format_attrs[] = {
278-
&format_attr_pkg_event.attr,
279-
NULL,
280-
};
281-
static struct attribute_group pkg_format_attr_group = {
282-
.name = "format",
283-
.attrs = pkg_format_attrs,
284-
};
285-
286271
static cpumask_t cstate_pkg_cpu_mask;
287272

288-
static const struct attribute_group *pkg_attr_groups[] = {
289-
&pkg_events_attr_group,
290-
&pkg_format_attr_group,
291-
&cpumask_attr_group,
292-
NULL,
293-
};
294-
295273
static ssize_t cstate_get_attr_cpumask(struct device *dev,
296274
struct device_attribute *attr,
297275
char *buf)
@@ -478,7 +456,7 @@ static const struct attribute_group *pkg_attr_update[] = {
478456
};
479457

480458
static struct pmu cstate_core_pmu = {
481-
.attr_groups = core_attr_groups,
459+
.attr_groups = cstate_attr_groups,
482460
.attr_update = core_attr_update,
483461
.name = "cstate_core",
484462
.task_ctx_nr = perf_invalid_context,
@@ -493,7 +471,7 @@ static struct pmu cstate_core_pmu = {
493471
};
494472

495473
static struct pmu cstate_pkg_pmu = {
496-
.attr_groups = pkg_attr_groups,
474+
.attr_groups = cstate_attr_groups,
497475
.attr_update = pkg_attr_update,
498476
.name = "cstate_pkg",
499477
.task_ctx_nr = perf_invalid_context,

0 commit comments

Comments
 (0)