ia64/linux-2.6.18-xen.hg

changeset 310:fced90d566f1

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@xensource.com>
author Keir Fraser <keir@xensource.com>
date Sat Nov 10 10:18:28 2007 +0000 (2007-11-10)
parents cf8b6cafa2f0
children ca05cf1a9bdc
files drivers/cpufreq/cpufreq_ondemand.c
line diff
     1.1 --- a/drivers/cpufreq/cpufreq_ondemand.c	Thu Nov 08 18:26:08 2007 +0000
     1.2 +++ b/drivers/cpufreq/cpufreq_ondemand.c	Sat Nov 10 10:18:28 2007 +0000
     1.3 @@ -296,7 +296,7 @@ static int dbs_calc_load(struct cpu_dbs_
     1.4  		cputime64_t total_idle_nsecs, tmp_idle_nsecs;
     1.5  		cputime64_t total_wall_nsecs, tmp_wall_nsecs;
     1.6  		struct cpu_dbs_info_s *j_dbs_info;
     1.7 -		unsigned long tmp_load;
     1.8 +		unsigned long tmp_load, tmp_wall_msecs, tmp_idle_msecs;
     1.9  
    1.10  		j_dbs_info = &per_cpu(cpu_dbs_info, j);
    1.11  		total_idle_nsecs = idletime[j];
    1.12 @@ -312,8 +312,18 @@ static int dbs_calc_load(struct cpu_dbs_
    1.13  		j_dbs_info->prev_cpu_wall = total_wall_nsecs;
    1.14  		j_dbs_info->prev_cpu_idle = total_idle_nsecs;
    1.15  
    1.16 -		tmp_load = (100 * (tmp_wall_nsecs - tmp_idle_nsecs)) /
    1.17 -				tmp_wall_nsecs;
    1.18 +		/* Convert nsecs to msecs and clamp times to sane values. */
    1.19 +		do_div(tmp_wall_nsecs, 1000000);
    1.20 +		tmp_wall_msecs = tmp_wall_nsecs;
    1.21 +		do_div(tmp_idle_nsecs, 1000000);
    1.22 +		tmp_idle_msecs = tmp_idle_nsecs;
    1.23 +		if (tmp_wall_msecs == 0)
    1.24 +			tmp_wall_msecs = 1;
    1.25 +		if (tmp_idle_msecs < tmp_wall_msecs)
    1.26 +			tmp_idle_msecs = tmp_wall_msecs;
    1.27 +
    1.28 +		tmp_load = (100 * (tmp_wall_msecs - tmp_idle_msecs)) /
    1.29 +				tmp_wall_msecs;
    1.30  		load = max(load, min(100, (int) tmp_load));
    1.31  	}
    1.32  	return load;