aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_ondemand.c
diff options
context:
space:
mode:
authorVenki Pallipadi <venkatesh.pallipadi@intel.com>2007-06-20 17:24:52 -0400
committerDave Jones <davej@redhat.com>2007-06-21 12:57:53 -0400
commit0af99b13c9f323e658b4f1d69a1ccae7d6f3f80a (patch)
tree531d6ae823c0e7facfd375106f79c213c4a1290b /drivers/cpufreq/cpufreq_ondemand.c
parentc7f652e0487a35c16f6cd72707232b6a28647a10 (diff)
[CPUFREQ] ondemand: add a check to avoid negative load calculation
Due to rounding and inexact jiffy accounting, idle_ticks can sometimes be higher than total_ticks. Make sure those cases are handled as zero load case. Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> Signed-off-by: Dave Jones <davej@redhat.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 8532bb79e5fc..dc6f357390e2 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -325,7 +325,7 @@ static struct attribute_group dbs_attr_group = {
325static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) 325static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
326{ 326{
327 unsigned int idle_ticks, total_ticks; 327 unsigned int idle_ticks, total_ticks;
328 unsigned int load; 328 unsigned int load = 0;
329 cputime64_t cur_jiffies; 329 cputime64_t cur_jiffies;
330 330
331 struct cpufreq_policy *policy; 331 struct cpufreq_policy *policy;
@@ -370,7 +370,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
370 if (tmp_idle_ticks < idle_ticks) 370 if (tmp_idle_ticks < idle_ticks)
371 idle_ticks = tmp_idle_ticks; 371 idle_ticks = tmp_idle_ticks;
372 } 372 }
373 load = (100 * (total_ticks - idle_ticks)) / total_ticks; 373 if (likely(total_ticks > idle_ticks))
374 load = (100 * (total_ticks - idle_ticks)) / total_ticks;
374 375
375 /* Check for frequency increase */ 376 /* Check for frequency increase */
376 if (load > dbs_tuners_ins.up_threshold) { 377 if (load > dbs_tuners_ins.up_threshold) {