diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2013-05-17 07:26:32 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-05-27 07:20:56 -0400 |
commit | 72a4ce340a7ebf39e1c6fdc8f5feb4f974d6c635 (patch) | |
tree | d7f8215bb0b0c6eb064c69e3957b0dd72ec490e4 | |
parent | 944e9a0316e60bc5bc122e46c1fde36e5f6e9f56 (diff) |
cpufreq: Move get_cpu_idle_time() to cpufreq.c
Governors other than ondemand and conservative can also use
get_cpu_idle_time() and they aren't required to compile
cpufreq_governor.c. So, move these independent routines to
cpufreq.c instead.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 38 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.c | 36 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_governor.h | 1 | ||||
-rw-r--r-- | include/linux/cpufreq.h | 1 |
4 files changed, 39 insertions, 37 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3faf62bdbad0..c6ab21880c07 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -17,7 +17,9 @@ | |||
17 | 17 | ||
18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 18 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
19 | 19 | ||
20 | #include <asm/cputime.h> | ||
20 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/kernel_stat.h> | ||
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
22 | #include <linux/init.h> | 24 | #include <linux/init.h> |
23 | #include <linux/notifier.h> | 25 | #include <linux/notifier.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <linux/delay.h> | 27 | #include <linux/delay.h> |
26 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
27 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
30 | #include <linux/tick.h> | ||
28 | #include <linux/device.h> | 31 | #include <linux/device.h> |
29 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
30 | #include <linux/cpu.h> | 33 | #include <linux/cpu.h> |
@@ -143,6 +146,41 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | |||
143 | } | 146 | } |
144 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); | 147 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); |
145 | 148 | ||
149 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
150 | { | ||
151 | u64 idle_time; | ||
152 | u64 cur_wall_time; | ||
153 | u64 busy_time; | ||
154 | |||
155 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
156 | |||
157 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
158 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
159 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
160 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
161 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
162 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
163 | |||
164 | idle_time = cur_wall_time - busy_time; | ||
165 | if (wall) | ||
166 | *wall = cputime_to_usecs(cur_wall_time); | ||
167 | |||
168 | return cputime_to_usecs(idle_time); | ||
169 | } | ||
170 | |||
171 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
172 | { | ||
173 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
174 | |||
175 | if (idle_time == -1ULL) | ||
176 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
177 | else if (!io_busy) | ||
178 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
179 | |||
180 | return idle_time; | ||
181 | } | ||
182 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
183 | |||
146 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) | 184 | static struct cpufreq_policy *__cpufreq_cpu_get(unsigned int cpu, bool sysfs) |
147 | { | 185 | { |
148 | struct cpufreq_policy *data; | 186 | struct cpufreq_policy *data; |
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index d1421b498c76..b6cfd55d8266 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include <linux/kernel_stat.h> | 23 | #include <linux/kernel_stat.h> |
24 | #include <linux/mutex.h> | 24 | #include <linux/mutex.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/tick.h> | ||
27 | #include <linux/types.h> | 26 | #include <linux/types.h> |
28 | #include <linux/workqueue.h> | 27 | #include <linux/workqueue.h> |
29 | 28 | ||
@@ -37,41 +36,6 @@ static struct attribute_group *get_sysfs_attr(struct dbs_data *dbs_data) | |||
37 | return dbs_data->cdata->attr_group_gov_sys; | 36 | return dbs_data->cdata->attr_group_gov_sys; |
38 | } | 37 | } |
39 | 38 | ||
40 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | ||
41 | { | ||
42 | u64 idle_time; | ||
43 | u64 cur_wall_time; | ||
44 | u64 busy_time; | ||
45 | |||
46 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | ||
47 | |||
48 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; | ||
49 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; | ||
50 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; | ||
51 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; | ||
52 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
53 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
54 | |||
55 | idle_time = cur_wall_time - busy_time; | ||
56 | if (wall) | ||
57 | *wall = cputime_to_usecs(cur_wall_time); | ||
58 | |||
59 | return cputime_to_usecs(idle_time); | ||
60 | } | ||
61 | |||
62 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) | ||
63 | { | ||
64 | u64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL); | ||
65 | |||
66 | if (idle_time == -1ULL) | ||
67 | return get_cpu_idle_time_jiffy(cpu, wall); | ||
68 | else if (!io_busy) | ||
69 | idle_time += get_cpu_iowait_time_us(cpu, wall); | ||
70 | |||
71 | return idle_time; | ||
72 | } | ||
73 | EXPORT_SYMBOL_GPL(get_cpu_idle_time); | ||
74 | |||
75 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) | 39 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu) |
76 | { | 40 | { |
77 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); | 41 | struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); |
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h index e16a96130cb3..e7bbf767380d 100644 --- a/drivers/cpufreq/cpufreq_governor.h +++ b/drivers/cpufreq/cpufreq_governor.h | |||
@@ -256,7 +256,6 @@ static ssize_t show_sampling_rate_min_gov_pol \ | |||
256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ | 256 | return sprintf(buf, "%u\n", dbs_data->min_sampling_rate); \ |
257 | } | 257 | } |
258 | 258 | ||
259 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
260 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); | 259 | void dbs_check_cpu(struct dbs_data *dbs_data, int cpu); |
261 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, | 260 | bool need_load_eval(struct cpu_dbs_common_info *cdbs, |
262 | unsigned int sampling_rate); | 261 | unsigned int sampling_rate); |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index dd1a5d41357b..fbf392aaa02e 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
@@ -337,6 +337,7 @@ const char *cpufreq_get_current_driver(void); | |||
337 | /********************************************************************* | 337 | /********************************************************************* |
338 | * CPUFREQ 2.6. INTERFACE * | 338 | * CPUFREQ 2.6. INTERFACE * |
339 | *********************************************************************/ | 339 | *********************************************************************/ |
340 | u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); | ||
340 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); | 341 | int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu); |
341 | int cpufreq_update_policy(unsigned int cpu); | 342 | int cpufreq_update_policy(unsigned int cpu); |
342 | bool have_governor_per_policy(void); | 343 | bool have_governor_per_policy(void); |