From 9a52262bf2fe8290c860f13b00c56128de5a5283 Mon Sep 17 00:00:00 2001 From: Larry Bassel Date: Tue, 17 Feb 2015 15:01:11 -0800 Subject: energy_model: calculate number of cap and C states correctly The number of cap and C states displayed for a cluster in a generated energy model template file was not correct, as these values weren't compatible with the list of cap and C states later in the file. Signed-off-by: Larry Bassel Signed-off-by: Amit Kucheria --- energy_model.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/energy_model.c b/energy_model.c index 6931ea4..2ea6fdd 100644 --- a/energy_model.c +++ b/energy_model.c @@ -79,8 +79,17 @@ static int make_energy_model_template(struct program_options *options) s_core = list_entry((&s_phy->core_head)->prev, struct cpu_core, list_core); s_cpu = list_entry((&s_core->cpu_head)->prev, struct cpu_cpu, list_cpu); - num_cap_states = s_cpu->pstates->max; - num_c_states = s_cpu->cstates->cstate_max; + num_c_states = s_cpu->cstates->cstate_max + 1; + for (i = 0; i < s_cpu->pstates->max; i++) { + struct cpufreq_pstate *p = &s_cpu->pstates->pstate[i]; + + if (p->freq == 0) + continue; + + num_cap_states++; + } + + fprintf(f, "\nC-states:\n"); fprintf(f, "cluster%c: %d cap states %d C states\n\n", cluster_number + 'A', num_cap_states, num_c_states); -- cgit v1.2.3