cpufreq_schedutil.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * CPUFreq governor based on scheduler-provided CPU utilization data.
  3. *
  4. * Copyright (C) 2016, Intel Corporation
  5. * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/cpufreq.h>
  13. #include <linux/kthread.h>
  14. #include <uapi/linux/sched/types.h>
  15. #include <linux/slab.h>
  16. #include <trace/events/power.h>
  17. #include "sched.h"
  18. #define SUGOV_KTHREAD_PRIORITY 50
  19. struct sugov_tunables {
  20. struct gov_attr_set attr_set;
  21. unsigned int rate_limit_us;
  22. };
  23. struct sugov_policy {
  24. struct cpufreq_policy *policy;
  25. struct sugov_tunables *tunables;
  26. struct list_head tunables_hook;
  27. raw_spinlock_t update_lock; /* For shared policies */
  28. u64 last_freq_update_time;
  29. s64 freq_update_delay_ns;
  30. unsigned int next_freq;
  31. unsigned int cached_raw_freq;
  32. /* The next fields are only needed if fast switch cannot be used. */
  33. struct irq_work irq_work;
  34. struct kthread_work work;
  35. struct mutex work_lock;
  36. struct kthread_worker worker;
  37. struct task_struct *thread;
  38. bool work_in_progress;
  39. bool need_freq_update;
  40. };
  41. struct sugov_cpu {
  42. struct update_util_data update_util;
  43. struct sugov_policy *sg_policy;
  44. unsigned long iowait_boost;
  45. unsigned long iowait_boost_max;
  46. u64 last_update;
  47. /* The fields below are only needed when sharing a policy. */
  48. unsigned long util;
  49. unsigned long max;
  50. unsigned int flags;
  51. /* The field below is for single-CPU policies only. */
  52. #ifdef CONFIG_NO_HZ_COMMON
  53. unsigned long saved_idle_calls;
  54. #endif
  55. };
  56. static DEFINE_PER_CPU(struct sugov_cpu, sugov_cpu);
  57. /************************ Governor internals ***********************/
  58. static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
  59. {
  60. s64 delta_ns;
  61. if (sg_policy->work_in_progress)
  62. return false;
  63. if (unlikely(sg_policy->need_freq_update)) {
  64. sg_policy->need_freq_update = false;
  65. /*
  66. * This happens when limits change, so forget the previous
  67. * next_freq value and force an update.
  68. */
  69. sg_policy->next_freq = UINT_MAX;
  70. return true;
  71. }
  72. delta_ns = time - sg_policy->last_freq_update_time;
  73. return delta_ns >= sg_policy->freq_update_delay_ns;
  74. }
  75. static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
  76. unsigned int next_freq)
  77. {
  78. struct cpufreq_policy *policy = sg_policy->policy;
  79. if (sg_policy->next_freq == next_freq)
  80. return;
  81. sg_policy->next_freq = next_freq;
  82. sg_policy->last_freq_update_time = time;
  83. if (policy->fast_switch_enabled) {
  84. next_freq = cpufreq_driver_fast_switch(policy, next_freq);
  85. if (next_freq == CPUFREQ_ENTRY_INVALID)
  86. return;
  87. policy->cur = next_freq;
  88. trace_cpu_frequency(next_freq, smp_processor_id());
  89. } else {
  90. sg_policy->work_in_progress = true;
  91. irq_work_queue(&sg_policy->irq_work);
  92. }
  93. }
  94. /**
  95. * get_next_freq - Compute a new frequency for a given cpufreq policy.
  96. * @sg_policy: schedutil policy object to compute the new frequency for.
  97. * @util: Current CPU utilization.
  98. * @max: CPU capacity.
  99. *
  100. * If the utilization is frequency-invariant, choose the new frequency to be
  101. * proportional to it, that is
  102. *
  103. * next_freq = C * max_freq * util / max
  104. *
  105. * Otherwise, approximate the would-be frequency-invariant utilization by
  106. * util_raw * (curr_freq / max_freq) which leads to
  107. *
  108. * next_freq = C * curr_freq * util_raw / max
  109. *
  110. * Take C = 1.25 for the frequency tipping point at (util / max) = 0.8.
  111. *
  112. * The lowest driver-supported frequency which is equal or greater than the raw
  113. * next_freq (as calculated above) is returned, subject to policy min/max and
  114. * cpufreq driver limitations.
  115. */
  116. static unsigned int get_next_freq(struct sugov_policy *sg_policy,
  117. unsigned long util, unsigned long max)
  118. {
  119. struct cpufreq_policy *policy = sg_policy->policy;
  120. unsigned int freq = arch_scale_freq_invariant() ?
  121. policy->cpuinfo.max_freq : policy->cur;
  122. freq = (freq + (freq >> 2)) * util / max;
  123. if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq != UINT_MAX)
  124. return sg_policy->next_freq;
  125. sg_policy->cached_raw_freq = freq;
  126. return cpufreq_driver_resolve_freq(policy, freq);
  127. }
  128. static void sugov_get_util(unsigned long *util, unsigned long *max)
  129. {
  130. struct rq *rq = this_rq();
  131. unsigned long cfs_max;
  132. cfs_max = arch_scale_cpu_capacity(NULL, smp_processor_id());
  133. *util = min(rq->cfs.avg.util_avg, cfs_max);
  134. *max = cfs_max;
  135. }
  136. static void sugov_set_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,
  137. unsigned int flags)
  138. {
  139. if (flags & SCHED_CPUFREQ_IOWAIT) {
  140. sg_cpu->iowait_boost = sg_cpu->iowait_boost_max;
  141. } else if (sg_cpu->iowait_boost) {
  142. s64 delta_ns = time - sg_cpu->last_update;
  143. /* Clear iowait_boost if the CPU apprears to have been idle. */
  144. if (delta_ns > TICK_NSEC)
  145. sg_cpu->iowait_boost = 0;
  146. }
  147. }
  148. static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, unsigned long *util,
  149. unsigned long *max)
  150. {
  151. unsigned long boost_util = sg_cpu->iowait_boost;
  152. unsigned long boost_max = sg_cpu->iowait_boost_max;
  153. if (!boost_util)
  154. return;
  155. if (*util * boost_max < *max * boost_util) {
  156. *util = boost_util;
  157. *max = boost_max;
  158. }
  159. sg_cpu->iowait_boost >>= 1;
  160. }
  161. #ifdef CONFIG_NO_HZ_COMMON
  162. static bool sugov_cpu_is_busy(struct sugov_cpu *sg_cpu)
  163. {
  164. unsigned long idle_calls = tick_nohz_get_idle_calls();
  165. bool ret = idle_calls == sg_cpu->saved_idle_calls;
  166. sg_cpu->saved_idle_calls = idle_calls;
  167. return ret;
  168. }
  169. #else
  170. static inline bool sugov_cpu_is_busy(struct sugov_cpu *sg_cpu) { return false; }
  171. #endif /* CONFIG_NO_HZ_COMMON */
  172. static void sugov_update_single(struct update_util_data *hook, u64 time,
  173. unsigned int flags)
  174. {
  175. struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
  176. struct sugov_policy *sg_policy = sg_cpu->sg_policy;
  177. struct cpufreq_policy *policy = sg_policy->policy;
  178. unsigned long util, max;
  179. unsigned int next_f;
  180. bool busy;
  181. sugov_set_iowait_boost(sg_cpu, time, flags);
  182. sg_cpu->last_update = time;
  183. if (!sugov_should_update_freq(sg_policy, time))
  184. return;
  185. busy = sugov_cpu_is_busy(sg_cpu);
  186. if (flags & SCHED_CPUFREQ_RT_DL) {
  187. next_f = policy->cpuinfo.max_freq;
  188. } else {
  189. sugov_get_util(&util, &max);
  190. sugov_iowait_boost(sg_cpu, &util, &max);
  191. next_f = get_next_freq(sg_policy, util, max);
  192. /*
  193. * Do not reduce the frequency if the CPU has not been idle
  194. * recently, as the reduction is likely to be premature then.
  195. */
  196. if (busy && next_f < sg_policy->next_freq)
  197. next_f = sg_policy->next_freq;
  198. }
  199. sugov_update_commit(sg_policy, time, next_f);
  200. }
  201. static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu)
  202. {
  203. struct sugov_policy *sg_policy = sg_cpu->sg_policy;
  204. struct cpufreq_policy *policy = sg_policy->policy;
  205. u64 last_freq_update_time = sg_policy->last_freq_update_time;
  206. unsigned long util = 0, max = 1;
  207. unsigned int j;
  208. for_each_cpu(j, policy->cpus) {
  209. struct sugov_cpu *j_sg_cpu = &per_cpu(sugov_cpu, j);
  210. unsigned long j_util, j_max;
  211. s64 delta_ns;
  212. /*
  213. * If the CPU utilization was last updated before the previous
  214. * frequency update and the time elapsed between the last update
  215. * of the CPU utilization and the last frequency update is long
  216. * enough, don't take the CPU into account as it probably is
  217. * idle now (and clear iowait_boost for it).
  218. */
  219. delta_ns = last_freq_update_time - j_sg_cpu->last_update;
  220. if (delta_ns > TICK_NSEC) {
  221. j_sg_cpu->iowait_boost = 0;
  222. continue;
  223. }
  224. if (j_sg_cpu->flags & SCHED_CPUFREQ_RT_DL)
  225. return policy->cpuinfo.max_freq;
  226. j_util = j_sg_cpu->util;
  227. j_max = j_sg_cpu->max;
  228. if (j_util * max > j_max * util) {
  229. util = j_util;
  230. max = j_max;
  231. }
  232. sugov_iowait_boost(j_sg_cpu, &util, &max);
  233. }
  234. return get_next_freq(sg_policy, util, max);
  235. }
  236. static void sugov_update_shared(struct update_util_data *hook, u64 time,
  237. unsigned int flags)
  238. {
  239. struct sugov_cpu *sg_cpu = container_of(hook, struct sugov_cpu, update_util);
  240. struct sugov_policy *sg_policy = sg_cpu->sg_policy;
  241. unsigned long util, max;
  242. unsigned int next_f;
  243. sugov_get_util(&util, &max);
  244. raw_spin_lock(&sg_policy->update_lock);
  245. sg_cpu->util = util;
  246. sg_cpu->max = max;
  247. sg_cpu->flags = flags;
  248. sugov_set_iowait_boost(sg_cpu, time, flags);
  249. sg_cpu->last_update = time;
  250. if (sugov_should_update_freq(sg_policy, time)) {
  251. if (flags & SCHED_CPUFREQ_RT_DL)
  252. next_f = sg_policy->policy->cpuinfo.max_freq;
  253. else
  254. next_f = sugov_next_freq_shared(sg_cpu);
  255. sugov_update_commit(sg_policy, time, next_f);
  256. }
  257. raw_spin_unlock(&sg_policy->update_lock);
  258. }
  259. static void sugov_work(struct kthread_work *work)
  260. {
  261. struct sugov_policy *sg_policy = container_of(work, struct sugov_policy, work);
  262. mutex_lock(&sg_policy->work_lock);
  263. __cpufreq_driver_target(sg_policy->policy, sg_policy->next_freq,
  264. CPUFREQ_RELATION_L);
  265. mutex_unlock(&sg_policy->work_lock);
  266. sg_policy->work_in_progress = false;
  267. }
  268. static void sugov_irq_work(struct irq_work *irq_work)
  269. {
  270. struct sugov_policy *sg_policy;
  271. sg_policy = container_of(irq_work, struct sugov_policy, irq_work);
  272. /*
  273. * For RT and deadline tasks, the schedutil governor shoots the
  274. * frequency to maximum. Special care must be taken to ensure that this
  275. * kthread doesn't result in the same behavior.
  276. *
  277. * This is (mostly) guaranteed by the work_in_progress flag. The flag is
  278. * updated only at the end of the sugov_work() function and before that
  279. * the schedutil governor rejects all other frequency scaling requests.
  280. *
  281. * There is a very rare case though, where the RT thread yields right
  282. * after the work_in_progress flag is cleared. The effects of that are
  283. * neglected for now.
  284. */
  285. kthread_queue_work(&sg_policy->worker, &sg_policy->work);
  286. }
  287. /************************** sysfs interface ************************/
  288. static struct sugov_tunables *global_tunables;
  289. static DEFINE_MUTEX(global_tunables_lock);
  290. static inline struct sugov_tunables *to_sugov_tunables(struct gov_attr_set *attr_set)
  291. {
  292. return container_of(attr_set, struct sugov_tunables, attr_set);
  293. }
  294. static ssize_t rate_limit_us_show(struct gov_attr_set *attr_set, char *buf)
  295. {
  296. struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
  297. return sprintf(buf, "%u\n", tunables->rate_limit_us);
  298. }
  299. static ssize_t rate_limit_us_store(struct gov_attr_set *attr_set, const char *buf,
  300. size_t count)
  301. {
  302. struct sugov_tunables *tunables = to_sugov_tunables(attr_set);
  303. struct sugov_policy *sg_policy;
  304. unsigned int rate_limit_us;
  305. if (kstrtouint(buf, 10, &rate_limit_us))
  306. return -EINVAL;
  307. tunables->rate_limit_us = rate_limit_us;
  308. list_for_each_entry(sg_policy, &attr_set->policy_list, tunables_hook)
  309. sg_policy->freq_update_delay_ns = rate_limit_us * NSEC_PER_USEC;
  310. return count;
  311. }
  312. static struct governor_attr rate_limit_us = __ATTR_RW(rate_limit_us);
  313. static struct attribute *sugov_attributes[] = {
  314. &rate_limit_us.attr,
  315. NULL
  316. };
  317. static struct kobj_type sugov_tunables_ktype = {
  318. .default_attrs = sugov_attributes,
  319. .sysfs_ops = &governor_sysfs_ops,
  320. };
  321. /********************** cpufreq governor interface *********************/
  322. static struct cpufreq_governor schedutil_gov;
  323. static struct sugov_policy *sugov_policy_alloc(struct cpufreq_policy *policy)
  324. {
  325. struct sugov_policy *sg_policy;
  326. sg_policy = kzalloc(sizeof(*sg_policy), GFP_KERNEL);
  327. if (!sg_policy)
  328. return NULL;
  329. sg_policy->policy = policy;
  330. raw_spin_lock_init(&sg_policy->update_lock);
  331. return sg_policy;
  332. }
  333. static void sugov_policy_free(struct sugov_policy *sg_policy)
  334. {
  335. kfree(sg_policy);
  336. }
  337. static int sugov_kthread_create(struct sugov_policy *sg_policy)
  338. {
  339. struct task_struct *thread;
  340. struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO / 2 };
  341. struct cpufreq_policy *policy = sg_policy->policy;
  342. int ret;
  343. /* kthread only required for slow path */
  344. if (policy->fast_switch_enabled)
  345. return 0;
  346. kthread_init_work(&sg_policy->work, sugov_work);
  347. kthread_init_worker(&sg_policy->worker);
  348. thread = kthread_create(kthread_worker_fn, &sg_policy->worker,
  349. "sugov:%d",
  350. cpumask_first(policy->related_cpus));
  351. if (IS_ERR(thread)) {
  352. pr_err("failed to create sugov thread: %ld\n", PTR_ERR(thread));
  353. return PTR_ERR(thread);
  354. }
  355. ret = sched_setscheduler_nocheck(thread, SCHED_FIFO, &param);
  356. if (ret) {
  357. kthread_stop(thread);
  358. pr_warn("%s: failed to set SCHED_FIFO\n", __func__);
  359. return ret;
  360. }
  361. sg_policy->thread = thread;
  362. kthread_bind_mask(thread, policy->related_cpus);
  363. init_irq_work(&sg_policy->irq_work, sugov_irq_work);
  364. mutex_init(&sg_policy->work_lock);
  365. wake_up_process(thread);
  366. return 0;
  367. }
  368. static void sugov_kthread_stop(struct sugov_policy *sg_policy)
  369. {
  370. /* kthread only required for slow path */
  371. if (sg_policy->policy->fast_switch_enabled)
  372. return;
  373. kthread_flush_worker(&sg_policy->worker);
  374. kthread_stop(sg_policy->thread);
  375. mutex_destroy(&sg_policy->work_lock);
  376. }
  377. static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_policy)
  378. {
  379. struct sugov_tunables *tunables;
  380. tunables = kzalloc(sizeof(*tunables), GFP_KERNEL);
  381. if (tunables) {
  382. gov_attr_set_init(&tunables->attr_set, &sg_policy->tunables_hook);
  383. if (!have_governor_per_policy())
  384. global_tunables = tunables;
  385. }
  386. return tunables;
  387. }
  388. static void sugov_tunables_free(struct sugov_tunables *tunables)
  389. {
  390. if (!have_governor_per_policy())
  391. global_tunables = NULL;
  392. kfree(tunables);
  393. }
  394. static int sugov_init(struct cpufreq_policy *policy)
  395. {
  396. struct sugov_policy *sg_policy;
  397. struct sugov_tunables *tunables;
  398. unsigned int lat;
  399. int ret = 0;
  400. /* State should be equivalent to EXIT */
  401. if (policy->governor_data)
  402. return -EBUSY;
  403. cpufreq_enable_fast_switch(policy);
  404. sg_policy = sugov_policy_alloc(policy);
  405. if (!sg_policy) {
  406. ret = -ENOMEM;
  407. goto disable_fast_switch;
  408. }
  409. ret = sugov_kthread_create(sg_policy);
  410. if (ret)
  411. goto free_sg_policy;
  412. mutex_lock(&global_tunables_lock);
  413. if (global_tunables) {
  414. if (WARN_ON(have_governor_per_policy())) {
  415. ret = -EINVAL;
  416. goto stop_kthread;
  417. }
  418. policy->governor_data = sg_policy;
  419. sg_policy->tunables = global_tunables;
  420. gov_attr_set_get(&global_tunables->attr_set, &sg_policy->tunables_hook);
  421. goto out;
  422. }
  423. tunables = sugov_tunables_alloc(sg_policy);
  424. if (!tunables) {
  425. ret = -ENOMEM;
  426. goto stop_kthread;
  427. }
  428. tunables->rate_limit_us = LATENCY_MULTIPLIER;
  429. lat = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
  430. if (lat)
  431. tunables->rate_limit_us *= lat;
  432. policy->governor_data = sg_policy;
  433. sg_policy->tunables = tunables;
  434. ret = kobject_init_and_add(&tunables->attr_set.kobj, &sugov_tunables_ktype,
  435. get_governor_parent_kobj(policy), "%s",
  436. schedutil_gov.name);
  437. if (ret)
  438. goto fail;
  439. out:
  440. mutex_unlock(&global_tunables_lock);
  441. return 0;
  442. fail:
  443. policy->governor_data = NULL;
  444. sugov_tunables_free(tunables);
  445. stop_kthread:
  446. sugov_kthread_stop(sg_policy);
  447. free_sg_policy:
  448. mutex_unlock(&global_tunables_lock);
  449. sugov_policy_free(sg_policy);
  450. disable_fast_switch:
  451. cpufreq_disable_fast_switch(policy);
  452. pr_err("initialization failed (error %d)\n", ret);
  453. return ret;
  454. }
  455. static void sugov_exit(struct cpufreq_policy *policy)
  456. {
  457. struct sugov_policy *sg_policy = policy->governor_data;
  458. struct sugov_tunables *tunables = sg_policy->tunables;
  459. unsigned int count;
  460. mutex_lock(&global_tunables_lock);
  461. count = gov_attr_set_put(&tunables->attr_set, &sg_policy->tunables_hook);
  462. policy->governor_data = NULL;
  463. if (!count)
  464. sugov_tunables_free(tunables);
  465. mutex_unlock(&global_tunables_lock);
  466. sugov_kthread_stop(sg_policy);
  467. sugov_policy_free(sg_policy);
  468. cpufreq_disable_fast_switch(policy);
  469. }
  470. static int sugov_start(struct cpufreq_policy *policy)
  471. {
  472. struct sugov_policy *sg_policy = policy->governor_data;
  473. unsigned int cpu;
  474. sg_policy->freq_update_delay_ns = sg_policy->tunables->rate_limit_us * NSEC_PER_USEC;
  475. sg_policy->last_freq_update_time = 0;
  476. sg_policy->next_freq = UINT_MAX;
  477. sg_policy->work_in_progress = false;
  478. sg_policy->need_freq_update = false;
  479. sg_policy->cached_raw_freq = 0;
  480. for_each_cpu(cpu, policy->cpus) {
  481. struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
  482. sg_cpu->sg_policy = sg_policy;
  483. if (policy_is_shared(policy)) {
  484. sg_cpu->util = 0;
  485. sg_cpu->max = 0;
  486. sg_cpu->flags = SCHED_CPUFREQ_RT;
  487. sg_cpu->last_update = 0;
  488. sg_cpu->iowait_boost = 0;
  489. sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq;
  490. cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util,
  491. sugov_update_shared);
  492. } else {
  493. cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util,
  494. sugov_update_single);
  495. }
  496. }
  497. return 0;
  498. }
  499. static void sugov_stop(struct cpufreq_policy *policy)
  500. {
  501. struct sugov_policy *sg_policy = policy->governor_data;
  502. unsigned int cpu;
  503. for_each_cpu(cpu, policy->cpus)
  504. cpufreq_remove_update_util_hook(cpu);
  505. synchronize_sched();
  506. if (!policy->fast_switch_enabled) {
  507. irq_work_sync(&sg_policy->irq_work);
  508. kthread_cancel_work_sync(&sg_policy->work);
  509. }
  510. }
  511. static void sugov_limits(struct cpufreq_policy *policy)
  512. {
  513. struct sugov_policy *sg_policy = policy->governor_data;
  514. if (!policy->fast_switch_enabled) {
  515. mutex_lock(&sg_policy->work_lock);
  516. cpufreq_policy_apply_limits(policy);
  517. mutex_unlock(&sg_policy->work_lock);
  518. }
  519. sg_policy->need_freq_update = true;
  520. }
  521. static struct cpufreq_governor schedutil_gov = {
  522. .name = "schedutil",
  523. .owner = THIS_MODULE,
  524. .init = sugov_init,
  525. .exit = sugov_exit,
  526. .start = sugov_start,
  527. .stop = sugov_stop,
  528. .limits = sugov_limits,
  529. };
  530. #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL
  531. struct cpufreq_governor *cpufreq_default_governor(void)
  532. {
  533. return &schedutil_gov;
  534. }
  535. #endif
  536. static int __init sugov_register(void)
  537. {
  538. return cpufreq_register_governor(&schedutil_gov);
  539. }
  540. fs_initcall(sugov_register);