aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_ondemand.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 8532bb79e5fc..e794527e4925 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -96,15 +96,25 @@ static struct dbs_tuners {
96 96
97static inline cputime64_t get_cpu_idle_time(unsigned int cpu) 97static inline cputime64_t get_cpu_idle_time(unsigned int cpu)
98{ 98{
99 cputime64_t retval; 99 cputime64_t idle_time;
100 cputime64_t cur_jiffies;
101 cputime64_t busy_time;
100 102
101 retval = cputime64_add(kstat_cpu(cpu).cpustat.idle, 103 cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
102 kstat_cpu(cpu).cpustat.iowait); 104 busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user,
105 kstat_cpu(cpu).cpustat.system);
103 106
104 if (dbs_tuners_ins.ignore_nice) 107 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq);
105 retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice); 108 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq);
109 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal);
106 110
107 return retval; 111 if (!dbs_tuners_ins.ignore_nice) {
112 busy_time = cputime64_add(busy_time,
113 kstat_cpu(cpu).cpustat.nice);
114 }
115
116 idle_time = cputime64_sub(cur_jiffies, busy_time);
117 return idle_time;
108} 118}
109 119
110/* 120/*
@@ -325,7 +335,7 @@ static struct attribute_group dbs_attr_group = {
325static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) 335static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
326{ 336{
327 unsigned int idle_ticks, total_ticks; 337 unsigned int idle_ticks, total_ticks;
328 unsigned int load; 338 unsigned int load = 0;
329 cputime64_t cur_jiffies; 339 cputime64_t cur_jiffies;
330 340
331 struct cpufreq_policy *policy; 341 struct cpufreq_policy *policy;
@@ -339,7 +349,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
339 cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); 349 cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
340 total_ticks = (unsigned int) cputime64_sub(cur_jiffies, 350 total_ticks = (unsigned int) cputime64_sub(cur_jiffies,
341 this_dbs_info->prev_cpu_wall); 351 this_dbs_info->prev_cpu_wall);
342 this_dbs_info->prev_cpu_wall = cur_jiffies; 352 this_dbs_info->prev_cpu_wall = get_jiffies_64();
353
343 if (!total_ticks) 354 if (!total_ticks)
344 return; 355 return;
345 /* 356 /*
@@ -370,7 +381,8 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
370 if (tmp_idle_ticks < idle_ticks) 381 if (tmp_idle_ticks < idle_ticks)
371 idle_ticks = tmp_idle_ticks; 382 idle_ticks = tmp_idle_ticks;
372 } 383 }
373 load = (100 * (total_ticks - idle_ticks)) / total_ticks; 384 if (likely(total_ticks > idle_ticks))
385 load = (100 * (total_ticks - idle_ticks)) / total_ticks;
374 386
375 /* Check for frequency increase */ 387 /* Check for frequency increase */
376 if (load > dbs_tuners_ins.up_threshold) { 388 if (load > dbs_tuners_ins.up_threshold) {