~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/cpufreq/cpufreq_conservative.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
static unsigned int dbs_enable; /* number of CPUs using this policy */
77
77
 
78
78
/*
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.
81
80
 */
82
81
static DEFINE_MUTEX(dbs_mutex);
83
82
 
84
 
static struct workqueue_struct  *kconservative_wq;
85
 
 
86
83
static struct dbs_tuners {
87
84
        unsigned int sampling_rate;
88
85
        unsigned int sampling_down_factor;
118
115
        if (wall)
119
116
                *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time);
120
117
 
121
 
        return (cputime64_t)jiffies_to_usecs(idle_time);;
 
118
        return (cputime64_t)jiffies_to_usecs(idle_time);
122
119
}
123
120
 
124
121
static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
164
161
};
165
162
 
166
163
/************************** sysfs interface ************************/
167
 
static ssize_t show_sampling_rate_max(struct kobject *kobj,
168
 
                                      struct attribute *attr, char *buf)
169
 
{
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);
173
 
}
174
 
 
175
164
static ssize_t show_sampling_rate_min(struct kobject *kobj,
176
165
                                      struct attribute *attr, char *buf)
177
166
{
178
167
        return sprintf(buf, "%u\n", min_sampling_rate);
179
168
}
180
169
 
181
 
define_one_global_ro(sampling_rate_max);
182
170
define_one_global_ro(sampling_rate_min);
183
171
 
184
172
/* cpufreq_conservative Governor Tunables */
195
183
show_one(ignore_nice_load, ignore_nice);
196
184
show_one(freq_step, freq_step);
197
185
 
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");
202
 
 
203
 
#define show_one_old(file_name)                                         \
204
 
static ssize_t show_##file_name##_old                                   \
205
 
(struct cpufreq_policy *unused, char *buf)                              \
206
 
{                                                                       \
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);                       \
210
 
}
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);
219
 
 
220
 
cpufreq_freq_attr_ro_old(sampling_rate_min);
221
 
cpufreq_freq_attr_ro_old(sampling_rate_max);
222
 
 
223
 
/*** delete after deprecation time ***/
224
 
 
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)
233
194
        if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
234
195
                return -EINVAL;
235
196
 
236
 
        mutex_lock(&dbs_mutex);
237
197
        dbs_tuners_ins.sampling_down_factor = input;
238
 
        mutex_unlock(&dbs_mutex);
239
 
 
240
198
        return count;
241
199
}
242
200
 
250
208
        if (ret != 1)
251
209
                return -EINVAL;
252
210
 
253
 
        mutex_lock(&dbs_mutex);
254
211
        dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
255
 
        mutex_unlock(&dbs_mutex);
256
 
 
257
212
        return count;
258
213
}
259
214
 
264
219
        int ret;
265
220
        ret = sscanf(buf, "%u", &input);
266
221
 
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)
271
224
                return -EINVAL;
272
 
        }
273
225
 
274
226
        dbs_tuners_ins.up_threshold = input;
275
 
        mutex_unlock(&dbs_mutex);
276
 
 
277
227
        return count;
278
228
}
279
229
 
284
234
        int ret;
285
235
        ret = sscanf(buf, "%u", &input);
286
236
 
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)
292
240
                return -EINVAL;
293
 
        }
294
241
 
295
242
        dbs_tuners_ins.down_threshold = input;
296
 
        mutex_unlock(&dbs_mutex);
297
 
 
298
243
        return count;
299
244
}
300
245
 
313
258
        if (input > 1)
314
259
                input = 1;
315
260
 
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 */
319
262
                return count;
320
 
        }
 
263
 
321
264
        dbs_tuners_ins.ignore_nice = input;
322
265
 
323
266
        /* we need to re-evaluate prev_cpu_idle */
329
272
                if (dbs_tuners_ins.ignore_nice)
330
273
                        dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
331
274
        }
332
 
        mutex_unlock(&dbs_mutex);
333
 
 
334
275
        return count;
335
276
}
336
277
 
349
290
 
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);
355
 
 
356
294
        return count;
357
295
}
358
296
 
364
302
define_one_global_rw(freq_step);
365
303
 
366
304
static struct attribute *dbs_attributes[] = {
367
 
        &sampling_rate_max.attr,
368
305
        &sampling_rate_min.attr,
369
306
        &sampling_rate.attr,
370
307
        &sampling_down_factor.attr,
380
317
        .name = "conservative",
381
318
};
382
319
 
383
 
/*** delete after deprecation time ***/
384
 
 
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)          \
388
 
{                                                                       \
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);               \
392
 
}
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);
399
 
 
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);
406
 
 
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,
415
 
        &freq_step_old.attr,
416
 
        NULL
417
 
};
418
 
 
419
 
static struct attribute_group dbs_attr_group_old = {
420
 
        .attrs = dbs_attributes_old,
421
 
        .name = "conservative",
422
 
};
423
 
 
424
 
/*** delete after deprecation time ***/
425
 
 
426
320
/************************** sysfs end ************************/
427
321
 
428
322
static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
560
454
 
561
455
        dbs_check_cpu(dbs_info);
562
456
 
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);
565
459
}
566
460
 
572
466
 
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,
576
 
                                delay);
 
469
        schedule_delayed_work_on(dbs_info->cpu, &dbs_info->work, delay);
577
470
}
578
471
 
579
472
static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
599
492
 
600
493
                mutex_lock(&dbs_mutex);
601
494
 
602
 
                rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old);
603
 
                if (rc) {
604
 
                        mutex_unlock(&dbs_mutex);
605
 
                        return rc;
606
 
                }
607
 
 
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);
667
554
                dbs_timer_exit(this_dbs_info);
668
555
 
669
556
                mutex_lock(&dbs_mutex);
670
 
                sysfs_remove_group(&policy->kobj, &dbs_attr_group_old);
671
557
                dbs_enable--;
672
558
                mutex_destroy(&this_dbs_info->timer_mutex);
673
559
 
716
602
 
717
603
static int __init cpufreq_gov_dbs_init(void)
718
604
{
719
 
        int err;
720
 
 
721
 
        kconservative_wq = create_workqueue("kconservative");
722
 
        if (!kconservative_wq) {
723
 
                printk(KERN_ERR "Creation of kconservative failed\n");
724
 
                return -EFAULT;
725
 
        }
726
 
 
727
 
        err = cpufreq_register_governor(&cpufreq_gov_conservative);
728
 
        if (err)
729
 
                destroy_workqueue(kconservative_wq);
730
 
 
731
 
        return err;
 
605
        return cpufreq_register_governor(&cpufreq_gov_conservative);
732
606
}
733
607
 
734
608
static void __exit cpufreq_gov_dbs_exit(void)
735
609
{
736
610
        cpufreq_unregister_governor(&cpufreq_gov_conservative);
737
 
        destroy_workqueue(kconservative_wq);
738
611
}
739
612
 
740
613