76
76
static unsigned int dbs_enable; /* number of CPUs using this policy */
79
* dbs_mutex protects data in dbs_tuners_ins from concurrent changes on
80
* different CPUs. It protects dbs_enable in governor start/stop.
79
* dbs_mutex protects dbs_enable in governor start/stop.
82
81
static DEFINE_MUTEX(dbs_mutex);
84
static struct workqueue_struct *kconservative_wq;
86
83
static struct dbs_tuners {
87
84
unsigned int sampling_rate;
88
85
unsigned int sampling_down_factor;
119
116
*wall = (cputime64_t)jiffies_to_usecs(cur_wall_time);
121
return (cputime64_t)jiffies_to_usecs(idle_time);;
118
return (cputime64_t)jiffies_to_usecs(idle_time);
124
121
static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
166
163
/************************** sysfs interface ************************/
167
static ssize_t show_sampling_rate_max(struct kobject *kobj,
168
struct attribute *attr, char *buf)
170
printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
171
"sysfs file is deprecated - used by: %s\n", current->comm);
172
return sprintf(buf, "%u\n", -1U);
175
164
static ssize_t show_sampling_rate_min(struct kobject *kobj,
176
165
struct attribute *attr, char *buf)
178
167
return sprintf(buf, "%u\n", min_sampling_rate);
181
define_one_global_ro(sampling_rate_max);
182
170
define_one_global_ro(sampling_rate_min);
184
172
/* cpufreq_conservative Governor Tunables */
195
183
show_one(ignore_nice_load, ignore_nice);
196
184
show_one(freq_step, freq_step);
198
/*** delete after deprecation time ***/
199
#define DEPRECATION_MSG(file_name) \
200
printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
201
"interface is deprecated - " #file_name "\n");
203
#define show_one_old(file_name) \
204
static ssize_t show_##file_name##_old \
205
(struct cpufreq_policy *unused, char *buf) \
207
printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
208
"interface is deprecated - " #file_name "\n"); \
209
return show_##file_name(NULL, NULL, buf); \
211
show_one_old(sampling_rate);
212
show_one_old(sampling_down_factor);
213
show_one_old(up_threshold);
214
show_one_old(down_threshold);
215
show_one_old(ignore_nice_load);
216
show_one_old(freq_step);
217
show_one_old(sampling_rate_min);
218
show_one_old(sampling_rate_max);
220
cpufreq_freq_attr_ro_old(sampling_rate_min);
221
cpufreq_freq_attr_ro_old(sampling_rate_max);
223
/*** delete after deprecation time ***/
225
186
static ssize_t store_sampling_down_factor(struct kobject *a,
226
187
struct attribute *b,
227
188
const char *buf, size_t count)
265
220
ret = sscanf(buf, "%u", &input);
267
mutex_lock(&dbs_mutex);
268
222
if (ret != 1 || input > 100 ||
269
input <= dbs_tuners_ins.down_threshold) {
270
mutex_unlock(&dbs_mutex);
223
input <= dbs_tuners_ins.down_threshold)
274
226
dbs_tuners_ins.up_threshold = input;
275
mutex_unlock(&dbs_mutex);
285
235
ret = sscanf(buf, "%u", &input);
287
mutex_lock(&dbs_mutex);
288
237
/* cannot be lower than 11 otherwise freq will not fall */
289
238
if (ret != 1 || input < 11 || input > 100 ||
290
input >= dbs_tuners_ins.up_threshold) {
291
mutex_unlock(&dbs_mutex);
239
input >= dbs_tuners_ins.up_threshold)
295
242
dbs_tuners_ins.down_threshold = input;
296
mutex_unlock(&dbs_mutex);
316
mutex_lock(&dbs_mutex);
317
if (input == dbs_tuners_ins.ignore_nice) { /* nothing to do */
318
mutex_unlock(&dbs_mutex);
261
if (input == dbs_tuners_ins.ignore_nice) /* nothing to do */
321
264
dbs_tuners_ins.ignore_nice = input;
323
266
/* we need to re-evaluate prev_cpu_idle */
350
291
/* no need to test here if freq_step is zero as the user might actually
351
292
* want this, they would be crazy though :) */
352
mutex_lock(&dbs_mutex);
353
293
dbs_tuners_ins.freq_step = input;
354
mutex_unlock(&dbs_mutex);
380
317
.name = "conservative",
383
/*** delete after deprecation time ***/
385
#define write_one_old(file_name) \
386
static ssize_t store_##file_name##_old \
387
(struct cpufreq_policy *unused, const char *buf, size_t count) \
389
printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \
390
"interface is deprecated - " #file_name "\n"); \
391
return store_##file_name(NULL, NULL, buf, count); \
393
write_one_old(sampling_rate);
394
write_one_old(sampling_down_factor);
395
write_one_old(up_threshold);
396
write_one_old(down_threshold);
397
write_one_old(ignore_nice_load);
398
write_one_old(freq_step);
400
cpufreq_freq_attr_rw_old(sampling_rate);
401
cpufreq_freq_attr_rw_old(sampling_down_factor);
402
cpufreq_freq_attr_rw_old(up_threshold);
403
cpufreq_freq_attr_rw_old(down_threshold);
404
cpufreq_freq_attr_rw_old(ignore_nice_load);
405
cpufreq_freq_attr_rw_old(freq_step);
407
static struct attribute *dbs_attributes_old[] = {
408
&sampling_rate_max_old.attr,
409
&sampling_rate_min_old.attr,
410
&sampling_rate_old.attr,
411
&sampling_down_factor_old.attr,
412
&up_threshold_old.attr,
413
&down_threshold_old.attr,
414
&ignore_nice_load_old.attr,
419
static struct attribute_group dbs_attr_group_old = {
420
.attrs = dbs_attributes_old,
421
.name = "conservative",
424
/*** delete after deprecation time ***/
426
320
/************************** sysfs end ************************/
428
322
static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
561
455
dbs_check_cpu(dbs_info);
563
queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay);
457
schedule_delayed_work_on(cpu, &dbs_info->work, delay);
564
458
mutex_unlock(&dbs_info->timer_mutex);
573
467
dbs_info->enable = 1;
574
468
INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
575
queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
469
schedule_delayed_work_on(dbs_info->cpu, &dbs_info->work, delay);
579
472
static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
600
493
mutex_lock(&dbs_mutex);
602
rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old);
604
mutex_unlock(&dbs_mutex);
608
495
for_each_cpu(j, policy->cpus) {
609
496
struct cpu_dbs_info_s *j_dbs_info;
610
497
j_dbs_info = &per_cpu(cs_cpu_dbs_info, j);
717
603
static int __init cpufreq_gov_dbs_init(void)
721
kconservative_wq = create_workqueue("kconservative");
722
if (!kconservative_wq) {
723
printk(KERN_ERR "Creation of kconservative failed\n");
727
err = cpufreq_register_governor(&cpufreq_gov_conservative);
729
destroy_workqueue(kconservative_wq);
605
return cpufreq_register_governor(&cpufreq_gov_conservative);
734
608
static void __exit cpufreq_gov_dbs_exit(void)
736
610
cpufreq_unregister_governor(&cpufreq_gov_conservative);
737
destroy_workqueue(kconservative_wq);