Commit 2a3e3f73 authored by Stephane Eranian's avatar Stephane Eranian Committed by Ingo Molnar

perf/x86/rapl: Flip logic on default events visibility

This patch modifies the default visibility of the attribute_group
for each RAPL event. By default if the grp.is_visible field is NULL,
sysfs considers that it must display the attribute group.
If the field is not NULL (callback function), then the return value
of the callback determines the visibility (0 = not visible). The RAPL
attribute groups had the field set to NULL, meaning that unless they
failed the probing from perf_msr_probe(), they would be visible. We want
to avoid having to specify attribute groups that are not supported by the HW
in the rapl_msrs[] array, they don't have an MSR address to begin with.

Therefore, we intialize the visible field of all RAPL attribute groups
to a callback that returns 0. If the RAPL msr goes through probing
and succeeds the is_visible field will be set back to NULL (visible).
If the probing fails the field is set to a callback that return 0 (not visible).
Signed-off-by: default avatarStephane Eranian <eranian@google.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20200527224659.206129-4-eranian@google.com
parent 5c95c689
...@@ -460,9 +460,16 @@ static struct attribute *rapl_events_cores[] = { ...@@ -460,9 +460,16 @@ static struct attribute *rapl_events_cores[] = {
NULL, NULL,
}; };
static umode_t
rapl_not_visible(struct kobject *kobj, struct attribute *attr, int i)
{
return 0;
}
static struct attribute_group rapl_events_cores_group = { static struct attribute_group rapl_events_cores_group = {
.name = "events", .name = "events",
.attrs = rapl_events_cores, .attrs = rapl_events_cores,
.is_visible = rapl_not_visible,
}; };
static struct attribute *rapl_events_pkg[] = { static struct attribute *rapl_events_pkg[] = {
...@@ -475,6 +482,7 @@ static struct attribute *rapl_events_pkg[] = { ...@@ -475,6 +482,7 @@ static struct attribute *rapl_events_pkg[] = {
static struct attribute_group rapl_events_pkg_group = { static struct attribute_group rapl_events_pkg_group = {
.name = "events", .name = "events",
.attrs = rapl_events_pkg, .attrs = rapl_events_pkg,
.is_visible = rapl_not_visible,
}; };
static struct attribute *rapl_events_ram[] = { static struct attribute *rapl_events_ram[] = {
...@@ -487,6 +495,7 @@ static struct attribute *rapl_events_ram[] = { ...@@ -487,6 +495,7 @@ static struct attribute *rapl_events_ram[] = {
static struct attribute_group rapl_events_ram_group = { static struct attribute_group rapl_events_ram_group = {
.name = "events", .name = "events",
.attrs = rapl_events_ram, .attrs = rapl_events_ram,
.is_visible = rapl_not_visible,
}; };
static struct attribute *rapl_events_gpu[] = { static struct attribute *rapl_events_gpu[] = {
...@@ -499,6 +508,7 @@ static struct attribute *rapl_events_gpu[] = { ...@@ -499,6 +508,7 @@ static struct attribute *rapl_events_gpu[] = {
static struct attribute_group rapl_events_gpu_group = { static struct attribute_group rapl_events_gpu_group = {
.name = "events", .name = "events",
.attrs = rapl_events_gpu, .attrs = rapl_events_gpu,
.is_visible = rapl_not_visible,
}; };
static struct attribute *rapl_events_psys[] = { static struct attribute *rapl_events_psys[] = {
...@@ -511,6 +521,7 @@ static struct attribute *rapl_events_psys[] = { ...@@ -511,6 +521,7 @@ static struct attribute *rapl_events_psys[] = {
static struct attribute_group rapl_events_psys_group = { static struct attribute_group rapl_events_psys_group = {
.name = "events", .name = "events",
.attrs = rapl_events_psys, .attrs = rapl_events_psys,
.is_visible = rapl_not_visible,
}; };
static bool test_msr(int idx, void *data) static bool test_msr(int idx, void *data)
......
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