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_conservative.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_conservative.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index c97b468ee9f7..118bff73fed3 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -95,27 +95,26 @@ static struct dbs_tuners { | |||
95 | .freq_step = 5, | 95 | .freq_step = 5, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 98 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
99 | cputime64_t *wall) | ||
100 | { | 99 | { |
101 | cputime64_t idle_time; | 100 | u64 idle_time; |
102 | cputime64_t cur_wall_time; | 101 | cputime64_t cur_wall_time; |
103 | cputime64_t busy_time; | 102 | u64 busy_time; |
104 | 103 | ||
105 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 104 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
106 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | 105 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER] + |
107 | kstat_cpu(cpu).cpustat.system); | 106 | kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
108 | 107 | ||
109 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 108 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
110 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 109 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
111 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 110 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; |
112 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 111 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; |
113 | 112 | ||
114 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 113 | idle_time = cputime64_sub(cur_wall_time, busy_time); |
115 | if (wall) | 114 | if (wall) |
116 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 115 | *wall = jiffies_to_usecs(cur_wall_time); |
117 | 116 | ||
118 | return (cputime64_t)jiffies_to_usecs(idle_time); | 117 | return jiffies_to_usecs(idle_time); |
119 | } | 118 | } |
120 | 119 | ||
121 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 120 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -272,7 +271,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
272 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 271 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
273 | &dbs_info->prev_cpu_wall); | 272 | &dbs_info->prev_cpu_wall); |
274 | if (dbs_tuners_ins.ignore_nice) | 273 | if (dbs_tuners_ins.ignore_nice) |
275 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 274 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
276 | } | 275 | } |
277 | return count; | 276 | return count; |
278 | } | 277 | } |
@@ -362,11 +361,11 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
362 | j_dbs_info->prev_cpu_idle = cur_idle_time; | 361 | j_dbs_info->prev_cpu_idle = cur_idle_time; |
363 | 362 | ||
364 | if (dbs_tuners_ins.ignore_nice) { | 363 | if (dbs_tuners_ins.ignore_nice) { |
365 | cputime64_t cur_nice; | 364 | u64 cur_nice; |
366 | unsigned long cur_nice_jiffies; | 365 | unsigned long cur_nice_jiffies; |
367 | 366 | ||
368 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 367 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
369 | j_dbs_info->prev_cpu_nice); | 368 | j_dbs_info->prev_cpu_nice; |
370 | /* | 369 | /* |
371 | * Assumption: nice time between sampling periods will | 370 | * Assumption: nice time between sampling periods will |
372 | * be less than 2^32 jiffies for 32 bit sys | 371 | * be less than 2^32 jiffies for 32 bit sys |
@@ -374,7 +373,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
374 | cur_nice_jiffies = (unsigned long) | 373 | cur_nice_jiffies = (unsigned long) |
375 | cputime64_to_jiffies64(cur_nice); | 374 | cputime64_to_jiffies64(cur_nice); |
376 | 375 | ||
377 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 376 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
378 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 377 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
379 | } | 378 | } |
380 | 379 | ||
@@ -501,10 +500,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
501 | 500 | ||
502 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 501 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
503 | &j_dbs_info->prev_cpu_wall); | 502 | &j_dbs_info->prev_cpu_wall); |
504 | if (dbs_tuners_ins.ignore_nice) { | 503 | if (dbs_tuners_ins.ignore_nice) |
505 | j_dbs_info->prev_cpu_nice = | 504 | j_dbs_info->prev_cpu_nice = |
506 | kstat_cpu(j).cpustat.nice; | 505 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
507 | } | ||
508 | } | 506 | } |
509 | this_dbs_info->down_skip = 0; | 507 | this_dbs_info->down_skip = 0; |
510 | this_dbs_info->requested_freq = policy->cur; | 508 | this_dbs_info->requested_freq = policy->cur; |