Skip to contentSkip to conversation

platform/x86/intel-uncore-freq: Conditionally create attribute for read frequency

PATCH In review Srinivas Pandruvada 2 participants 4 messages Oct 2, 2023 – Oct 4, 2023

Subsystems (2)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

PATCH 1/1 platform/x86/intel-uncore-freq: Conditionally create attribute for read frequency

When the current uncore frequency can't be read, don't create attribute "current_freq_khz" as any read will fail later. Some user space applications like turbostat fail to continue with the failure. So, check error during attribute creation.

Fixes 8a54e2253e4c ("platform/x86/intel-uncore-freq: Uncore frequency control via TPMI")

---
update
- Added Fixes tag

 .../x86/intel/uncore-frequency/uncore-frequency-common.c  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +6 -2
index 1152deaa0078..33ab207493e3 100644
@@ -176,7 +176,7 @@ show_uncore_data(initial_max_freq_khz);
 
 static int create_attr_group(struct uncore_data *data, char *name)
 {
-	int ret, index = 0;
+	int ret, freq, index = 0;
 
 	init_attribute_rw(max_freq_khz);
 	init_attribute_rw(min_freq_khz);
@@ -197,7 +197,11 @@ static int create_attr_group(struct uncore_data *data, char *name)
 	data->uncore_attrs[index++] = &data->min_freq_khz_dev_attr.attr;
 	data->uncore_attrs[index++] = &data->initial_min_freq_khz_dev_attr.attr;
 	data->uncore_attrs[index++] = &data->initial_max_freq_khz_dev_attr.attr;
-	data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;
+
+	ret = uncore_read_freq(data, &freq);
+	if (!ret)
+		data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;
+
 	data->uncore_attrs[index] = NULL;
 
 	data->uncore_attr_group.name = name;
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 6 lines · Srinivas Pandruvada

When the current uncore frequency can't be read, don't create attribute "current_freq_khz" as any read will fail later. Some user space applications like turbostat fail to continue with the failure. So, check error during attribute creation.

Fixes 8a54e2253e4c ("platform/x86/intel-uncore-freq: Uncore frequency control via TPMI")

Hi,

Thanks for the update but that commit id looks bogus, or where the value is used w/o error check?

Signature · 1 line
 i.
Quoted 35 lines

---
update
- Added Fixes tag

 .../x86/intel/uncore-frequency/uncore-frequency-common.c  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c +6 -2
index 1152deaa0078..33ab207493e3 100644
@@ -176,7 +176,7 @@ show_uncore_data(initial_max_freq_khz);
 
 static int create_attr_group(struct uncore_data *data, char *name)
 {
-	int ret, index = 0;
+	int ret, freq, index = 0;
 
 	init_attribute_rw(max_freq_khz);
 	init_attribute_rw(min_freq_khz);
@@ -197,7 +197,11 @@ static int create_attr_group(struct uncore_data *data, char *name)
 	data->uncore_attrs[index++] = &data->min_freq_khz_dev_attr.attr;
 	data->uncore_attrs[index++] = &data->initial_min_freq_khz_dev_attr.attr;
 	data->uncore_attrs[index++] = &data->initial_max_freq_khz_dev_attr.attr;
-	data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;
+
+	ret = uncore_read_freq(data, &freq);
+	if (!ret)
+		data->uncore_attrs[index++] = &data->current_freq_khz_dev_attr.attr;
+
 	data->uncore_attrs[index] = NULL;
 
 	data->uncore_attr_group.name = name;
author maintainer
#2 lore raw

Hi llPo,

Quoted 9 lines · Ilpo Järvinen
Quoted 7 lines · Srinivas Pandruvada

When the current uncore frequency can't be read, don't create attribute
"current_freq_khz" as any read will fail later. Some user space applications like turbostat fail to continue with the failure. So, check
error during attribute creation.

Quoted 8 lines
Quoted 2 lines
Fixes 8a54e2253e4c ("platform/x86/intel-uncore-freq: Uncore

frequency control via TPMI")

Hi,

Thanks for the update but that commit id looks bogus, or where the value
is used w/o error check?

commit 8a54e2253e4c25e5b61c9a9bee157bb52da5d432

Author: Srinivas Pandruvada <[email protected]>
Date:   Thu Apr 20 15:05:14 2023 -0700

platform/x86/intel-uncore-freq: Uncore frequency control via TPMI

This is the commit exposed the issue. This is not the commit which changed the code in question.

I can add also

Fixes dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and

enumeration part")

But the change even before that as this commit just reorganized code but because of change of folders, that will look like correct commit.

Thanks,
Srinivas

maintainer
#3 lore raw
Quoted 30 lines · srinivas pandruvada
Quoted 9 lines · Ilpo Järvinen
Quoted 7 lines · Srinivas Pandruvada

When the current uncore frequency can't be read, don't create attribute
"current_freq_khz" as any read will fail later. Some user space applications like turbostat fail to continue with the failure. So, check
error during attribute creation.

Quoted 8 lines
Quoted 2 lines
Fixes 8a54e2253e4c ("platform/x86/intel-uncore-freq: Uncore

frequency control via TPMI")

Hi,

Thanks for the update but that commit id looks bogus, or where the value
is used w/o error check?

commit 8a54e2253e4c25e5b61c9a9bee157bb52da5d432

Author: Srinivas Pandruvada <[email protected]>
Date:   Thu Apr 20 15:05:14 2023 -0700

platform/x86/intel-uncore-freq: Uncore frequency control via TPMI

This is the commit exposed the issue. This is not the commit which changed the code in question.

Quoted 6 lines

I can add also

Fixes dbce412a7733 ("platform/x86/intel-uncore-freq: Split common and

enumeration part")

But the change even before that as this commit just reorganized code but because of change of folders, that will look like correct commit.

I never thought dbce412a7733 is being fixed here, it's just a refactor moving code around like you say.

But how about 414eef27283a ("platform/x86/intel/uncore-freq: Display uncore current frequency") which actually adds the code line you're now fixing. What was broken before it? All I see is the one call in show_perf_status_freq_khz() but that's checking for errors.

Signature · 1 line
 i.