On Wed, Oct 31, 2012 at 9:03 PM, Mark Langsdorf <mark.langsdorf@xxxxxxxxxxx> wrote: > Allow frequency values to vary by +/-5000 Hz when collecting stats. > > Signed-off-by: Mark Langsdorf <mark.langsdorf@xxxxxxxxxxx> > Cc: cpufreq@xxxxxxxxxxxxxxx > Cc: Rafael J. Wysocki <rjw@xxxxxxx> If we are getting values with some variations from policy->cur and we can sure that the every "intended" frequency is already included in the freq_table[] array, why don't we simply do rounding based on the freq_table[]? (choosing the closest value from the table) Besides, your proposal may incur bugs in my system (look at the first two values): mzx@hisui:~/test$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 3401000 3400000 3200000 3000000 2800000 2600000 2400000 2200000 2000000 1800000 1600000 mzx@hisui:~/test$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 42 model name : Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz stepping : 7 cpu MHz : 1600.000 cache size : 8192 KB [skip] Cheers, MyungJoo > > --- > drivers/cpufreq/cpufreq_stats.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c > index 3998316..4e2ea7e 100644 > --- a/drivers/cpufreq/cpufreq_stats.c > +++ b/drivers/cpufreq/cpufreq_stats.c > @@ -158,9 +158,11 @@ static struct attribute_group stats_attr_group = { > static int freq_table_get_index(struct cpufreq_stats *stat, unsigned int freq) > { > int index; > - for (index = 0; index < stat->max_state; index++) > - if (stat->freq_table[index] == freq) > + for (index = 0; index < stat->max_state; index++) { > + if ((stat->freq_table[index] < (freq + 5000)) && > + (stat->freq_table[index] > (freq - 5000))) > return index; > + } > return -1; > } > > @@ -251,6 +253,8 @@ static int cpufreq_stats_create_table(struct cpufreq_policy *policy, > spin_lock(&cpufreq_stats_lock); > stat->last_time = get_jiffies_64(); > stat->last_index = freq_table_get_index(stat, policy->cur); > + if (stat->last_index > stat->max_state) > + stat->last_index = stat->max_state - 1; > spin_unlock(&cpufreq_stats_lock); > cpufreq_cpu_put(data); > return 0; > -- > 1.7.11.7 > > -- > To unsubscribe from this list: send the line "unsubscribe cpufreq" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- MyungJoo Ham, Ph.D. System S/W Lab, S/W Center, Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe cpufreq" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html