cpufreq_conservative.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /*
  2. * drivers/cpufreq/cpufreq_conservative.c
  3. *
  4. * Copyright (C) 2001 Russell King
  5. * (C) 2003 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>.
  6. * Jun Nakajima <jun.nakajima@intel.com>
  7. * (C) 2009 Alexander Clouter <alex@digriz.org.uk>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/cpufreq.h>
  17. #include <linux/cpu.h>
  18. #include <linux/jiffies.h>
  19. #include <linux/kernel_stat.h>
  20. #include <linux/mutex.h>
  21. #include <linux/hrtimer.h>
  22. #include <linux/tick.h>
  23. #include <linux/ktime.h>
  24. #include <linux/sched.h>
  25. /*
  26. * dbs is used in this file as a shortform for demandbased switching
  27. * It helps to keep variable names smaller, simpler
  28. */
  29. #define DEF_FREQUENCY_UP_THRESHOLD (80)
  30. #define DEF_FREQUENCY_DOWN_THRESHOLD (20)
  31. /*
  32. * The polling frequency of this governor depends on the capability of
  33. * the processor. Default polling frequency is 1000 times the transition
  34. * latency of the processor. The governor will work on any processor with
  35. * transition latency <= 10mS, using appropriate sampling
  36. * rate.
  37. * For CPUs with transition latency > 10mS (mostly drivers with CPUFREQ_ETERNAL)
  38. * this governor will not work.
  39. * All times here are in uS.
  40. */
  41. #define MIN_SAMPLING_RATE_RATIO (2)
  42. static unsigned int min_sampling_rate;
  43. #define LATENCY_MULTIPLIER (1000)
  44. #define MIN_LATENCY_MULTIPLIER (100)
  45. #define DEF_SAMPLING_DOWN_FACTOR (1)
  46. #define MAX_SAMPLING_DOWN_FACTOR (10)
  47. #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
  48. static void do_dbs_timer(struct work_struct *work);
  49. struct cpu_dbs_info_s {
  50. cputime64_t prev_cpu_idle;
  51. cputime64_t prev_cpu_wall;
  52. cputime64_t prev_cpu_nice;
  53. struct cpufreq_policy *cur_policy;
  54. struct delayed_work work;
  55. unsigned int down_skip;
  56. unsigned int requested_freq;
  57. int cpu;
  58. /*
  59. * percpu mutex that serializes governor limit change with
  60. * do_dbs_timer invocation. We do not want do_dbs_timer to run
  61. * when user is changing the governor or limits.
  62. */
  63. struct mutex timer_mutex;
  64. };
  65. static DEFINE_PER_CPU(struct cpu_dbs_info_s, cpu_dbs_info);
  66. static unsigned int dbs_enable; /* number of CPUs using this policy */
  67. /*
  68. * dbs_mutex protects data in dbs_tuners_ins from concurrent changes on
  69. * different CPUs. It protects dbs_enable in governor start/stop.
  70. */
  71. static DEFINE_MUTEX(dbs_mutex);
  72. static struct workqueue_struct *kconservative_wq;
  73. static struct dbs_tuners {
  74. unsigned int sampling_rate;
  75. unsigned int sampling_down_factor;
  76. unsigned int up_threshold;
  77. unsigned int down_threshold;
  78. unsigned int ignore_nice;
  79. unsigned int freq_step;
  80. } dbs_tuners_ins = {
  81. .up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
  82. .down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD,
  83. .sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
  84. .ignore_nice = 0,
  85. .freq_step = 5,
  86. };
  87. static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
  88. cputime64_t *wall)
  89. {
  90. cputime64_t idle_time;
  91. cputime64_t cur_wall_time;
  92. cputime64_t busy_time;
  93. cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
  94. busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user,
  95. kstat_cpu(cpu).cpustat.system);
  96. busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq);
  97. busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq);
  98. busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal);
  99. busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice);
  100. idle_time = cputime64_sub(cur_wall_time, busy_time);
  101. if (wall)
  102. *wall = cur_wall_time;
  103. return idle_time;
  104. }
  105. static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
  106. {
  107. u64 idle_time = get_cpu_idle_time_us(cpu, wall);
  108. if (idle_time == -1ULL)
  109. return get_cpu_idle_time_jiffy(cpu, wall);
  110. return idle_time;
  111. }
  112. /* keep track of frequency transitions */
  113. static int
  114. dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
  115. void *data)
  116. {
  117. struct cpufreq_freqs *freq = data;
  118. struct cpu_dbs_info_s *this_dbs_info = &per_cpu(cpu_dbs_info,
  119. freq->cpu);
  120. struct cpufreq_policy *policy;
  121. policy = this_dbs_info->cur_policy;
  122. /*
  123. * we only care if our internally tracked freq moves outside
  124. * the 'valid' ranges of freqency available to us otherwise
  125. * we do not change it
  126. */
  127. if (this_dbs_info->requested_freq > policy->max
  128. || this_dbs_info->requested_freq < policy->min)
  129. this_dbs_info->requested_freq = freq->new;
  130. return 0;
  131. }
  132. static struct notifier_block dbs_cpufreq_notifier_block = {
  133. .notifier_call = dbs_cpufreq_notifier
  134. };
  135. /************************** sysfs interface ************************/
  136. static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf)
  137. {
  138. printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max "
  139. "sysfs file is deprecated - used by: %s\n", current->comm);
  140. return sprintf(buf, "%u\n", -1U);
  141. }
  142. static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf)
  143. {
  144. return sprintf(buf, "%u\n", min_sampling_rate);
  145. }
  146. #define define_one_ro(_name) \
  147. static struct freq_attr _name = \
  148. __ATTR(_name, 0444, show_##_name, NULL)
  149. define_one_ro(sampling_rate_max);
  150. define_one_ro(sampling_rate_min);
  151. /* cpufreq_conservative Governor Tunables */
  152. #define show_one(file_name, object) \
  153. static ssize_t show_##file_name \
  154. (struct cpufreq_policy *unused, char *buf) \
  155. { \
  156. return sprintf(buf, "%u\n", dbs_tuners_ins.object); \
  157. }
  158. show_one(sampling_rate, sampling_rate);
  159. show_one(sampling_down_factor, sampling_down_factor);
  160. show_one(up_threshold, up_threshold);
  161. show_one(down_threshold, down_threshold);
  162. show_one(ignore_nice_load, ignore_nice);
  163. show_one(freq_step, freq_step);
  164. static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
  165. const char *buf, size_t count)
  166. {
  167. unsigned int input;
  168. int ret;
  169. ret = sscanf(buf, "%u", &input);
  170. if (ret != 1 || input > MAX_SAMPLING_DOWN_FACTOR || input < 1)
  171. return -EINVAL;
  172. mutex_lock(&dbs_mutex);
  173. dbs_tuners_ins.sampling_down_factor = input;
  174. mutex_unlock(&dbs_mutex);
  175. return count;
  176. }
  177. static ssize_t store_sampling_rate(struct cpufreq_policy *unused,
  178. const char *buf, size_t count)
  179. {
  180. unsigned int input;
  181. int ret;
  182. ret = sscanf(buf, "%u", &input);
  183. if (ret != 1)
  184. return -EINVAL;
  185. mutex_lock(&dbs_mutex);
  186. dbs_tuners_ins.sampling_rate = max(input, min_sampling_rate);
  187. mutex_unlock(&dbs_mutex);
  188. return count;
  189. }
  190. static ssize_t store_up_threshold(struct cpufreq_policy *unused,
  191. const char *buf, size_t count)
  192. {
  193. unsigned int input;
  194. int ret;
  195. ret = sscanf(buf, "%u", &input);
  196. mutex_lock(&dbs_mutex);
  197. if (ret != 1 || input > 100 ||
  198. input <= dbs_tuners_ins.down_threshold) {
  199. mutex_unlock(&dbs_mutex);
  200. return -EINVAL;
  201. }
  202. dbs_tuners_ins.up_threshold = input;
  203. mutex_unlock(&dbs_mutex);
  204. return count;
  205. }
  206. static ssize_t store_down_threshold(struct cpufreq_policy *unused,
  207. const char *buf, size_t count)
  208. {
  209. unsigned int input;
  210. int ret;
  211. ret = sscanf(buf, "%u", &input);
  212. mutex_lock(&dbs_mutex);
  213. /* cannot be lower than 11 otherwise freq will not fall */
  214. if (ret != 1 || input < 11 || input > 100 ||
  215. input >= dbs_tuners_ins.up_threshold) {
  216. mutex_unlock(&dbs_mutex);
  217. return -EINVAL;
  218. }
  219. dbs_tuners_ins.down_threshold = input;
  220. mutex_unlock(&dbs_mutex);
  221. return count;
  222. }
  223. static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
  224. const char *buf, size_t count)
  225. {
  226. unsigned int input;
  227. int ret;
  228. unsigned int j;
  229. ret = sscanf(buf, "%u", &input);
  230. if (ret != 1)
  231. return -EINVAL;
  232. if (input > 1)
  233. input = 1;
  234. mutex_lock(&dbs_mutex);
  235. if (input == dbs_tuners_ins.ignore_nice) { /* nothing to do */
  236. mutex_unlock(&dbs_mutex);
  237. return count;
  238. }
  239. dbs_tuners_ins.ignore_nice = input;
  240. /* we need to re-evaluate prev_cpu_idle */
  241. for_each_online_cpu(j) {
  242. struct cpu_dbs_info_s *dbs_info;
  243. dbs_info = &per_cpu(cpu_dbs_info, j);
  244. dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
  245. &dbs_info->prev_cpu_wall);
  246. if (dbs_tuners_ins.ignore_nice)
  247. dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
  248. }
  249. mutex_unlock(&dbs_mutex);
  250. return count;
  251. }
  252. static ssize_t store_freq_step(struct cpufreq_policy *policy,
  253. const char *buf, size_t count)
  254. {
  255. unsigned int input;
  256. int ret;
  257. ret = sscanf(buf, "%u", &input);
  258. if (ret != 1)
  259. return -EINVAL;
  260. if (input > 100)
  261. input = 100;
  262. /* no need to test here if freq_step is zero as the user might actually
  263. * want this, they would be crazy though :) */
  264. mutex_lock(&dbs_mutex);
  265. dbs_tuners_ins.freq_step = input;
  266. mutex_unlock(&dbs_mutex);
  267. return count;
  268. }
  269. #define define_one_rw(_name) \
  270. static struct freq_attr _name = \
  271. __ATTR(_name, 0644, show_##_name, store_##_name)
  272. define_one_rw(sampling_rate);
  273. define_one_rw(sampling_down_factor);
  274. define_one_rw(up_threshold);
  275. define_one_rw(down_threshold);
  276. define_one_rw(ignore_nice_load);
  277. define_one_rw(freq_step);
  278. static struct attribute *dbs_attributes[] = {
  279. &sampling_rate_max.attr,
  280. &sampling_rate_min.attr,
  281. &sampling_rate.attr,
  282. &sampling_down_factor.attr,
  283. &up_threshold.attr,
  284. &down_threshold.attr,
  285. &ignore_nice_load.attr,
  286. &freq_step.attr,
  287. NULL
  288. };
  289. static struct attribute_group dbs_attr_group = {
  290. .attrs = dbs_attributes,
  291. .name = "conservative",
  292. };
  293. /************************** sysfs end ************************/
  294. static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
  295. {
  296. unsigned int load = 0;
  297. unsigned int freq_target;
  298. struct cpufreq_policy *policy;
  299. unsigned int j;
  300. policy = this_dbs_info->cur_policy;
  301. /*
  302. * Every sampling_rate, we check, if current idle time is less
  303. * than 20% (default), then we try to increase frequency
  304. * Every sampling_rate*sampling_down_factor, we check, if current
  305. * idle time is more than 80%, then we try to decrease frequency
  306. *
  307. * Any frequency increase takes it to the maximum frequency.
  308. * Frequency reduction happens at minimum steps of
  309. * 5% (default) of maximum frequency
  310. */
  311. /* Get Absolute Load */
  312. for_each_cpu(j, policy->cpus) {
  313. struct cpu_dbs_info_s *j_dbs_info;
  314. cputime64_t cur_wall_time, cur_idle_time;
  315. unsigned int idle_time, wall_time;
  316. j_dbs_info = &per_cpu(cpu_dbs_info, j);
  317. cur_idle_time = get_cpu_idle_time(j, &cur_wall_time);
  318. wall_time = (unsigned int) cputime64_sub(cur_wall_time,
  319. j_dbs_info->prev_cpu_wall);
  320. j_dbs_info->prev_cpu_wall = cur_wall_time;
  321. idle_time = (unsigned int) cputime64_sub(cur_idle_time,
  322. j_dbs_info->prev_cpu_idle);
  323. j_dbs_info->prev_cpu_idle = cur_idle_time;
  324. if (dbs_tuners_ins.ignore_nice) {
  325. cputime64_t cur_nice;
  326. unsigned long cur_nice_jiffies;
  327. cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice,
  328. j_dbs_info->prev_cpu_nice);
  329. /*
  330. * Assumption: nice time between sampling periods will
  331. * be less than 2^32 jiffies for 32 bit sys
  332. */
  333. cur_nice_jiffies = (unsigned long)
  334. cputime64_to_jiffies64(cur_nice);
  335. j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
  336. idle_time += jiffies_to_usecs(cur_nice_jiffies);
  337. }
  338. if (unlikely(!wall_time || wall_time < idle_time))
  339. continue;
  340. load = 100 * (wall_time - idle_time) / wall_time;
  341. }
  342. /*
  343. * break out if we 'cannot' reduce the speed as the user might
  344. * want freq_step to be zero
  345. */
  346. if (dbs_tuners_ins.freq_step == 0)
  347. return;
  348. /* Check for frequency increase */
  349. if (load > dbs_tuners_ins.up_threshold) {
  350. this_dbs_info->down_skip = 0;
  351. /* if we are already at full speed then break out early */
  352. if (this_dbs_info->requested_freq == policy->max)
  353. return;
  354. freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
  355. /* max freq cannot be less than 100. But who knows.... */
  356. if (unlikely(freq_target == 0))
  357. freq_target = 5;
  358. this_dbs_info->requested_freq += freq_target;
  359. if (this_dbs_info->requested_freq > policy->max)
  360. this_dbs_info->requested_freq = policy->max;
  361. __cpufreq_driver_target(policy, this_dbs_info->requested_freq,
  362. CPUFREQ_RELATION_H);
  363. return;
  364. }
  365. /*
  366. * The optimal frequency is the frequency that is the lowest that
  367. * can support the current CPU usage without triggering the up
  368. * policy. To be safe, we focus 10 points under the threshold.
  369. */
  370. if (load < (dbs_tuners_ins.down_threshold - 10)) {
  371. freq_target = (dbs_tuners_ins.freq_step * policy->max) / 100;
  372. this_dbs_info->requested_freq -= freq_target;
  373. if (this_dbs_info->requested_freq < policy->min)
  374. this_dbs_info->requested_freq = policy->min;
  375. /*
  376. * if we cannot reduce the frequency anymore, break out early
  377. */
  378. if (policy->cur == policy->min)
  379. return;
  380. __cpufreq_driver_target(policy, this_dbs_info->requested_freq,
  381. CPUFREQ_RELATION_H);
  382. return;
  383. }
  384. }
  385. static void do_dbs_timer(struct work_struct *work)
  386. {
  387. struct cpu_dbs_info_s *dbs_info =
  388. container_of(work, struct cpu_dbs_info_s, work.work);
  389. unsigned int cpu = dbs_info->cpu;
  390. /* We want all CPUs to do sampling nearly on same jiffy */
  391. int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
  392. delay -= jiffies % delay;
  393. mutex_lock(&dbs_info->timer_mutex);
  394. dbs_check_cpu(dbs_info);
  395. queue_delayed_work_on(cpu, kconservative_wq, &dbs_info->work, delay);
  396. mutex_unlock(&dbs_info->timer_mutex);
  397. }
  398. static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
  399. {
  400. /* We want all CPUs to do sampling nearly on same jiffy */
  401. int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
  402. delay -= jiffies % delay;
  403. INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
  404. queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
  405. delay);
  406. }
  407. static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
  408. {
  409. cancel_delayed_work_sync(&dbs_info->work);
  410. }
  411. static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
  412. unsigned int event)
  413. {
  414. unsigned int cpu = policy->cpu;
  415. struct cpu_dbs_info_s *this_dbs_info;
  416. unsigned int j;
  417. int rc;
  418. this_dbs_info = &per_cpu(cpu_dbs_info, cpu);
  419. switch (event) {
  420. case CPUFREQ_GOV_START:
  421. if ((!cpu_online(cpu)) || (!policy->cur))
  422. return -EINVAL;
  423. mutex_lock(&dbs_mutex);
  424. rc = sysfs_create_group(&policy->kobj, &dbs_attr_group);
  425. if (rc) {
  426. mutex_unlock(&dbs_mutex);
  427. return rc;
  428. }
  429. for_each_cpu(j, policy->cpus) {
  430. struct cpu_dbs_info_s *j_dbs_info;
  431. j_dbs_info = &per_cpu(cpu_dbs_info, j);
  432. j_dbs_info->cur_policy = policy;
  433. j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
  434. &j_dbs_info->prev_cpu_wall);
  435. if (dbs_tuners_ins.ignore_nice) {
  436. j_dbs_info->prev_cpu_nice =
  437. kstat_cpu(j).cpustat.nice;
  438. }
  439. }
  440. this_dbs_info->down_skip = 0;
  441. this_dbs_info->requested_freq = policy->cur;
  442. mutex_init(&this_dbs_info->timer_mutex);
  443. dbs_enable++;
  444. /*
  445. * Start the timerschedule work, when this governor
  446. * is used for first time
  447. */
  448. if (dbs_enable == 1) {
  449. unsigned int latency;
  450. /* policy latency is in nS. Convert it to uS first */
  451. latency = policy->cpuinfo.transition_latency / 1000;
  452. if (latency == 0)
  453. latency = 1;
  454. /*
  455. * conservative does not implement micro like ondemand
  456. * governor, thus we are bound to jiffes/HZ
  457. */
  458. min_sampling_rate =
  459. MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
  460. /* Bring kernel and HW constraints together */
  461. min_sampling_rate = max(min_sampling_rate,
  462. MIN_LATENCY_MULTIPLIER * latency);
  463. dbs_tuners_ins.sampling_rate =
  464. max(min_sampling_rate,
  465. latency * LATENCY_MULTIPLIER);
  466. cpufreq_register_notifier(
  467. &dbs_cpufreq_notifier_block,
  468. CPUFREQ_TRANSITION_NOTIFIER);
  469. }
  470. mutex_unlock(&dbs_mutex);
  471. dbs_timer_init(this_dbs_info);
  472. break;
  473. case CPUFREQ_GOV_STOP:
  474. dbs_timer_exit(this_dbs_info);
  475. mutex_lock(&dbs_mutex);
  476. sysfs_remove_group(&policy->kobj, &dbs_attr_group);
  477. dbs_enable--;
  478. mutex_destroy(&this_dbs_info->timer_mutex);
  479. /*
  480. * Stop the timerschedule work, when this governor
  481. * is used for first time
  482. */
  483. if (dbs_enable == 0)
  484. cpufreq_unregister_notifier(
  485. &dbs_cpufreq_notifier_block,
  486. CPUFREQ_TRANSITION_NOTIFIER);
  487. mutex_unlock(&dbs_mutex);
  488. break;
  489. case CPUFREQ_GOV_LIMITS:
  490. mutex_lock(&this_dbs_info->timer_mutex);
  491. if (policy->max < this_dbs_info->cur_policy->cur)
  492. __cpufreq_driver_target(
  493. this_dbs_info->cur_policy,
  494. policy->max, CPUFREQ_RELATION_H);
  495. else if (policy->min > this_dbs_info->cur_policy->cur)
  496. __cpufreq_driver_target(
  497. this_dbs_info->cur_policy,
  498. policy->min, CPUFREQ_RELATION_L);
  499. mutex_unlock(&this_dbs_info->timer_mutex);
  500. break;
  501. }
  502. return 0;
  503. }
  504. #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
  505. static
  506. #endif
  507. struct cpufreq_governor cpufreq_gov_conservative = {
  508. .name = "conservative",
  509. .governor = cpufreq_governor_dbs,
  510. .max_transition_latency = TRANSITION_LATENCY_LIMIT,
  511. .owner = THIS_MODULE,
  512. };
  513. static int __init cpufreq_gov_dbs_init(void)
  514. {
  515. int err;
  516. kconservative_wq = create_workqueue("kconservative");
  517. if (!kconservative_wq) {
  518. printk(KERN_ERR "Creation of kconservative failed\n");
  519. return -EFAULT;
  520. }
  521. err = cpufreq_register_governor(&cpufreq_gov_conservative);
  522. if (err)
  523. destroy_workqueue(kconservative_wq);
  524. return err;
  525. }
  526. static void __exit cpufreq_gov_dbs_exit(void)
  527. {
  528. cpufreq_unregister_governor(&cpufreq_gov_conservative);
  529. destroy_workqueue(kconservative_wq);
  530. }
  531. MODULE_AUTHOR("Alexander Clouter <alex@digriz.org.uk>");
  532. MODULE_DESCRIPTION("'cpufreq_conservative' - A dynamic cpufreq governor for "
  533. "Low Latency Frequency Transition capable processors "
  534. "optimised for use in a battery environment");
  535. MODULE_LICENSE("GPL");
  536. #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
  537. fs_initcall(cpufreq_gov_dbs_init);
  538. #else
  539. module_init(cpufreq_gov_dbs_init);
  540. #endif
  541. module_exit(cpufreq_gov_dbs_exit);