]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
CPUFREQ: ondemand: add a check to avoid negative load calculation
authorVenki Pallipadi <venkatesh.pallipadi@intel.com>
Wed, 20 Jun 2007 21:24:52 +0000 (14:24 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 15 Aug 2007 16:25:10 +0000 (09:25 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/cpufreq/cpufreq_ondemand.c

index b6b3e52c9f282de85a37be9f350e978cf9351330..e794527e49251d10564e703805b1965844c12b65 100644 (file)
@@ -335,7 +335,7 @@ static struct attribute_group dbs_attr_group = {
 static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
 {
        unsigned int idle_ticks, total_ticks;
-       unsigned int load;
+       unsigned int load = 0;
        cputime64_t cur_jiffies;
 
        struct cpufreq_policy *policy;
@@ -381,7 +381,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
                if (tmp_idle_ticks < idle_ticks)
                        idle_ticks = tmp_idle_ticks;
        }
-       load = (100 * (total_ticks - idle_ticks)) / total_ticks;
+       if (likely(total_ticks > idle_ticks))
+               load = (100 * (total_ticks - idle_ticks)) / total_ticks;
 
        /* Check for frequency increase */
        if (load > dbs_tuners_ins.up_threshold) {