[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] cpufreq: Fix the ondemand driver for Xen. No 64-bit division allowed



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1194689908 0
# Node ID fced90d566f1158ba1c8593554571f77e25f7118
# Parent  cf8b6cafa2f0a8ba698322786cc78ae28a1b0f60
cpufreq: Fix the ondemand driver for Xen. No 64-bit division allowed
in a 32-bit kernel except in special circumstances.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 drivers/cpufreq/cpufreq_ondemand.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff -r cf8b6cafa2f0 -r fced90d566f1 drivers/cpufreq/cpufreq_ondemand.c
--- a/drivers/cpufreq/cpufreq_ondemand.c        Thu Nov 08 18:26:08 2007 +0000
+++ b/drivers/cpufreq/cpufreq_ondemand.c        Sat Nov 10 10:18:28 2007 +0000
@@ -296,7 +296,7 @@ static int dbs_calc_load(struct cpu_dbs_
                cputime64_t total_idle_nsecs, tmp_idle_nsecs;
                cputime64_t total_wall_nsecs, tmp_wall_nsecs;
                struct cpu_dbs_info_s *j_dbs_info;
-               unsigned long tmp_load;
+               unsigned long tmp_load, tmp_wall_msecs, tmp_idle_msecs;
 
                j_dbs_info = &per_cpu(cpu_dbs_info, j);
                total_idle_nsecs = idletime[j];
@@ -312,8 +312,18 @@ static int dbs_calc_load(struct cpu_dbs_
                j_dbs_info->prev_cpu_wall = total_wall_nsecs;
                j_dbs_info->prev_cpu_idle = total_idle_nsecs;
 
-               tmp_load = (100 * (tmp_wall_nsecs - tmp_idle_nsecs)) /
-                               tmp_wall_nsecs;
+               /* Convert nsecs to msecs and clamp times to sane values. */
+               do_div(tmp_wall_nsecs, 1000000);
+               tmp_wall_msecs = tmp_wall_nsecs;
+               do_div(tmp_idle_nsecs, 1000000);
+               tmp_idle_msecs = tmp_idle_nsecs;
+               if (tmp_wall_msecs == 0)
+                       tmp_wall_msecs = 1;
+               if (tmp_idle_msecs < tmp_wall_msecs)
+                       tmp_idle_msecs = tmp_wall_msecs;
+
+               tmp_load = (100 * (tmp_wall_msecs - tmp_idle_msecs)) /
+                               tmp_wall_msecs;
                load = max(load, min(100, (int) tmp_load));
        }
        return load;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.