[PATCH] cpufreq: Add support to read boost frequencies

Shilpasri G Bhat shilpa.bhat at linux.vnet.ibm.com
Wed Apr 4 08:55:24 UTC 2018


POWER8+ and POWER9 have boost frequencies given by the cpufreq sysfs
file 'scaling_boost_frequencies'. These frequencies are greater than
the 'scaling_available_frequencies'. So re-compute the max frequency
when boost frequencies are available and add the boost frequencies to
the list of supported frequencies.

Signed-off-by: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
---
 src/cpu/cpufreq/cpufreq.c | 24 +++++++++++++++++++++---
 src/cpu/maxfreq/maxfreq.c | 14 +++++++++++++-
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 8bee1dd..6cd7014 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -749,7 +749,7 @@ static int parse_cpu_info(fwts_framework *fw,
 {
 	char *end, path[PATH_MAX+1], *str, *tmp;
 	struct stat statbuf;
-	int rc;
+	int rc, i = 0;
 
 	strcpy(cpu->sysfs_path, dir->d_name);
 	cpu->idx = strtoul(cpu->sysfs_path + strlen("cpu"), &end, 10);
@@ -783,8 +783,6 @@ static int parse_cpu_info(fwts_framework *fw,
 
 	/* cpu driver like intel_pstate has no scaling_available_frequencies */
 	if (str != NULL) {
-		int i = 0;
-
 		for (tmp = str; ; tmp = NULL) {
 			char *tok = strtok(tmp, " ");
 			if (!tok)
@@ -800,6 +798,26 @@ static int parse_cpu_info(fwts_framework *fw,
 
 	free(str);
 
+	/* parse boost frequencies */
+	cpu_mkpath(path, sizeof(path), cpu, "scaling_boost_frequencies");
+	str = fwts_get(path);
+
+	if (str) {
+		for (tmp = str; ; tmp = NULL) {
+			char *tok = strtok(tmp, " ");
+
+			if (!tok)
+				break;
+			if (!isdigit(tok[0]))
+				continue;
+			cpu->freqs[i++].Hz = strtoull(tok, NULL, 10);
+		}
+		cpu->n_freqs = i;
+		qsort(cpu->freqs, cpu->n_freqs, sizeof(cpu->freqs[0]),
+		      cpu_freq_compare);
+	}
+
+	free(str);
 	return FWTS_OK;
 }
 
diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
index 4aab257..ff913a2 100644
--- a/src/cpu/maxfreq/maxfreq.c
+++ b/src/cpu/maxfreq/maxfreq.c
@@ -131,7 +131,7 @@ static int maxfreq_test1(fwts_framework *fw)
 	do {
 		char path[PATH_MAX];
 		char *data;
-		double maxfreq, maxfreq_ghz, cpufreq_ghz;
+		double maxfreq, maxfreq_ghz, cpufreq_ghz, boost_maxfreq;
 		int cpunum;
 
 		entry = readdir(dir);
@@ -148,6 +148,18 @@ static int maxfreq_test1(fwts_framework *fw)
 		maxfreq = maxfreq_max(data);
 		free(data);
 
+		snprintf(path, sizeof(path),
+			CPU_FREQ_PATH "/%s/cpufreq/scaling_boost_frequencies",
+			entry->d_name);
+		data = fwts_get(path);
+		if (data) {
+			boost_maxfreq = maxfreq_max(data);
+			free(data);
+		}
+
+		if (maxfreq > boost_maxfreq)
+			max_freq = boost_max_freq;
+
 		cpunum = atoi(entry->d_name + 3);
 		if (maxfreq < 0.0) {
 			fwts_failed(fw, LOG_LEVEL_MEDIUM,
-- 
1.8.3.1




More information about the fwts-devel mailing list