Merge branch 'linux-linaro-lsk' into linux-linaro-lsk-android
[firefly-linux-kernel-4.4.55.git] / drivers / cpufreq / cpufreq_interactive.c
1 /*
2  * drivers/cpufreq/cpufreq_interactive.c
3  *
4  * Copyright (C) 2010 Google, Inc.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * Author: Mike Chan (mike@android.com)
16  *
17  */
18
19 #include <linux/cpu.h>
20 #include <linux/cpumask.h>
21 #include <linux/cpufreq.h>
22 #include <linux/module.h>
23 #include <linux/moduleparam.h>
24 #include <linux/rwsem.h>
25 #include <linux/sched.h>
26 #include <linux/sched/rt.h>
27 #include <linux/tick.h>
28 #include <linux/time.h>
29 #include <linux/timer.h>
30 #include <linux/workqueue.h>
31 #include <linux/kthread.h>
32 #include <linux/slab.h>
33 #include "cpufreq_governor.h"
34
35 #define CREATE_TRACE_POINTS
36 #include <trace/events/cpufreq_interactive.h>
37
38 struct cpufreq_interactive_cpuinfo {
39         struct timer_list cpu_timer;
40         struct timer_list cpu_slack_timer;
41         spinlock_t load_lock; /* protects the next 4 fields */
42         u64 time_in_idle;
43         u64 time_in_idle_timestamp;
44         u64 cputime_speedadj;
45         u64 cputime_speedadj_timestamp;
46         struct cpufreq_policy *policy;
47         struct cpufreq_frequency_table *freq_table;
48         unsigned int target_freq;
49         unsigned int floor_freq;
50         u64 floor_validate_time;
51         u64 hispeed_validate_time;
52         struct rw_semaphore enable_sem;
53         int governor_enabled;
54 };
55
56 static DEFINE_PER_CPU(struct cpufreq_interactive_cpuinfo, cpuinfo);
57
58 /* realtime thread handles frequency scaling */
59 static struct task_struct *speedchange_task;
60 static cpumask_t speedchange_cpumask;
61 static spinlock_t speedchange_cpumask_lock;
62 static struct mutex gov_lock;
63
64 /* Target load.  Lower values result in higher CPU speeds. */
65 #define DEFAULT_TARGET_LOAD 90
66 static unsigned int default_target_loads[] = {DEFAULT_TARGET_LOAD};
67
68 #define DEFAULT_TIMER_RATE (20 * USEC_PER_MSEC)
69 #define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
70 static unsigned int default_above_hispeed_delay[] = {
71         DEFAULT_ABOVE_HISPEED_DELAY };
72
73 struct cpufreq_interactive_tunables {
74         int usage_count;
75         /* Hi speed to bump to from lo speed when load burst (default max) */
76         unsigned int hispeed_freq;
77         /* Go to hi speed when CPU load at or above this value. */
78 #define DEFAULT_GO_HISPEED_LOAD 99
79         unsigned long go_hispeed_load;
80         /* Target load. Lower values result in higher CPU speeds. */
81         spinlock_t target_loads_lock;
82         unsigned int *target_loads;
83         int ntarget_loads;
84         /*
85          * The minimum amount of time to spend at a frequency before we can ramp
86          * down.
87          */
88 #define DEFAULT_MIN_SAMPLE_TIME (80 * USEC_PER_MSEC)
89         unsigned long min_sample_time;
90         /*
91          * The sample rate of the timer used to increase frequency
92          */
93         unsigned long timer_rate;
94         /*
95          * Wait this long before raising speed above hispeed, by default a
96          * single timer interval.
97          */
98         spinlock_t above_hispeed_delay_lock;
99         unsigned int *above_hispeed_delay;
100         int nabove_hispeed_delay;
101         /* Non-zero means indefinite speed boost active */
102         int boost_val;
103         /* Duration of a boot pulse in usecs */
104         int boostpulse_duration_val;
105         /* End time of boost pulse in ktime converted to usecs */
106         u64 boostpulse_endtime;
107         /*
108          * Max additional time to wait in idle, beyond timer_rate, at speeds
109          * above minimum before wakeup to reduce speed, or -1 if unnecessary.
110          */
111 #define DEFAULT_TIMER_SLACK (4 * DEFAULT_TIMER_RATE)
112         int timer_slack_val;
113         bool io_is_busy;
114 };
115
116 /* For cases where we have single governor instance for system */
117 struct cpufreq_interactive_tunables *common_tunables;
118
119 static struct attribute_group *get_sysfs_attr(void);
120
121 static void cpufreq_interactive_timer_resched(
122         struct cpufreq_interactive_cpuinfo *pcpu)
123 {
124         struct cpufreq_interactive_tunables *tunables =
125                 pcpu->policy->governor_data;
126         unsigned long expires;
127         unsigned long flags;
128
129         spin_lock_irqsave(&pcpu->load_lock, flags);
130         pcpu->time_in_idle =
131                 get_cpu_idle_time(smp_processor_id(),
132                                   &pcpu->time_in_idle_timestamp,
133                                   tunables->io_is_busy);
134         pcpu->cputime_speedadj = 0;
135         pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
136         expires = jiffies + usecs_to_jiffies(tunables->timer_rate);
137         mod_timer_pinned(&pcpu->cpu_timer, expires);
138
139         if (tunables->timer_slack_val >= 0 &&
140             pcpu->target_freq > pcpu->policy->min) {
141                 expires += usecs_to_jiffies(tunables->timer_slack_val);
142                 mod_timer_pinned(&pcpu->cpu_slack_timer, expires);
143         }
144
145         spin_unlock_irqrestore(&pcpu->load_lock, flags);
146 }
147
148 /* The caller shall take enable_sem write semaphore to avoid any timer race.
149  * The cpu_timer and cpu_slack_timer must be deactivated when calling this
150  * function.
151  */
152 static void cpufreq_interactive_timer_start(
153         struct cpufreq_interactive_tunables *tunables, int cpu)
154 {
155         struct cpufreq_interactive_cpuinfo *pcpu = &per_cpu(cpuinfo, cpu);
156         unsigned long expires = jiffies +
157                 usecs_to_jiffies(tunables->timer_rate);
158         unsigned long flags;
159
160         pcpu->cpu_timer.expires = expires;
161         add_timer_on(&pcpu->cpu_timer, cpu);
162         if (tunables->timer_slack_val >= 0 &&
163             pcpu->target_freq > pcpu->policy->min) {
164                 expires += usecs_to_jiffies(tunables->timer_slack_val);
165                 pcpu->cpu_slack_timer.expires = expires;
166                 add_timer_on(&pcpu->cpu_slack_timer, cpu);
167         }
168
169         spin_lock_irqsave(&pcpu->load_lock, flags);
170         pcpu->time_in_idle =
171                 get_cpu_idle_time(cpu, &pcpu->time_in_idle_timestamp,
172                                   tunables->io_is_busy);
173         pcpu->cputime_speedadj = 0;
174         pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
175         spin_unlock_irqrestore(&pcpu->load_lock, flags);
176 }
177
178 static unsigned int freq_to_above_hispeed_delay(
179         struct cpufreq_interactive_tunables *tunables,
180         unsigned int freq)
181 {
182         int i;
183         unsigned int ret;
184         unsigned long flags;
185
186         spin_lock_irqsave(&tunables->above_hispeed_delay_lock, flags);
187
188         for (i = 0; i < tunables->nabove_hispeed_delay - 1 &&
189                         freq >= tunables->above_hispeed_delay[i+1]; i += 2)
190                 ;
191
192         ret = tunables->above_hispeed_delay[i];
193         spin_unlock_irqrestore(&tunables->above_hispeed_delay_lock, flags);
194         return ret;
195 }
196
197 static unsigned int freq_to_targetload(
198         struct cpufreq_interactive_tunables *tunables, unsigned int freq)
199 {
200         int i;
201         unsigned int ret;
202         unsigned long flags;
203
204         spin_lock_irqsave(&tunables->target_loads_lock, flags);
205
206         for (i = 0; i < tunables->ntarget_loads - 1 &&
207                     freq >= tunables->target_loads[i+1]; i += 2)
208                 ;
209
210         ret = tunables->target_loads[i];
211         spin_unlock_irqrestore(&tunables->target_loads_lock, flags);
212         return ret;
213 }
214
215 /*
216  * If increasing frequencies never map to a lower target load then
217  * choose_freq() will find the minimum frequency that does not exceed its
218  * target load given the current load.
219  */
220 static unsigned int choose_freq(struct cpufreq_interactive_cpuinfo *pcpu,
221                 unsigned int loadadjfreq)
222 {
223         unsigned int freq = pcpu->policy->cur;
224         unsigned int prevfreq, freqmin, freqmax;
225         unsigned int tl;
226         int index;
227
228         freqmin = 0;
229         freqmax = UINT_MAX;
230
231         do {
232                 prevfreq = freq;
233                 tl = freq_to_targetload(pcpu->policy->governor_data, freq);
234
235                 /*
236                  * Find the lowest frequency where the computed load is less
237                  * than or equal to the target load.
238                  */
239
240                 if (cpufreq_frequency_table_target(
241                             pcpu->policy, pcpu->freq_table, loadadjfreq / tl,
242                             CPUFREQ_RELATION_L, &index))
243                         break;
244                 freq = pcpu->freq_table[index].frequency;
245
246                 if (freq > prevfreq) {
247                         /* The previous frequency is too low. */
248                         freqmin = prevfreq;
249
250                         if (freq >= freqmax) {
251                                 /*
252                                  * Find the highest frequency that is less
253                                  * than freqmax.
254                                  */
255                                 if (cpufreq_frequency_table_target(
256                                             pcpu->policy, pcpu->freq_table,
257                                             freqmax - 1, CPUFREQ_RELATION_H,
258                                             &index))
259                                         break;
260                                 freq = pcpu->freq_table[index].frequency;
261
262                                 if (freq == freqmin) {
263                                         /*
264                                          * The first frequency below freqmax
265                                          * has already been found to be too
266                                          * low.  freqmax is the lowest speed
267                                          * we found that is fast enough.
268                                          */
269                                         freq = freqmax;
270                                         break;
271                                 }
272                         }
273                 } else if (freq < prevfreq) {
274                         /* The previous frequency is high enough. */
275                         freqmax = prevfreq;
276
277                         if (freq <= freqmin) {
278                                 /*
279                                  * Find the lowest frequency that is higher
280                                  * than freqmin.
281                                  */
282                                 if (cpufreq_frequency_table_target(
283                                             pcpu->policy, pcpu->freq_table,
284                                             freqmin + 1, CPUFREQ_RELATION_L,
285                                             &index))
286                                         break;
287                                 freq = pcpu->freq_table[index].frequency;
288
289                                 /*
290                                  * If freqmax is the first frequency above
291                                  * freqmin then we have already found that
292                                  * this speed is fast enough.
293                                  */
294                                 if (freq == freqmax)
295                                         break;
296                         }
297                 }
298
299                 /* If same frequency chosen as previous then done. */
300         } while (freq != prevfreq);
301
302         return freq;
303 }
304
305 static u64 update_load(int cpu)
306 {
307         struct cpufreq_interactive_cpuinfo *pcpu = &per_cpu(cpuinfo, cpu);
308         struct cpufreq_interactive_tunables *tunables =
309                 pcpu->policy->governor_data;
310         u64 now;
311         u64 now_idle;
312         u64 delta_idle;
313         u64 delta_time;
314         u64 active_time;
315
316         now_idle = get_cpu_idle_time(cpu, &now, tunables->io_is_busy);
317         delta_idle = (now_idle - pcpu->time_in_idle);
318         delta_time = (now - pcpu->time_in_idle_timestamp);
319
320         if (delta_time <= delta_idle)
321                 active_time = 0;
322         else
323                 active_time = delta_time - delta_idle;
324
325         pcpu->cputime_speedadj += active_time * pcpu->policy->cur;
326
327         pcpu->time_in_idle = now_idle;
328         pcpu->time_in_idle_timestamp = now;
329         return now;
330 }
331
332 static void cpufreq_interactive_timer(unsigned long data)
333 {
334         u64 now;
335         unsigned int delta_time;
336         u64 cputime_speedadj;
337         int cpu_load;
338         struct cpufreq_interactive_cpuinfo *pcpu =
339                 &per_cpu(cpuinfo, data);
340         struct cpufreq_interactive_tunables *tunables =
341                 pcpu->policy->governor_data;
342         unsigned int new_freq;
343         unsigned int loadadjfreq;
344         unsigned int index;
345         unsigned long flags;
346         bool boosted;
347
348         if (!down_read_trylock(&pcpu->enable_sem))
349                 return;
350         if (!pcpu->governor_enabled)
351                 goto exit;
352
353         spin_lock_irqsave(&pcpu->load_lock, flags);
354         now = update_load(data);
355         delta_time = (unsigned int)(now - pcpu->cputime_speedadj_timestamp);
356         cputime_speedadj = pcpu->cputime_speedadj;
357         spin_unlock_irqrestore(&pcpu->load_lock, flags);
358
359         if (WARN_ON_ONCE(!delta_time))
360                 goto rearm;
361
362         do_div(cputime_speedadj, delta_time);
363         loadadjfreq = (unsigned int)cputime_speedadj * 100;
364         cpu_load = loadadjfreq / pcpu->target_freq;
365         boosted = tunables->boost_val || now < tunables->boostpulse_endtime;
366
367         if (cpu_load >= tunables->go_hispeed_load || boosted) {
368                 if (pcpu->target_freq < tunables->hispeed_freq) {
369                         new_freq = tunables->hispeed_freq;
370                 } else {
371                         new_freq = choose_freq(pcpu, loadadjfreq);
372
373                         if (new_freq < tunables->hispeed_freq)
374                                 new_freq = tunables->hispeed_freq;
375                 }
376         } else {
377                 new_freq = choose_freq(pcpu, loadadjfreq);
378         }
379
380         if (pcpu->target_freq >= tunables->hispeed_freq &&
381             new_freq > pcpu->target_freq &&
382             now - pcpu->hispeed_validate_time <
383             freq_to_above_hispeed_delay(tunables, pcpu->target_freq)) {
384                 trace_cpufreq_interactive_notyet(
385                         data, cpu_load, pcpu->target_freq,
386                         pcpu->policy->cur, new_freq);
387                 goto rearm;
388         }
389
390         pcpu->hispeed_validate_time = now;
391
392         if (cpufreq_frequency_table_target(pcpu->policy, pcpu->freq_table,
393                                            new_freq, CPUFREQ_RELATION_L,
394                                            &index))
395                 goto rearm;
396
397         new_freq = pcpu->freq_table[index].frequency;
398
399         /*
400          * Do not scale below floor_freq unless we have been at or above the
401          * floor frequency for the minimum sample time since last validated.
402          */
403         if (new_freq < pcpu->floor_freq) {
404                 if (now - pcpu->floor_validate_time <
405                                 tunables->min_sample_time) {
406                         trace_cpufreq_interactive_notyet(
407                                 data, cpu_load, pcpu->target_freq,
408                                 pcpu->policy->cur, new_freq);
409                         goto rearm;
410                 }
411         }
412
413         /*
414          * Update the timestamp for checking whether speed has been held at
415          * or above the selected frequency for a minimum of min_sample_time,
416          * if not boosted to hispeed_freq.  If boosted to hispeed_freq then we
417          * allow the speed to drop as soon as the boostpulse duration expires
418          * (or the indefinite boost is turned off).
419          */
420
421         if (!boosted || new_freq > tunables->hispeed_freq) {
422                 pcpu->floor_freq = new_freq;
423                 pcpu->floor_validate_time = now;
424         }
425
426         if (pcpu->target_freq == new_freq) {
427                 trace_cpufreq_interactive_already(
428                         data, cpu_load, pcpu->target_freq,
429                         pcpu->policy->cur, new_freq);
430                 goto rearm_if_notmax;
431         }
432
433         trace_cpufreq_interactive_target(data, cpu_load, pcpu->target_freq,
434                                          pcpu->policy->cur, new_freq);
435
436         pcpu->target_freq = new_freq;
437         spin_lock_irqsave(&speedchange_cpumask_lock, flags);
438         cpumask_set_cpu(data, &speedchange_cpumask);
439         spin_unlock_irqrestore(&speedchange_cpumask_lock, flags);
440         wake_up_process(speedchange_task);
441
442 rearm_if_notmax:
443         /*
444          * Already set max speed and don't see a need to change that,
445          * wait until next idle to re-evaluate, don't need timer.
446          */
447         if (pcpu->target_freq == pcpu->policy->max)
448                 goto exit;
449
450 rearm:
451         if (!timer_pending(&pcpu->cpu_timer))
452                 cpufreq_interactive_timer_resched(pcpu);
453
454 exit:
455         up_read(&pcpu->enable_sem);
456         return;
457 }
458
459 static void cpufreq_interactive_idle_start(void)
460 {
461         struct cpufreq_interactive_cpuinfo *pcpu =
462                 &per_cpu(cpuinfo, smp_processor_id());
463         int pending;
464
465         if (!down_read_trylock(&pcpu->enable_sem))
466                 return;
467         if (!pcpu->governor_enabled) {
468                 up_read(&pcpu->enable_sem);
469                 return;
470         }
471
472         pending = timer_pending(&pcpu->cpu_timer);
473
474         if (pcpu->target_freq != pcpu->policy->min) {
475                 /*
476                  * Entering idle while not at lowest speed.  On some
477                  * platforms this can hold the other CPU(s) at that speed
478                  * even though the CPU is idle. Set a timer to re-evaluate
479                  * speed so this idle CPU doesn't hold the other CPUs above
480                  * min indefinitely.  This should probably be a quirk of
481                  * the CPUFreq driver.
482                  */
483                 if (!pending)
484                         cpufreq_interactive_timer_resched(pcpu);
485         }
486
487         up_read(&pcpu->enable_sem);
488 }
489
490 static void cpufreq_interactive_idle_end(void)
491 {
492         struct cpufreq_interactive_cpuinfo *pcpu =
493                 &per_cpu(cpuinfo, smp_processor_id());
494
495         if (!down_read_trylock(&pcpu->enable_sem))
496                 return;
497         if (!pcpu->governor_enabled) {
498                 up_read(&pcpu->enable_sem);
499                 return;
500         }
501
502         /* Arm the timer for 1-2 ticks later if not already. */
503         if (!timer_pending(&pcpu->cpu_timer)) {
504                 cpufreq_interactive_timer_resched(pcpu);
505         } else if (time_after_eq(jiffies, pcpu->cpu_timer.expires)) {
506                 del_timer(&pcpu->cpu_timer);
507                 del_timer(&pcpu->cpu_slack_timer);
508                 cpufreq_interactive_timer(smp_processor_id());
509         }
510
511         up_read(&pcpu->enable_sem);
512 }
513
514 static int cpufreq_interactive_speedchange_task(void *data)
515 {
516         unsigned int cpu;
517         cpumask_t tmp_mask;
518         unsigned long flags;
519         struct cpufreq_interactive_cpuinfo *pcpu;
520
521         while (1) {
522                 set_current_state(TASK_INTERRUPTIBLE);
523                 spin_lock_irqsave(&speedchange_cpumask_lock, flags);
524
525                 if (cpumask_empty(&speedchange_cpumask)) {
526                         spin_unlock_irqrestore(&speedchange_cpumask_lock,
527                                                flags);
528                         schedule();
529
530                         if (kthread_should_stop())
531                                 break;
532
533                         spin_lock_irqsave(&speedchange_cpumask_lock, flags);
534                 }
535
536                 set_current_state(TASK_RUNNING);
537                 tmp_mask = speedchange_cpumask;
538                 cpumask_clear(&speedchange_cpumask);
539                 spin_unlock_irqrestore(&speedchange_cpumask_lock, flags);
540
541                 for_each_cpu(cpu, &tmp_mask) {
542                         unsigned int j;
543                         unsigned int max_freq = 0;
544
545                         pcpu = &per_cpu(cpuinfo, cpu);
546                         if (!down_read_trylock(&pcpu->enable_sem))
547                                 continue;
548                         if (!pcpu->governor_enabled) {
549                                 up_read(&pcpu->enable_sem);
550                                 continue;
551                         }
552
553                         for_each_cpu(j, pcpu->policy->cpus) {
554                                 struct cpufreq_interactive_cpuinfo *pjcpu =
555                                         &per_cpu(cpuinfo, j);
556
557                                 if (pjcpu->target_freq > max_freq)
558                                         max_freq = pjcpu->target_freq;
559                         }
560
561                         if (max_freq != pcpu->policy->cur)
562                                 __cpufreq_driver_target(pcpu->policy,
563                                                         max_freq,
564                                                         CPUFREQ_RELATION_H);
565                         trace_cpufreq_interactive_setspeed(cpu,
566                                                      pcpu->target_freq,
567                                                      pcpu->policy->cur);
568
569                         up_read(&pcpu->enable_sem);
570                 }
571         }
572
573         return 0;
574 }
575
576 static void cpufreq_interactive_boost(void)
577 {
578         int i;
579         int anyboost = 0;
580         unsigned long flags;
581         struct cpufreq_interactive_cpuinfo *pcpu;
582         struct cpufreq_interactive_tunables *tunables;
583
584         spin_lock_irqsave(&speedchange_cpumask_lock, flags);
585
586         for_each_online_cpu(i) {
587                 pcpu = &per_cpu(cpuinfo, i);
588                 tunables = pcpu->policy->governor_data;
589
590                 if (pcpu->target_freq < tunables->hispeed_freq) {
591                         pcpu->target_freq = tunables->hispeed_freq;
592                         cpumask_set_cpu(i, &speedchange_cpumask);
593                         pcpu->hispeed_validate_time =
594                                 ktime_to_us(ktime_get());
595                         anyboost = 1;
596                 }
597
598                 /*
599                  * Set floor freq and (re)start timer for when last
600                  * validated.
601                  */
602
603                 pcpu->floor_freq = tunables->hispeed_freq;
604                 pcpu->floor_validate_time = ktime_to_us(ktime_get());
605         }
606
607         spin_unlock_irqrestore(&speedchange_cpumask_lock, flags);
608
609         if (anyboost)
610                 wake_up_process(speedchange_task);
611 }
612
613 static int cpufreq_interactive_notifier(
614         struct notifier_block *nb, unsigned long val, void *data)
615 {
616         struct cpufreq_freqs *freq = data;
617         struct cpufreq_interactive_cpuinfo *pcpu;
618         int cpu;
619         unsigned long flags;
620
621         if (val == CPUFREQ_POSTCHANGE) {
622                 pcpu = &per_cpu(cpuinfo, freq->cpu);
623                 if (!down_read_trylock(&pcpu->enable_sem))
624                         return 0;
625                 if (!pcpu->governor_enabled) {
626                         up_read(&pcpu->enable_sem);
627                         return 0;
628                 }
629
630                 for_each_cpu(cpu, pcpu->policy->cpus) {
631                         struct cpufreq_interactive_cpuinfo *pjcpu =
632                                 &per_cpu(cpuinfo, cpu);
633                         if (cpu != freq->cpu) {
634                                 if (!down_read_trylock(&pjcpu->enable_sem))
635                                         continue;
636                                 if (!pjcpu->governor_enabled) {
637                                         up_read(&pjcpu->enable_sem);
638                                         continue;
639                                 }
640                         }
641                         spin_lock_irqsave(&pjcpu->load_lock, flags);
642                         update_load(cpu);
643                         spin_unlock_irqrestore(&pjcpu->load_lock, flags);
644                         if (cpu != freq->cpu)
645                                 up_read(&pjcpu->enable_sem);
646                 }
647
648                 up_read(&pcpu->enable_sem);
649         }
650         return 0;
651 }
652
653 static struct notifier_block cpufreq_notifier_block = {
654         .notifier_call = cpufreq_interactive_notifier,
655 };
656
657 static unsigned int *get_tokenized_data(const char *buf, int *num_tokens)
658 {
659         const char *cp;
660         int i;
661         int ntokens = 1;
662         unsigned int *tokenized_data;
663         int err = -EINVAL;
664
665         cp = buf;
666         while ((cp = strpbrk(cp + 1, " :")))
667                 ntokens++;
668
669         if (!(ntokens & 0x1))
670                 goto err;
671
672         tokenized_data = kmalloc(ntokens * sizeof(unsigned int), GFP_KERNEL);
673         if (!tokenized_data) {
674                 err = -ENOMEM;
675                 goto err;
676         }
677
678         cp = buf;
679         i = 0;
680         while (i < ntokens) {
681                 if (sscanf(cp, "%u", &tokenized_data[i++]) != 1)
682                         goto err_kfree;
683
684                 cp = strpbrk(cp, " :");
685                 if (!cp)
686                         break;
687                 cp++;
688         }
689
690         if (i != ntokens)
691                 goto err_kfree;
692
693         *num_tokens = ntokens;
694         return tokenized_data;
695
696 err_kfree:
697         kfree(tokenized_data);
698 err:
699         return ERR_PTR(err);
700 }
701
702 static ssize_t show_target_loads(
703         struct cpufreq_interactive_tunables *tunables,
704         char *buf)
705 {
706         int i;
707         ssize_t ret = 0;
708         unsigned long flags;
709
710         spin_lock_irqsave(&tunables->target_loads_lock, flags);
711
712         for (i = 0; i < tunables->ntarget_loads; i++)
713                 ret += sprintf(buf + ret, "%u%s", tunables->target_loads[i],
714                                i & 0x1 ? ":" : " ");
715
716         sprintf(buf + ret - 1, "\n");
717         spin_unlock_irqrestore(&tunables->target_loads_lock, flags);
718         return ret;
719 }
720
721 static ssize_t store_target_loads(
722         struct cpufreq_interactive_tunables *tunables,
723         const char *buf, size_t count)
724 {
725         int ntokens;
726         unsigned int *new_target_loads = NULL;
727         unsigned long flags;
728
729         new_target_loads = get_tokenized_data(buf, &ntokens);
730         if (IS_ERR(new_target_loads))
731                 return PTR_RET(new_target_loads);
732
733         spin_lock_irqsave(&tunables->target_loads_lock, flags);
734         if (tunables->target_loads != default_target_loads)
735                 kfree(tunables->target_loads);
736         tunables->target_loads = new_target_loads;
737         tunables->ntarget_loads = ntokens;
738         spin_unlock_irqrestore(&tunables->target_loads_lock, flags);
739         return count;
740 }
741
742 static ssize_t show_above_hispeed_delay(
743         struct cpufreq_interactive_tunables *tunables, char *buf)
744 {
745         int i;
746         ssize_t ret = 0;
747         unsigned long flags;
748
749         spin_lock_irqsave(&tunables->above_hispeed_delay_lock, flags);
750
751         for (i = 0; i < tunables->nabove_hispeed_delay; i++)
752                 ret += sprintf(buf + ret, "%u%s",
753                                tunables->above_hispeed_delay[i],
754                                i & 0x1 ? ":" : " ");
755
756         sprintf(buf + ret - 1, "\n");
757         spin_unlock_irqrestore(&tunables->above_hispeed_delay_lock, flags);
758         return ret;
759 }
760
761 static ssize_t store_above_hispeed_delay(
762         struct cpufreq_interactive_tunables *tunables,
763         const char *buf, size_t count)
764 {
765         int ntokens;
766         unsigned int *new_above_hispeed_delay = NULL;
767         unsigned long flags;
768
769         new_above_hispeed_delay = get_tokenized_data(buf, &ntokens);
770         if (IS_ERR(new_above_hispeed_delay))
771                 return PTR_RET(new_above_hispeed_delay);
772
773         spin_lock_irqsave(&tunables->above_hispeed_delay_lock, flags);
774         if (tunables->above_hispeed_delay != default_above_hispeed_delay)
775                 kfree(tunables->above_hispeed_delay);
776         tunables->above_hispeed_delay = new_above_hispeed_delay;
777         tunables->nabove_hispeed_delay = ntokens;
778         spin_unlock_irqrestore(&tunables->above_hispeed_delay_lock, flags);
779         return count;
780
781 }
782
783 static ssize_t show_hispeed_freq(struct cpufreq_interactive_tunables *tunables,
784                 char *buf)
785 {
786         return sprintf(buf, "%u\n", tunables->hispeed_freq);
787 }
788
789 static ssize_t store_hispeed_freq(struct cpufreq_interactive_tunables *tunables,
790                 const char *buf, size_t count)
791 {
792         int ret;
793         long unsigned int val;
794
795         ret = strict_strtoul(buf, 0, &val);
796         if (ret < 0)
797                 return ret;
798         tunables->hispeed_freq = val;
799         return count;
800 }
801
802 static ssize_t show_go_hispeed_load(struct cpufreq_interactive_tunables
803                 *tunables, char *buf)
804 {
805         return sprintf(buf, "%lu\n", tunables->go_hispeed_load);
806 }
807
808 static ssize_t store_go_hispeed_load(struct cpufreq_interactive_tunables
809                 *tunables, const char *buf, size_t count)
810 {
811         int ret;
812         unsigned long val;
813
814         ret = strict_strtoul(buf, 0, &val);
815         if (ret < 0)
816                 return ret;
817         tunables->go_hispeed_load = val;
818         return count;
819 }
820
821 static ssize_t show_min_sample_time(struct cpufreq_interactive_tunables
822                 *tunables, char *buf)
823 {
824         return sprintf(buf, "%lu\n", tunables->min_sample_time);
825 }
826
827 static ssize_t store_min_sample_time(struct cpufreq_interactive_tunables
828                 *tunables, const char *buf, size_t count)
829 {
830         int ret;
831         unsigned long val;
832
833         ret = strict_strtoul(buf, 0, &val);
834         if (ret < 0)
835                 return ret;
836         tunables->min_sample_time = val;
837         return count;
838 }
839
840 static ssize_t show_timer_rate(struct cpufreq_interactive_tunables *tunables,
841                 char *buf)
842 {
843         return sprintf(buf, "%lu\n", tunables->timer_rate);
844 }
845
846 static ssize_t store_timer_rate(struct cpufreq_interactive_tunables *tunables,
847                 const char *buf, size_t count)
848 {
849         int ret;
850         unsigned long val;
851
852         ret = strict_strtoul(buf, 0, &val);
853         if (ret < 0)
854                 return ret;
855         tunables->timer_rate = val;
856         return count;
857 }
858
859 static ssize_t show_timer_slack(struct cpufreq_interactive_tunables *tunables,
860                 char *buf)
861 {
862         return sprintf(buf, "%d\n", tunables->timer_slack_val);
863 }
864
865 static ssize_t store_timer_slack(struct cpufreq_interactive_tunables *tunables,
866                 const char *buf, size_t count)
867 {
868         int ret;
869         unsigned long val;
870
871         ret = kstrtol(buf, 10, &val);
872         if (ret < 0)
873                 return ret;
874
875         tunables->timer_slack_val = val;
876         return count;
877 }
878
879 static ssize_t show_boost(struct cpufreq_interactive_tunables *tunables,
880                           char *buf)
881 {
882         return sprintf(buf, "%d\n", tunables->boost_val);
883 }
884
885 static ssize_t store_boost(struct cpufreq_interactive_tunables *tunables,
886                            const char *buf, size_t count)
887 {
888         int ret;
889         unsigned long val;
890
891         ret = kstrtoul(buf, 0, &val);
892         if (ret < 0)
893                 return ret;
894
895         tunables->boost_val = val;
896
897         if (tunables->boost_val) {
898                 trace_cpufreq_interactive_boost("on");
899                 cpufreq_interactive_boost();
900         } else {
901                 trace_cpufreq_interactive_unboost("off");
902         }
903
904         return count;
905 }
906
907 static ssize_t store_boostpulse(struct cpufreq_interactive_tunables *tunables,
908                                 const char *buf, size_t count)
909 {
910         int ret;
911         unsigned long val;
912
913         ret = kstrtoul(buf, 0, &val);
914         if (ret < 0)
915                 return ret;
916
917         tunables->boostpulse_endtime = ktime_to_us(ktime_get()) +
918                 tunables->boostpulse_duration_val;
919         trace_cpufreq_interactive_boost("pulse");
920         cpufreq_interactive_boost();
921         return count;
922 }
923
924 static ssize_t show_boostpulse_duration(struct cpufreq_interactive_tunables
925                 *tunables, char *buf)
926 {
927         return sprintf(buf, "%d\n", tunables->boostpulse_duration_val);
928 }
929
930 static ssize_t store_boostpulse_duration(struct cpufreq_interactive_tunables
931                 *tunables, const char *buf, size_t count)
932 {
933         int ret;
934         unsigned long val;
935
936         ret = kstrtoul(buf, 0, &val);
937         if (ret < 0)
938                 return ret;
939
940         tunables->boostpulse_duration_val = val;
941         return count;
942 }
943
944 static ssize_t show_io_is_busy(struct cpufreq_interactive_tunables *tunables,
945                 char *buf)
946 {
947         return sprintf(buf, "%u\n", tunables->io_is_busy);
948 }
949
950 static ssize_t store_io_is_busy(struct cpufreq_interactive_tunables *tunables,
951                 const char *buf, size_t count)
952 {
953         int ret;
954         unsigned long val;
955
956         ret = kstrtoul(buf, 0, &val);
957         if (ret < 0)
958                 return ret;
959         tunables->io_is_busy = val;
960         return count;
961 }
962
963 /*
964  * Create show/store routines
965  * - sys: One governor instance for complete SYSTEM
966  * - pol: One governor instance per struct cpufreq_policy
967  */
968 #define show_gov_pol_sys(file_name)                                     \
969 static ssize_t show_##file_name##_gov_sys                               \
970 (struct kobject *kobj, struct attribute *attr, char *buf)               \
971 {                                                                       \
972         return show_##file_name(common_tunables, buf);                  \
973 }                                                                       \
974                                                                         \
975 static ssize_t show_##file_name##_gov_pol                               \
976 (struct cpufreq_policy *policy, char *buf)                              \
977 {                                                                       \
978         return show_##file_name(policy->governor_data, buf);            \
979 }
980
981 #define store_gov_pol_sys(file_name)                                    \
982 static ssize_t store_##file_name##_gov_sys                              \
983 (struct kobject *kobj, struct attribute *attr, const char *buf,         \
984         size_t count)                                                   \
985 {                                                                       \
986         return store_##file_name(common_tunables, buf, count);          \
987 }                                                                       \
988                                                                         \
989 static ssize_t store_##file_name##_gov_pol                              \
990 (struct cpufreq_policy *policy, const char *buf, size_t count)          \
991 {                                                                       \
992         return store_##file_name(policy->governor_data, buf, count);    \
993 }
994
995 #define show_store_gov_pol_sys(file_name)                               \
996 show_gov_pol_sys(file_name);                                            \
997 store_gov_pol_sys(file_name)
998
999 show_store_gov_pol_sys(target_loads);
1000 show_store_gov_pol_sys(above_hispeed_delay);
1001 show_store_gov_pol_sys(hispeed_freq);
1002 show_store_gov_pol_sys(go_hispeed_load);
1003 show_store_gov_pol_sys(min_sample_time);
1004 show_store_gov_pol_sys(timer_rate);
1005 show_store_gov_pol_sys(timer_slack);
1006 show_store_gov_pol_sys(boost);
1007 store_gov_pol_sys(boostpulse);
1008 show_store_gov_pol_sys(boostpulse_duration);
1009 show_store_gov_pol_sys(io_is_busy);
1010
1011 #define gov_sys_attr_rw(_name)                                          \
1012 static struct global_attr _name##_gov_sys =                             \
1013 __ATTR(_name, 0644, show_##_name##_gov_sys, store_##_name##_gov_sys)
1014
1015 #define gov_pol_attr_rw(_name)                                          \
1016 static struct freq_attr _name##_gov_pol =                               \
1017 __ATTR(_name, 0644, show_##_name##_gov_pol, store_##_name##_gov_pol)
1018
1019 #define gov_sys_pol_attr_rw(_name)                                      \
1020         gov_sys_attr_rw(_name);                                         \
1021         gov_pol_attr_rw(_name)
1022
1023 gov_sys_pol_attr_rw(target_loads);
1024 gov_sys_pol_attr_rw(above_hispeed_delay);
1025 gov_sys_pol_attr_rw(hispeed_freq);
1026 gov_sys_pol_attr_rw(go_hispeed_load);
1027 gov_sys_pol_attr_rw(min_sample_time);
1028 gov_sys_pol_attr_rw(timer_rate);
1029 gov_sys_pol_attr_rw(timer_slack);
1030 gov_sys_pol_attr_rw(boost);
1031 gov_sys_pol_attr_rw(boostpulse_duration);
1032 gov_sys_pol_attr_rw(io_is_busy);
1033
1034 static struct global_attr boostpulse_gov_sys =
1035         __ATTR(boostpulse, 0200, NULL, store_boostpulse_gov_sys);
1036
1037 static struct freq_attr boostpulse_gov_pol =
1038         __ATTR(boostpulse, 0200, NULL, store_boostpulse_gov_pol);
1039
1040 /* One Governor instance for entire system */
1041 static struct attribute *interactive_attributes_gov_sys[] = {
1042         &target_loads_gov_sys.attr,
1043         &above_hispeed_delay_gov_sys.attr,
1044         &hispeed_freq_gov_sys.attr,
1045         &go_hispeed_load_gov_sys.attr,
1046         &min_sample_time_gov_sys.attr,
1047         &timer_rate_gov_sys.attr,
1048         &timer_slack_gov_sys.attr,
1049         &boost_gov_sys.attr,
1050         &boostpulse_gov_sys.attr,
1051         &boostpulse_duration_gov_sys.attr,
1052         &io_is_busy_gov_sys.attr,
1053         NULL,
1054 };
1055
1056 static struct attribute_group interactive_attr_group_gov_sys = {
1057         .attrs = interactive_attributes_gov_sys,
1058         .name = "interactive",
1059 };
1060
1061 /* Per policy governor instance */
1062 static struct attribute *interactive_attributes_gov_pol[] = {
1063         &target_loads_gov_pol.attr,
1064         &above_hispeed_delay_gov_pol.attr,
1065         &hispeed_freq_gov_pol.attr,
1066         &go_hispeed_load_gov_pol.attr,
1067         &min_sample_time_gov_pol.attr,
1068         &timer_rate_gov_pol.attr,
1069         &timer_slack_gov_pol.attr,
1070         &boost_gov_pol.attr,
1071         &boostpulse_gov_pol.attr,
1072         &boostpulse_duration_gov_pol.attr,
1073         &io_is_busy_gov_pol.attr,
1074         NULL,
1075 };
1076
1077 static struct attribute_group interactive_attr_group_gov_pol = {
1078         .attrs = interactive_attributes_gov_pol,
1079         .name = "interactive",
1080 };
1081
1082 static struct attribute_group *get_sysfs_attr(void)
1083 {
1084         if (have_governor_per_policy())
1085                 return &interactive_attr_group_gov_pol;
1086         else
1087                 return &interactive_attr_group_gov_sys;
1088 }
1089
1090 static int cpufreq_interactive_idle_notifier(struct notifier_block *nb,
1091                                              unsigned long val,
1092                                              void *data)
1093 {
1094         switch (val) {
1095         case IDLE_START:
1096                 cpufreq_interactive_idle_start();
1097                 break;
1098         case IDLE_END:
1099                 cpufreq_interactive_idle_end();
1100                 break;
1101         }
1102
1103         return 0;
1104 }
1105
1106 static struct notifier_block cpufreq_interactive_idle_nb = {
1107         .notifier_call = cpufreq_interactive_idle_notifier,
1108 };
1109
1110 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
1111                 unsigned int event)
1112 {
1113         int rc;
1114         unsigned int j;
1115         struct cpufreq_interactive_cpuinfo *pcpu;
1116         struct cpufreq_frequency_table *freq_table;
1117         struct cpufreq_interactive_tunables *tunables;
1118
1119         if (have_governor_per_policy())
1120                 tunables = policy->governor_data;
1121         else
1122                 tunables = common_tunables;
1123
1124         WARN_ON(!tunables && (event != CPUFREQ_GOV_POLICY_INIT));
1125
1126         switch (event) {
1127         case CPUFREQ_GOV_POLICY_INIT:
1128                 if (have_governor_per_policy()) {
1129                         WARN_ON(tunables);
1130                 } else if (tunables) {
1131                         tunables->usage_count++;
1132                         policy->governor_data = tunables;
1133                         return 0;
1134                 }
1135
1136                 tunables = kzalloc(sizeof(*tunables), GFP_KERNEL);
1137                 if (!tunables) {
1138                         pr_err("%s: POLICY_INIT: kzalloc failed\n", __func__);
1139                         return -ENOMEM;
1140                 }
1141
1142                 tunables->usage_count = 1;
1143                 tunables->above_hispeed_delay = default_above_hispeed_delay;
1144                 tunables->nabove_hispeed_delay =
1145                         ARRAY_SIZE(default_above_hispeed_delay);
1146                 tunables->go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
1147                 tunables->target_loads = default_target_loads;
1148                 tunables->ntarget_loads = ARRAY_SIZE(default_target_loads);
1149                 tunables->min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
1150                 tunables->timer_rate = DEFAULT_TIMER_RATE;
1151                 tunables->boostpulse_duration_val = DEFAULT_MIN_SAMPLE_TIME;
1152                 tunables->timer_slack_val = DEFAULT_TIMER_SLACK;
1153
1154                 spin_lock_init(&tunables->target_loads_lock);
1155                 spin_lock_init(&tunables->above_hispeed_delay_lock);
1156
1157                 policy->governor_data = tunables;
1158                 if (!have_governor_per_policy())
1159                         common_tunables = tunables;
1160
1161                 rc = sysfs_create_group(get_governor_parent_kobj(policy),
1162                                 get_sysfs_attr());
1163                 if (rc) {
1164                         kfree(tunables);
1165                         policy->governor_data = NULL;
1166                         if (!have_governor_per_policy())
1167                                 common_tunables = NULL;
1168                         return rc;
1169                 }
1170
1171                 if (!policy->governor->initialized) {
1172                         idle_notifier_register(&cpufreq_interactive_idle_nb);
1173                         cpufreq_register_notifier(&cpufreq_notifier_block,
1174                                         CPUFREQ_TRANSITION_NOTIFIER);
1175                 }
1176
1177                 break;
1178
1179         case CPUFREQ_GOV_POLICY_EXIT:
1180                 if (!--tunables->usage_count) {
1181                         if (policy->governor->initialized == 1) {
1182                                 cpufreq_unregister_notifier(&cpufreq_notifier_block,
1183                                                 CPUFREQ_TRANSITION_NOTIFIER);
1184                                 idle_notifier_unregister(&cpufreq_interactive_idle_nb);
1185                         }
1186
1187                         sysfs_remove_group(get_governor_parent_kobj(policy),
1188                                         get_sysfs_attr());
1189                         kfree(tunables);
1190                         common_tunables = NULL;
1191                 }
1192
1193                 policy->governor_data = NULL;
1194                 break;
1195
1196         case CPUFREQ_GOV_START:
1197                 mutex_lock(&gov_lock);
1198
1199                 freq_table = cpufreq_frequency_get_table(policy->cpu);
1200                 if (!tunables->hispeed_freq)
1201                         tunables->hispeed_freq = policy->max;
1202
1203                 for_each_cpu(j, policy->cpus) {
1204                         pcpu = &per_cpu(cpuinfo, j);
1205                         pcpu->policy = policy;
1206                         pcpu->target_freq = policy->cur;
1207                         pcpu->freq_table = freq_table;
1208                         pcpu->floor_freq = pcpu->target_freq;
1209                         pcpu->floor_validate_time =
1210                                 ktime_to_us(ktime_get());
1211                         pcpu->hispeed_validate_time =
1212                                 pcpu->floor_validate_time;
1213                         down_write(&pcpu->enable_sem);
1214                         del_timer_sync(&pcpu->cpu_timer);
1215                         del_timer_sync(&pcpu->cpu_slack_timer);
1216                         cpufreq_interactive_timer_start(tunables, j);
1217                         pcpu->governor_enabled = 1;
1218                         up_write(&pcpu->enable_sem);
1219                 }
1220
1221                 mutex_unlock(&gov_lock);
1222                 break;
1223
1224         case CPUFREQ_GOV_STOP:
1225                 mutex_lock(&gov_lock);
1226                 for_each_cpu(j, policy->cpus) {
1227                         pcpu = &per_cpu(cpuinfo, j);
1228                         down_write(&pcpu->enable_sem);
1229                         pcpu->governor_enabled = 0;
1230                         del_timer_sync(&pcpu->cpu_timer);
1231                         del_timer_sync(&pcpu->cpu_slack_timer);
1232                         up_write(&pcpu->enable_sem);
1233                 }
1234
1235                 mutex_unlock(&gov_lock);
1236                 break;
1237
1238         case CPUFREQ_GOV_LIMITS:
1239                 if (policy->max < policy->cur)
1240                         __cpufreq_driver_target(policy,
1241                                         policy->max, CPUFREQ_RELATION_H);
1242                 else if (policy->min > policy->cur)
1243                         __cpufreq_driver_target(policy,
1244                                         policy->min, CPUFREQ_RELATION_L);
1245                 for_each_cpu(j, policy->cpus) {
1246                         pcpu = &per_cpu(cpuinfo, j);
1247
1248                         /* hold write semaphore to avoid race */
1249                         down_write(&pcpu->enable_sem);
1250                         if (pcpu->governor_enabled == 0) {
1251                                 up_write(&pcpu->enable_sem);
1252                                 continue;
1253                         }
1254
1255                         /* update target_freq firstly */
1256                         if (policy->max < pcpu->target_freq)
1257                                 pcpu->target_freq = policy->max;
1258                         else if (policy->min > pcpu->target_freq)
1259                                 pcpu->target_freq = policy->min;
1260
1261                         /* Reschedule timer.
1262                          * Delete the timers, else the timer callback may
1263                          * return without re-arm the timer when failed
1264                          * acquire the semaphore. This race may cause timer
1265                          * stopped unexpectedly.
1266                          */
1267                         del_timer_sync(&pcpu->cpu_timer);
1268                         del_timer_sync(&pcpu->cpu_slack_timer);
1269                         cpufreq_interactive_timer_start(tunables, j);
1270                         up_write(&pcpu->enable_sem);
1271                 }
1272                 break;
1273         }
1274         return 0;
1275 }
1276
1277 #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
1278 static
1279 #endif
1280 struct cpufreq_governor cpufreq_gov_interactive = {
1281         .name = "interactive",
1282         .governor = cpufreq_governor_interactive,
1283         .max_transition_latency = 10000000,
1284         .owner = THIS_MODULE,
1285 };
1286
1287 static void cpufreq_interactive_nop_timer(unsigned long data)
1288 {
1289 }
1290
1291 static int __init cpufreq_interactive_init(void)
1292 {
1293         unsigned int i;
1294         struct cpufreq_interactive_cpuinfo *pcpu;
1295         struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
1296
1297         /* Initalize per-cpu timers */
1298         for_each_possible_cpu(i) {
1299                 pcpu = &per_cpu(cpuinfo, i);
1300                 init_timer_deferrable(&pcpu->cpu_timer);
1301                 pcpu->cpu_timer.function = cpufreq_interactive_timer;
1302                 pcpu->cpu_timer.data = i;
1303                 init_timer(&pcpu->cpu_slack_timer);
1304                 pcpu->cpu_slack_timer.function = cpufreq_interactive_nop_timer;
1305                 spin_lock_init(&pcpu->load_lock);
1306                 init_rwsem(&pcpu->enable_sem);
1307         }
1308
1309         spin_lock_init(&speedchange_cpumask_lock);
1310         mutex_init(&gov_lock);
1311         speedchange_task =
1312                 kthread_create(cpufreq_interactive_speedchange_task, NULL,
1313                                "cfinteractive");
1314         if (IS_ERR(speedchange_task))
1315                 return PTR_ERR(speedchange_task);
1316
1317         sched_setscheduler_nocheck(speedchange_task, SCHED_FIFO, &param);
1318         get_task_struct(speedchange_task);
1319
1320         /* NB: wake up so the thread does not look hung to the freezer */
1321         wake_up_process(speedchange_task);
1322
1323         return cpufreq_register_governor(&cpufreq_gov_interactive);
1324 }
1325
1326 #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE
1327 fs_initcall(cpufreq_interactive_init);
1328 #else
1329 module_init(cpufreq_interactive_init);
1330 #endif
1331
1332 static void __exit cpufreq_interactive_exit(void)
1333 {
1334         cpufreq_unregister_governor(&cpufreq_gov_interactive);
1335         kthread_stop(speedchange_task);
1336         put_task_struct(speedchange_task);
1337 }
1338
1339 module_exit(cpufreq_interactive_exit);
1340
1341 MODULE_AUTHOR("Mike Chan <mike@android.com>");
1342 MODULE_DESCRIPTION("'cpufreq_interactive' - A cpufreq governor for "
1343         "Latency sensitive workloads");
1344 MODULE_LICENSE("GPL");