Skip to content

Commit 318c498

Browse files
Kan LiangPeter Zijlstra
authored andcommitted
perf/x86/intel: Reorganize attrs and is_visible
Some attrs and is_visible implementations are rather far away from one another which makes the whole thing hard to interpret. There are only two attribute groups which have both .attrs and .is_visible, group_default and group_caps_lbr. Move them together. No functional changes. Suggested-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Kan Liang <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 1f2376c commit 318c498

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

arch/x86/events/intel/core.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5540,6 +5540,12 @@ static struct attribute *lbr_attrs[] = {
55405540
NULL
55415541
};
55425542

5543+
static umode_t
5544+
lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
5545+
{
5546+
return x86_pmu.lbr_nr ? attr->mode : 0;
5547+
}
5548+
55435549
static char pmu_name_str[30];
55445550

55455551
static ssize_t pmu_name_show(struct device *cdev,
@@ -5566,6 +5572,15 @@ static struct attribute *intel_pmu_attrs[] = {
55665572
NULL,
55675573
};
55685574

5575+
static umode_t
5576+
default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
5577+
{
5578+
if (attr == &dev_attr_allow_tsx_force_abort.attr)
5579+
return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0;
5580+
5581+
return attr->mode;
5582+
}
5583+
55695584
static umode_t
55705585
tsx_is_visible(struct kobject *kobj, struct attribute *attr, int i)
55715586
{
@@ -5587,27 +5602,12 @@ mem_is_visible(struct kobject *kobj, struct attribute *attr, int i)
55875602
return pebs_is_visible(kobj, attr, i);
55885603
}
55895604

5590-
static umode_t
5591-
lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
5592-
{
5593-
return x86_pmu.lbr_nr ? attr->mode : 0;
5594-
}
5595-
55965605
static umode_t
55975606
exra_is_visible(struct kobject *kobj, struct attribute *attr, int i)
55985607
{
55995608
return x86_pmu.version >= 2 ? attr->mode : 0;
56005609
}
56015610

5602-
static umode_t
5603-
default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
5604-
{
5605-
if (attr == &dev_attr_allow_tsx_force_abort.attr)
5606-
return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0;
5607-
5608-
return attr->mode;
5609-
}
5610-
56115611
static struct attribute_group group_events_td = {
56125612
.name = "events",
56135613
};

0 commit comments

Comments
 (0)