Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0af99b13c9f323e658b4f1d69a1ccae7d6f3f80a
Commit:     0af99b13c9f323e658b4f1d69a1ccae7d6f3f80a
Parent:     c7f652e0487a35c16f6cd72707232b6a28647a10
Author:     Venki Pallipadi <[EMAIL PROTECTED]>
AuthorDate: Wed Jun 20 14:24:52 2007 -0700
Committer:  Dave Jones <[EMAIL PROTECTED]>
CommitDate: Thu Jun 21 12:57:53 2007 -0400

    [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 <[EMAIL PROTECTED]>
    Signed-off-by: Dave Jones <[EMAIL PROTECTED]>
---
 drivers/cpufreq/cpufreq_ondemand.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_ondemand.c 
b/drivers/cpufreq/cpufreq_ondemand.c
index 8532bb7..dc6f357 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -325,7 +325,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;
@@ -370,7 +370,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) {
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to