diff options
author | Glauber Costa <glommer@parallels.com> | 2011-11-28 11:45:17 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-12-06 03:06:38 -0500 |
commit | 3292beb340c76884427faa1f5d6085719477d889 (patch) | |
tree | cb7e431b2a15fa66ef5278d485131bac7a125fbd /drivers/cpufreq/cpufreq_ondemand.c | |
parent | 786d6dc7aeb2bfbfe417507b7beb83919f319db3 (diff) |
sched/accounting: Change cpustat fields to an array
This patch changes fields in cpustat from a structure, to an
u64 array. Math gets easier, and the code is more flexible.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Paul Tuner <pjt@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1322498719-2255-2-git-send-email-glommer@parallels.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index fa8af4ebb1d6..f3d327cee43f 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -119,27 +119,26 @@ static struct dbs_tuners { | |||
119 | .powersave_bias = 0, | 119 | .powersave_bias = 0, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 122 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
123 | cputime64_t *wall) | ||
124 | { | 123 | { |
125 | cputime64_t idle_time; | 124 | u64 idle_time; |
126 | cputime64_t cur_wall_time; | 125 | cputime64_t cur_wall_time; |
127 | cputime64_t busy_time; | 126 | u64 busy_time; |
128 | 127 | ||
129 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 128 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
130 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | 129 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER] + |
131 | kstat_cpu(cpu).cpustat.system); | 130 | kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
132 | 131 | ||
133 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 132 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
134 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 133 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
135 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 134 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; |
136 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 135 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; |
137 | 136 | ||
138 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 137 | idle_time = cputime64_sub(cur_wall_time, busy_time); |
139 | if (wall) | 138 | if (wall) |
140 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 139 | *wall = jiffies_to_usecs(cur_wall_time); |
141 | 140 | ||
142 | return (cputime64_t)jiffies_to_usecs(idle_time); | 141 | return jiffies_to_usecs(idle_time); |
143 | } | 142 | } |
144 | 143 | ||
145 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 144 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -345,7 +344,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
345 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 344 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
346 | &dbs_info->prev_cpu_wall); | 345 | &dbs_info->prev_cpu_wall); |
347 | if (dbs_tuners_ins.ignore_nice) | 346 | if (dbs_tuners_ins.ignore_nice) |
348 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 347 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
349 | 348 | ||
350 | } | 349 | } |
351 | return count; | 350 | return count; |
@@ -455,11 +454,11 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
455 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; | 454 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; |
456 | 455 | ||
457 | if (dbs_tuners_ins.ignore_nice) { | 456 | if (dbs_tuners_ins.ignore_nice) { |
458 | cputime64_t cur_nice; | 457 | u64 cur_nice; |
459 | unsigned long cur_nice_jiffies; | 458 | unsigned long cur_nice_jiffies; |
460 | 459 | ||
461 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 460 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
462 | j_dbs_info->prev_cpu_nice); | 461 | j_dbs_info->prev_cpu_nice; |
463 | /* | 462 | /* |
464 | * Assumption: nice time between sampling periods will | 463 | * Assumption: nice time between sampling periods will |
465 | * be less than 2^32 jiffies for 32 bit sys | 464 | * be less than 2^32 jiffies for 32 bit sys |
@@ -467,7 +466,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
467 | cur_nice_jiffies = (unsigned long) | 466 | cur_nice_jiffies = (unsigned long) |
468 | cputime64_to_jiffies64(cur_nice); | 467 | cputime64_to_jiffies64(cur_nice); |
469 | 468 | ||
470 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 469 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
471 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 470 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
472 | } | 471 | } |
473 | 472 | ||
@@ -646,10 +645,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
646 | 645 | ||
647 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 646 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
648 | &j_dbs_info->prev_cpu_wall); | 647 | &j_dbs_info->prev_cpu_wall); |
649 | if (dbs_tuners_ins.ignore_nice) { | 648 | if (dbs_tuners_ins.ignore_nice) |
650 | j_dbs_info->prev_cpu_nice = | 649 | j_dbs_info->prev_cpu_nice = |
651 | kstat_cpu(j).cpustat.nice; | 650 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
652 | } | ||
653 | } | 651 | } |
654 | this_dbs_info->cpu = cpu; | 652 | this_dbs_info->cpu = cpu; |
655 | this_dbs_info->rate_mult = 1; | 653 | this_dbs_info->rate_mult = 1; |