Skip to content

Commit

Permalink
perf/x86/intel: Reorganize attrs and is_visible
Browse files Browse the repository at this point in the history
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) <peterz@infradead.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20231025201626.3000228-4-kan.liang@linux.intel.com
  • Loading branch information
Kan Liang authored and Peter Zijlstra committed Oct 27, 2023
1 parent 1f2376c commit 318c498
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions arch/x86/events/intel/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -5540,6 +5540,12 @@ static struct attribute *lbr_attrs[] = {
NULL
};

static umode_t
lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return x86_pmu.lbr_nr ? attr->mode : 0;
}

static char pmu_name_str[30];

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

static umode_t
default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
if (attr == &dev_attr_allow_tsx_force_abort.attr)
return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0;

return attr->mode;
}

static umode_t
tsx_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
Expand All @@ -5587,27 +5602,12 @@ mem_is_visible(struct kobject *kobj, struct attribute *attr, int i)
return pebs_is_visible(kobj, attr, i);
}

static umode_t
lbr_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return x86_pmu.lbr_nr ? attr->mode : 0;
}

static umode_t
exra_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return x86_pmu.version >= 2 ? attr->mode : 0;
}

static umode_t
default_is_visible(struct kobject *kobj, struct attribute *attr, int i)
{
if (attr == &dev_attr_allow_tsx_force_abort.attr)
return x86_pmu.flags & PMU_FL_TFA ? attr->mode : 0;

return attr->mode;
}

static struct attribute_group group_events_td = {
.name = "events",
};
Expand Down

0 comments on commit 318c498

Please sign in to comment.