aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuukka Tikkanen <tuukka.tikkanen@linaro.org>2015-01-22 03:38:11 +0200
committerTuukka Tikkanen <tuukka.tikkanen@linaro.org>2015-01-22 03:44:42 +0200
commit7f365110226a5cb350df98dc7270e851093c8668 (patch)
treea82bccbd027c333e3bc5e8faef17d96d959f610d
parent946d1fbdbef5fd01dfb1c56f392031a9807dc744 (diff)
Fix P-state calculations
alloc_pstate() searched the array of existing frequencies as if the frequencies were in descending order (by frequency) but then inserted the new frequency as if the frequencies were to be sorted into ascending order. The search order was changed to ascending order. cluster_get_highest_freq() actually returned the lowest active frequency in the cluster. core_get_highest_freq() acted in the similar way. These have been fixed. Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
-rw-r--r--idlestat.c4
-rw-r--r--topology.c16
2 files changed, 6 insertions, 14 deletions
diff --git a/idlestat.c b/idlestat.c
index b6f8cbc..6f28caf 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -407,7 +407,7 @@ static void output_pstates(FILE *f, struct init_pstates *initp, int nrcpus,
* This function checks the array of struct cpufreq_pstate in @pstates
* for an entry for @freq. If one if found, the index for this entry
* is returned. If not, a new entry is inserted into the array so that
- * the frequencies are in decreasing order and the index for the new
+ * the frequencies are in increasing order and the index for the new
* entry is returned.
* @return: the index of the existing or newly allocated pstate struct
*/
@@ -419,7 +419,7 @@ static int alloc_pstate(struct cpufreq_pstates *pstates, unsigned int freq)
pstate = pstates->pstate;
nrfreq = pstates->max;
- for (i = 0; i < nrfreq && freq <= pstate[i].freq; i++) {
+ for (i = 0; i < nrfreq && freq >= pstate[i].freq; i++) {
if (pstate[i].freq == freq)
return i;
}
diff --git a/topology.c b/topology.c
index 7e44cf2..6e70773 100644
--- a/topology.c
+++ b/topology.c
@@ -625,7 +625,7 @@ int cluster_get_highest_freq(struct cpu_physical *clust)
struct cpu_cpu *cpu;
int cpu_pstate_index;
unsigned int cpu_freq;
- unsigned int ret = ~0U;
+ unsigned int ret = 0;
cluster_for_each_cpu(cpu, clust) {
cpu_pstate_index = cpu->pstates->current;
@@ -634,14 +634,10 @@ int cluster_get_highest_freq(struct cpu_physical *clust)
if (cpu->pstates->idle > 0)
continue;
cpu_freq = cpu->pstates->pstate[cpu_pstate_index].freq;
- if (cpu_freq < ret)
+ if (cpu_freq > ret)
ret = cpu_freq;
}
- /* It is possible we don't know anything near the start of trace */
- if (ret == ~0U)
- ret = 0;
-
return ret;
}
@@ -664,21 +660,17 @@ int core_get_highest_freq(struct cpu_core *core)
struct cpu_cpu *cpu;
int cpu_pstate_index;
unsigned int cpu_freq;
- unsigned int ret = ~0;
+ unsigned int ret = 0;
core_for_each_cpu(cpu, core) {
cpu_pstate_index = cpu->pstates->current;
if (cpu_pstate_index < 0)
continue;
cpu_freq = cpu->pstates->pstate[cpu_pstate_index].freq;
- if (cpu_freq < ret)
+ if (cpu_freq > ret)
ret = cpu_freq;
}
- /* It is possible we don't know anything near the start of trace */
- if (ret == ~0)
- ret = 0;
-
return ret;
}