Skip to content

Commit 2a3e3f7

Browse files
Stephane EranianIngo Molnar
authored andcommitted
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: Stephane Eranian <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5c95c68 commit 2a3e3f7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/x86/events/rapl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,16 @@ static struct attribute *rapl_events_cores[] = {
460460
NULL,
461461
};
462462

463+
static umode_t
464+
rapl_not_visible(struct kobject *kobj, struct attribute *attr, int i)
465+
{
466+
return 0;
467+
}
468+
463469
static struct attribute_group rapl_events_cores_group = {
464470
.name = "events",
465471
.attrs = rapl_events_cores,
472+
.is_visible = rapl_not_visible,
466473
};
467474

468475
static struct attribute *rapl_events_pkg[] = {
@@ -475,6 +482,7 @@ static struct attribute *rapl_events_pkg[] = {
475482
static struct attribute_group rapl_events_pkg_group = {
476483
.name = "events",
477484
.attrs = rapl_events_pkg,
485+
.is_visible = rapl_not_visible,
478486
};
479487

480488
static struct attribute *rapl_events_ram[] = {
@@ -487,6 +495,7 @@ static struct attribute *rapl_events_ram[] = {
487495
static struct attribute_group rapl_events_ram_group = {
488496
.name = "events",
489497
.attrs = rapl_events_ram,
498+
.is_visible = rapl_not_visible,
490499
};
491500

492501
static struct attribute *rapl_events_gpu[] = {
@@ -499,6 +508,7 @@ static struct attribute *rapl_events_gpu[] = {
499508
static struct attribute_group rapl_events_gpu_group = {
500509
.name = "events",
501510
.attrs = rapl_events_gpu,
511+
.is_visible = rapl_not_visible,
502512
};
503513

504514
static struct attribute *rapl_events_psys[] = {
@@ -511,6 +521,7 @@ static struct attribute *rapl_events_psys[] = {
511521
static struct attribute_group rapl_events_psys_group = {
512522
.name = "events",
513523
.attrs = rapl_events_psys,
524+
.is_visible = rapl_not_visible,
514525
};
515526

516527
static bool test_msr(int idx, void *data)

0 commit comments

Comments
 (0)