diff mbox

[13/16] cpufreq: interactive: Use generic get_cpu_idle_time() from cpufreq.c

Message ID 413844c8d18a24ca15eb31d1b4a2bd0d219fcba5.1368696171.git.viresh.kumar@linaro.org
State Accepted
Headers show

Commit Message

Viresh Kumar May 16, 2013, 9:28 a.m. UTC
Generic version of get_cpu_idle_time() is present in cpufreq.c file. We must not
replicate that for Interactive governor, rather use the same one. Lets do it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_interactive.c | 42 ++---------------------------------
 1 file changed, 2 insertions(+), 40 deletions(-)

Comments

Todd Poynor June 2, 2013, 6:56 p.m. UTC | #1
- android-kernel@googlegroups.com, a subscription-only list

On Thu, May 16, 2013 at 2:28 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Generic version of get_cpu_idle_time() is present in cpufreq.c file. We must not
> replicate that for Interactive governor, rather use the same one. Lets do it.

Thanks, will touch this up to simply say "Use generic
get_cpu_idle_time().", which didn't exist in the 3.4 code.

>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq_interactive.c | 42 ++---------------------------------
>  1 file changed, 2 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
> index baf8740..4ed2fed 100644
> --- a/drivers/cpufreq/cpufreq_interactive.c
> +++ b/drivers/cpufreq/cpufreq_interactive.c
> @@ -30,8 +30,6 @@
>  #include <linux/workqueue.h>
>  #include <linux/kthread.h>
>  #include <linux/slab.h>
> -#include <linux/kernel_stat.h>
> -#include <asm/cputime.h>
>
>  #define CREATE_TRACE_POINTS
>  #include <trace/events/cpufreq_interactive.h>
> @@ -130,42 +128,6 @@ struct cpufreq_governor cpufreq_gov_interactive = {
>         .owner = THIS_MODULE,
>  };
>
> -static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
> -                                                 cputime64_t *wall)
> -{
> -       u64 idle_time;
> -       u64 cur_wall_time;
> -       u64 busy_time;
> -
> -       cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
> -
> -       busy_time  = kcpustat_cpu(cpu).cpustat[CPUTIME_USER];
> -       busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM];
> -       busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ];
> -       busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ];
> -       busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL];
> -       busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
> -
> -       idle_time = cur_wall_time - busy_time;
> -       if (wall)
> -               *wall = jiffies_to_usecs(cur_wall_time);
> -
> -       return jiffies_to_usecs(idle_time);
> -}
> -
> -static inline cputime64_t get_cpu_idle_time(unsigned int cpu,
> -                                           cputime64_t *wall)
> -{
> -       u64 idle_time = get_cpu_idle_time_us(cpu, wall);
> -
> -       if (idle_time == -1ULL)
> -               idle_time = get_cpu_idle_time_jiffy(cpu, wall);
> -       else if (!io_is_busy)
> -               idle_time += get_cpu_iowait_time_us(cpu, wall);
> -
> -       return idle_time;
> -}
> -
>  static void cpufreq_interactive_timer_resched(
>         struct cpufreq_interactive_cpuinfo *pcpu)
>  {
> @@ -181,7 +143,7 @@ static void cpufreq_interactive_timer_resched(
>         spin_lock_irqsave(&pcpu->load_lock, flags);
>         pcpu->time_in_idle =
>                 get_cpu_idle_time(smp_processor_id(),
> -                                    &pcpu->time_in_idle_timestamp);
> +                                    &pcpu->time_in_idle_timestamp, io_is_busy);
>         pcpu->cputime_speedadj = 0;
>         pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
>         spin_unlock_irqrestore(&pcpu->load_lock, flags);
> @@ -317,7 +279,7 @@ static u64 update_load(int cpu)
>         unsigned int delta_time;
>         u64 active_time;
>
> -       now_idle = get_cpu_idle_time(cpu, &now);
> +       now_idle = get_cpu_idle_time(cpu, &now, io_is_busy);
>         delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle);
>         delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp);
>         active_time = delta_time - delta_idle;
> --
> 1.7.12.rc2.18.g61b472e
>
diff mbox

Patch

diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index baf8740..4ed2fed 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -30,8 +30,6 @@ 
 #include <linux/workqueue.h>
 #include <linux/kthread.h>
 #include <linux/slab.h>
-#include <linux/kernel_stat.h>
-#include <asm/cputime.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/cpufreq_interactive.h>
@@ -130,42 +128,6 @@  struct cpufreq_governor cpufreq_gov_interactive = {
 	.owner = THIS_MODULE,
 };
 
-static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
-						  cputime64_t *wall)
-{
-	u64 idle_time;
-	u64 cur_wall_time;
-	u64 busy_time;
-
-	cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
-
-	busy_time  = kcpustat_cpu(cpu).cpustat[CPUTIME_USER];
-	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM];
-	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ];
-	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ];
-	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL];
-	busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE];
-
-	idle_time = cur_wall_time - busy_time;
-	if (wall)
-		*wall = jiffies_to_usecs(cur_wall_time);
-
-	return jiffies_to_usecs(idle_time);
-}
-
-static inline cputime64_t get_cpu_idle_time(unsigned int cpu,
-					    cputime64_t *wall)
-{
-	u64 idle_time = get_cpu_idle_time_us(cpu, wall);
-
-	if (idle_time == -1ULL)
-		idle_time = get_cpu_idle_time_jiffy(cpu, wall);
-	else if (!io_is_busy)
-		idle_time += get_cpu_iowait_time_us(cpu, wall);
-
-	return idle_time;
-}
-
 static void cpufreq_interactive_timer_resched(
 	struct cpufreq_interactive_cpuinfo *pcpu)
 {
@@ -181,7 +143,7 @@  static void cpufreq_interactive_timer_resched(
 	spin_lock_irqsave(&pcpu->load_lock, flags);
 	pcpu->time_in_idle =
 		get_cpu_idle_time(smp_processor_id(),
-				     &pcpu->time_in_idle_timestamp);
+				     &pcpu->time_in_idle_timestamp, io_is_busy);
 	pcpu->cputime_speedadj = 0;
 	pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
 	spin_unlock_irqrestore(&pcpu->load_lock, flags);
@@ -317,7 +279,7 @@  static u64 update_load(int cpu)
 	unsigned int delta_time;
 	u64 active_time;
 
-	now_idle = get_cpu_idle_time(cpu, &now);
+	now_idle = get_cpu_idle_time(cpu, &now, io_is_busy);
 	delta_idle = (unsigned int)(now_idle - pcpu->time_in_idle);
 	delta_time = (unsigned int)(now - pcpu->time_in_idle_timestamp);
 	active_time = delta_time - delta_idle;