aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_conservative.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/cpufreq/cpufreq_conservative.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/cpufreq/cpufreq_conservative.c')
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c137
1 files changed, 116 insertions, 21 deletions
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index c7b081b839ff..3a147874a465 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -164,20 +164,22 @@ static struct notifier_block dbs_cpufreq_notifier_block = {
164}; 164};
165 165
166/************************** sysfs interface ************************/ 166/************************** sysfs interface ************************/
167static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) 167static ssize_t show_sampling_rate_max(struct kobject *kobj,
168 struct attribute *attr, char *buf)
168{ 169{
169 printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max " 170 printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
170 "sysfs file is deprecated - used by: %s\n", current->comm); 171 "sysfs file is deprecated - used by: %s\n", current->comm);
171 return sprintf(buf, "%u\n", -1U); 172 return sprintf(buf, "%u\n", -1U);
172} 173}
173 174
174static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 175static ssize_t show_sampling_rate_min(struct kobject *kobj,
176 struct attribute *attr, char *buf)
175{ 177{
176 return sprintf(buf, "%u\n", min_sampling_rate); 178 return sprintf(buf, "%u\n", min_sampling_rate);
177} 179}
178 180
179#define define_one_ro(_name) \ 181#define define_one_ro(_name) \
180static struct freq_attr _name = \ 182static struct global_attr _name = \
181__ATTR(_name, 0444, show_##_name, NULL) 183__ATTR(_name, 0444, show_##_name, NULL)
182 184
183define_one_ro(sampling_rate_max); 185define_one_ro(sampling_rate_max);
@@ -186,7 +188,7 @@ define_one_ro(sampling_rate_min);
186/* cpufreq_conservative Governor Tunables */ 188/* cpufreq_conservative Governor Tunables */
187#define show_one(file_name, object) \ 189#define show_one(file_name, object) \
188static ssize_t show_##file_name \ 190static ssize_t show_##file_name \
189(struct cpufreq_policy *unused, char *buf) \ 191(struct kobject *kobj, struct attribute *attr, char *buf) \
190{ \ 192{ \
191 return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ 193 return sprintf(buf, "%u\n", dbs_tuners_ins.object); \
192} 194}
@@ -197,8 +199,40 @@ show_one(down_threshold, down_threshold);
197show_one(ignore_nice_load, ignore_nice); 199show_one(ignore_nice_load, ignore_nice);
198show_one(freq_step, freq_step); 200show_one(freq_step, freq_step);
199 201
200static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 202/*** delete after deprecation time ***/
201 const char *buf, size_t count) 203#define DEPRECATION_MSG(file_name) \
204 printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
205 "interface is deprecated - " #file_name "\n");
206
207#define show_one_old(file_name) \
208static ssize_t show_##file_name##_old \
209(struct cpufreq_policy *unused, char *buf) \
210{ \
211 printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
212 "interface is deprecated - " #file_name "\n"); \
213 return show_##file_name(NULL, NULL, buf); \
214}
215show_one_old(sampling_rate);
216show_one_old(sampling_down_factor);
217show_one_old(up_threshold);
218show_one_old(down_threshold);
219show_one_old(ignore_nice_load);
220show_one_old(freq_step);
221show_one_old(sampling_rate_min);
222show_one_old(sampling_rate_max);
223
224#define define_one_ro_old(object, _name) \
225static struct freq_attr object = \
226__ATTR(_name, 0444, show_##_name##_old, NULL)
227
228define_one_ro_old(sampling_rate_min_old, sampling_rate_min);
229define_one_ro_old(sampling_rate_max_old, sampling_rate_max);
230
231/*** delete after deprecation time ***/
232
233static ssize_t store_sampling_down_factor(struct kobject *a,
234 struct attribute *b,
235 const char *buf, size_t count)
202{ 236{
203 unsigned int input; 237 unsigned int input;
204 int ret; 238 int ret;
@@ -214,8 +248,8 @@ static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
214 return count; 248 return count;
215} 249}
216 250
217static ssize_t store_sampling_rate(struct cpufreq_policy *unused, 251static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b,
218 const char *buf, size_t count) 252 const char *buf, size_t count)
219{ 253{
220 unsigned int input; 254 unsigned int input;
221 int ret; 255 int ret;
@@ -231,8 +265,8 @@ static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
231 return count; 265 return count;
232} 266}
233 267
234static ssize_t store_up_threshold(struct cpufreq_policy *unused, 268static ssize_t store_up_threshold(struct kobject *a, struct attribute *b,
235 const char *buf, size_t count) 269 const char *buf, size_t count)
236{ 270{
237 unsigned int input; 271 unsigned int input;
238 int ret; 272 int ret;
@@ -251,8 +285,8 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
251 return count; 285 return count;
252} 286}
253 287
254static ssize_t store_down_threshold(struct cpufreq_policy *unused, 288static ssize_t store_down_threshold(struct kobject *a, struct attribute *b,
255 const char *buf, size_t count) 289 const char *buf, size_t count)
256{ 290{
257 unsigned int input; 291 unsigned int input;
258 int ret; 292 int ret;
@@ -272,8 +306,8 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
272 return count; 306 return count;
273} 307}
274 308
275static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, 309static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b,
276 const char *buf, size_t count) 310 const char *buf, size_t count)
277{ 311{
278 unsigned int input; 312 unsigned int input;
279 int ret; 313 int ret;
@@ -308,8 +342,8 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
308 return count; 342 return count;
309} 343}
310 344
311static ssize_t store_freq_step(struct cpufreq_policy *policy, 345static ssize_t store_freq_step(struct kobject *a, struct attribute *b,
312 const char *buf, size_t count) 346 const char *buf, size_t count)
313{ 347{
314 unsigned int input; 348 unsigned int input;
315 int ret; 349 int ret;
@@ -331,7 +365,7 @@ static ssize_t store_freq_step(struct cpufreq_policy *policy,
331} 365}
332 366
333#define define_one_rw(_name) \ 367#define define_one_rw(_name) \
334static struct freq_attr _name = \ 368static struct global_attr _name = \
335__ATTR(_name, 0644, show_##_name, store_##_name) 369__ATTR(_name, 0644, show_##_name, store_##_name)
336 370
337define_one_rw(sampling_rate); 371define_one_rw(sampling_rate);
@@ -358,11 +392,59 @@ static struct attribute_group dbs_attr_group = {
358 .name = "conservative", 392 .name = "conservative",
359}; 393};
360 394
395/*** delete after deprecation time ***/
396
397#define write_one_old(file_name) \
398static ssize_t store_##file_name##_old \
399(struct cpufreq_policy *unused, const char *buf, size_t count) \
400{ \
401 printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
402 "interface is deprecated - " #file_name "\n"); \
403 return store_##file_name(NULL, NULL, buf, count); \
404}
405write_one_old(sampling_rate);
406write_one_old(sampling_down_factor);
407write_one_old(up_threshold);
408write_one_old(down_threshold);
409write_one_old(ignore_nice_load);
410write_one_old(freq_step);
411
412#define define_one_rw_old(object, _name) \
413static struct freq_attr object = \
414__ATTR(_name, 0644, show_##_name##_old, store_##_name##_old)
415
416define_one_rw_old(sampling_rate_old, sampling_rate);
417define_one_rw_old(sampling_down_factor_old, sampling_down_factor);
418define_one_rw_old(up_threshold_old, up_threshold);
419define_one_rw_old(down_threshold_old, down_threshold);
420define_one_rw_old(ignore_nice_load_old, ignore_nice_load);
421define_one_rw_old(freq_step_old, freq_step);
422
423static struct attribute *dbs_attributes_old[] = {
424 &sampling_rate_max_old.attr,
425 &sampling_rate_min_old.attr,
426 &sampling_rate_old.attr,
427 &sampling_down_factor_old.attr,
428 &up_threshold_old.attr,
429 &down_threshold_old.attr,
430 &ignore_nice_load_old.attr,
431 &freq_step_old.attr,
432 NULL
433};
434
435static struct attribute_group dbs_attr_group_old = {
436 .attrs = dbs_attributes_old,
437 .name = "conservative",
438};
439
440/*** delete after deprecation time ***/
441
361/************************** sysfs end ************************/ 442/************************** sysfs end ************************/
362 443
363static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) 444static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
364{ 445{
365 unsigned int load = 0; 446 unsigned int load = 0;
447 unsigned int max_load = 0;
366 unsigned int freq_target; 448 unsigned int freq_target;
367 449
368 struct cpufreq_policy *policy; 450 struct cpufreq_policy *policy;
@@ -420,6 +502,9 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
420 continue; 502 continue;
421 503
422 load = 100 * (wall_time - idle_time) / wall_time; 504 load = 100 * (wall_time - idle_time) / wall_time;
505
506 if (load > max_load)
507 max_load = load;
423 } 508 }
424 509
425 /* 510 /*
@@ -430,7 +515,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
430 return; 515 return;
431 516
432 /* Check for frequency increase */ 517 /* Check for frequency increase */
433 if (load > dbs_tuners_ins.up_threshold) { 518 if (max_load > dbs_tuners_ins.up_threshold) {
434 this_dbs_info->down_skip = 0; 519 this_dbs_info->down_skip = 0;
435 520
436 /* if we are already at full speed then break out early */ 521 /* if we are already at full speed then break out early */
@@ -457,7 +542,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
457 * can support the current CPU usage without triggering the up 542 * can support the current CPU usage without triggering the up
458 * policy. To be safe, we focus 10 points under the threshold. 543 * policy. To be safe, we focus 10 points under the threshold.
459 */ 544 */
460 if (load < (dbs_tuners_ins.down_threshold - 10)) { 545 if (max_load < (dbs_tuners_ins.down_threshold - 10)) {
461 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100; 546 freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
462 547
463 this_dbs_info->requested_freq -= freq_target; 548 this_dbs_info->requested_freq -= freq_target;
@@ -530,7 +615,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
530 615
531 mutex_lock(&dbs_mutex); 616 mutex_lock(&dbs_mutex);
532 617
533 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); 618 rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old);
534 if (rc) { 619 if (rc) {
535 mutex_unlock(&dbs_mutex); 620 mutex_unlock(&dbs_mutex);
536 return rc; 621 return rc;
@@ -564,6 +649,13 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
564 if (latency == 0) 649 if (latency == 0)
565 latency = 1; 650 latency = 1;
566 651
652 rc = sysfs_create_group(cpufreq_global_kobject,
653 &dbs_attr_group);
654 if (rc) {
655 mutex_unlock(&dbs_mutex);
656 return rc;
657 }
658
567 /* 659 /*
568 * conservative does not implement micro like ondemand 660 * conservative does not implement micro like ondemand
569 * governor, thus we are bound to jiffes/HZ 661 * governor, thus we are bound to jiffes/HZ
@@ -591,7 +683,7 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
591 dbs_timer_exit(this_dbs_info); 683 dbs_timer_exit(this_dbs_info);
592 684
593 mutex_lock(&dbs_mutex); 685 mutex_lock(&dbs_mutex);
594 sysfs_remove_group(&policy->kobj, &dbs_attr_group); 686 sysfs_remove_group(&policy->kobj, &dbs_attr_group_old);
595 dbs_enable--; 687 dbs_enable--;
596 mutex_destroy(&this_dbs_info->timer_mutex); 688 mutex_destroy(&this_dbs_info->timer_mutex);
597 689
@@ -605,6 +697,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
605 CPUFREQ_TRANSITION_NOTIFIER); 697 CPUFREQ_TRANSITION_NOTIFIER);
606 698
607 mutex_unlock(&dbs_mutex); 699 mutex_unlock(&dbs_mutex);
700 if (!dbs_enable)
701 sysfs_remove_group(cpufreq_global_kobject,
702 &dbs_attr_group);
608 703
609 break; 704 break;
610 705