Loading drivers/cpufreq/cpufreq_interactive.c +204 −162 Original line number Diff line number Diff line Loading @@ -346,10 +346,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * than or equal to the target load. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, loadadjfreq / tl, CPUFREQ_RELATION_L, &index)) break; index = cpufreq_frequency_table_target(&pcpu->p_nolim, loadadjfreq / tl, CPUFREQ_RELATION_L); freq = pcpu->freq_table[index].frequency; if (freq > prevfreq) { Loading @@ -361,11 +360,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * Find the highest frequency that is less * than freqmax. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, freqmax - 1, CPUFREQ_RELATION_H, &index)) break; index = cpufreq_frequency_table_target( &pcpu->p_nolim, freqmax - 1, CPUFREQ_RELATION_H); freq = pcpu->freq_table[index].frequency; if (freq == freqmin) { Loading @@ -388,11 +385,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * Find the lowest frequency that is higher * than freqmin. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, freqmin + 1, CPUFREQ_RELATION_L, &index)) break; index = cpufreq_frequency_table_target( &pcpu->p_nolim, freqmin + 1, CPUFREQ_RELATION_L); freq = pcpu->freq_table[index].frequency; /* Loading Loading @@ -605,13 +600,8 @@ static void cpufreq_interactive_timer(unsigned long data) ppol->hispeed_validate_time = now; if (cpufreq_frequency_table_target(&ppol->p_nolim, ppol->freq_table, new_freq, CPUFREQ_RELATION_L, &index)) { spin_unlock_irqrestore(&ppol->target_freq_lock, flags); goto rearm; } index = cpufreq_frequency_table_target(&ppol->p_nolim, new_freq, CPUFREQ_RELATION_L); new_freq = ppol->freq_table[index].frequency; /* Loading Loading @@ -1644,12 +1634,20 @@ static struct cpufreq_interactive_tunables *get_tunables( return cached_common_tunables; } static int cpufreq_governor_interactive(struct cpufreq_policy *policy, unsigned int event) /* Interactive Governor callbacks */ struct interactive_governor { struct cpufreq_governor gov; unsigned int usage_count; }; static struct interactive_governor interactive_gov; #define CPU_FREQ_GOV_INTERACTIVE (&interactive_gov.gov) int cpufreq_interactive_init(struct cpufreq_policy *policy) { int rc; struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_frequency_table *freq_table; struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) Loading @@ -1657,10 +1655,6 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, else tunables = common_tunables; BUG_ON(!tunables && (event != CPUFREQ_GOV_POLICY_INIT)); switch (event) { case CPUFREQ_GOV_POLICY_INIT: ppol = get_policyinfo(policy); if (IS_ERR(ppol)) return PTR_ERR(ppol); Loading Loading @@ -1698,7 +1692,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, return rc; } if (!policy->governor->initialized) if (!interactive_gov.usage_count++) cpufreq_register_notifier(&cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); Loading @@ -1714,14 +1708,26 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, else cached_common_tunables = tunables; break; return 0; } void cpufreq_interactive_exit(struct cpufreq_policy *policy) { struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); case CPUFREQ_GOV_POLICY_EXIT: cpumask_andnot(&controlled_cpus, &controlled_cpus, policy->related_cpus); sched_update_freq_max_load(cpu_possible_mask); if (!--tunables->usage_count) { if (policy->governor->initialized == 1) /* Last policy using the governor ? */ if (!--interactive_gov.usage_count) cpufreq_unregister_notifier(&cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); Loading @@ -1735,13 +1741,23 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, if (tunables->use_sched_load) cpufreq_interactive_disable_sched_input(tunables); } break; int cpufreq_interactive_start(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_frequency_table *freq_table; struct cpufreq_interactive_tunables *tunables; case CPUFREQ_GOV_START: if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); mutex_lock(&gov_lock); freq_table = cpufreq_frequency_get_table(policy->cpu); freq_table = policy->freq_table; if (!tunables->hispeed_freq) tunables->hispeed_freq = policy->max; Loading Loading @@ -1769,9 +1785,21 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->reject_notification = false; mutex_unlock(&gov_lock); break; return 0; } void cpufreq_interactive_stop(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); case CPUFREQ_GOV_STOP: mutex_lock(&gov_lock); ppol = per_cpu(polinfo, policy->cpu); Loading @@ -1785,9 +1813,19 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->reject_notification = false; mutex_unlock(&gov_lock); break; } void cpufreq_interactive_limits(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_interactive_tunables *tunables; case CPUFREQ_GOV_LIMITS: if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); ppol = per_cpu(polinfo, policy->cpu); __cpufreq_driver_target(policy, Loading @@ -1801,23 +1839,22 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->min_freq = policy->min; } up_read(&ppol->enable_sem); break; } return 0; } #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE static #endif struct cpufreq_governor cpufreq_gov_interactive = { static struct interactive_governor interactive_gov = { .gov = { .name = "interactive", .governor = cpufreq_governor_interactive, .max_transition_latency = 10000000, .owner = THIS_MODULE, .init = cpufreq_interactive_init, .exit = cpufreq_interactive_exit, .start = cpufreq_interactive_start, .stop = cpufreq_interactive_stop, .limits = cpufreq_interactive_limits, } }; static int __init cpufreq_interactive_init(void) static int __init cpufreq_interactive_gov_init(void) { struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; Loading @@ -1836,20 +1873,25 @@ static int __init cpufreq_interactive_init(void) /* NB: wake up so the thread does not look hung to the freezer */ wake_up_process_no_notif(speedchange_task); return cpufreq_register_governor(&cpufreq_gov_interactive); return cpufreq_register_governor(CPU_FREQ_GOV_INTERACTIVE); } #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE fs_initcall(cpufreq_interactive_init); struct cpufreq_governor *cpufreq_default_governor(void) { return CPU_FREQ_GOV_INTERACTIVE; } fs_initcall(cpufreq_interactive_gov_init); #else module_init(cpufreq_interactive_init); module_init(cpufreq_interactive_gov_init); #endif static void __exit cpufreq_interactive_exit(void) static void __exit cpufreq_interactive_gov_exit(void) { int cpu; cpufreq_unregister_governor(&cpufreq_gov_interactive); cpufreq_unregister_governor(CPU_FREQ_GOV_INTERACTIVE); kthread_stop(speedchange_task); put_task_struct(speedchange_task); Loading @@ -1857,7 +1899,7 @@ static void __exit cpufreq_interactive_exit(void) free_policyinfo(cpu); } module_exit(cpufreq_interactive_exit); module_exit(cpufreq_interactive_gov_exit); MODULE_AUTHOR("Mike Chan <mike@android.com>"); MODULE_DESCRIPTION("'cpufreq_interactive' - A cpufreq governor for " Loading Loading
drivers/cpufreq/cpufreq_interactive.c +204 −162 Original line number Diff line number Diff line Loading @@ -346,10 +346,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * than or equal to the target load. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, loadadjfreq / tl, CPUFREQ_RELATION_L, &index)) break; index = cpufreq_frequency_table_target(&pcpu->p_nolim, loadadjfreq / tl, CPUFREQ_RELATION_L); freq = pcpu->freq_table[index].frequency; if (freq > prevfreq) { Loading @@ -361,11 +360,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * Find the highest frequency that is less * than freqmax. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, freqmax - 1, CPUFREQ_RELATION_H, &index)) break; index = cpufreq_frequency_table_target( &pcpu->p_nolim, freqmax - 1, CPUFREQ_RELATION_H); freq = pcpu->freq_table[index].frequency; if (freq == freqmin) { Loading @@ -388,11 +385,9 @@ static unsigned int choose_freq(struct cpufreq_interactive_policyinfo *pcpu, * Find the lowest frequency that is higher * than freqmin. */ if (cpufreq_frequency_table_target( &pcpu->p_nolim, pcpu->freq_table, freqmin + 1, CPUFREQ_RELATION_L, &index)) break; index = cpufreq_frequency_table_target( &pcpu->p_nolim, freqmin + 1, CPUFREQ_RELATION_L); freq = pcpu->freq_table[index].frequency; /* Loading Loading @@ -605,13 +600,8 @@ static void cpufreq_interactive_timer(unsigned long data) ppol->hispeed_validate_time = now; if (cpufreq_frequency_table_target(&ppol->p_nolim, ppol->freq_table, new_freq, CPUFREQ_RELATION_L, &index)) { spin_unlock_irqrestore(&ppol->target_freq_lock, flags); goto rearm; } index = cpufreq_frequency_table_target(&ppol->p_nolim, new_freq, CPUFREQ_RELATION_L); new_freq = ppol->freq_table[index].frequency; /* Loading Loading @@ -1644,12 +1634,20 @@ static struct cpufreq_interactive_tunables *get_tunables( return cached_common_tunables; } static int cpufreq_governor_interactive(struct cpufreq_policy *policy, unsigned int event) /* Interactive Governor callbacks */ struct interactive_governor { struct cpufreq_governor gov; unsigned int usage_count; }; static struct interactive_governor interactive_gov; #define CPU_FREQ_GOV_INTERACTIVE (&interactive_gov.gov) int cpufreq_interactive_init(struct cpufreq_policy *policy) { int rc; struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_frequency_table *freq_table; struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) Loading @@ -1657,10 +1655,6 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, else tunables = common_tunables; BUG_ON(!tunables && (event != CPUFREQ_GOV_POLICY_INIT)); switch (event) { case CPUFREQ_GOV_POLICY_INIT: ppol = get_policyinfo(policy); if (IS_ERR(ppol)) return PTR_ERR(ppol); Loading Loading @@ -1698,7 +1692,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, return rc; } if (!policy->governor->initialized) if (!interactive_gov.usage_count++) cpufreq_register_notifier(&cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); Loading @@ -1714,14 +1708,26 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, else cached_common_tunables = tunables; break; return 0; } void cpufreq_interactive_exit(struct cpufreq_policy *policy) { struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); case CPUFREQ_GOV_POLICY_EXIT: cpumask_andnot(&controlled_cpus, &controlled_cpus, policy->related_cpus); sched_update_freq_max_load(cpu_possible_mask); if (!--tunables->usage_count) { if (policy->governor->initialized == 1) /* Last policy using the governor ? */ if (!--interactive_gov.usage_count) cpufreq_unregister_notifier(&cpufreq_notifier_block, CPUFREQ_TRANSITION_NOTIFIER); Loading @@ -1735,13 +1741,23 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, if (tunables->use_sched_load) cpufreq_interactive_disable_sched_input(tunables); } break; int cpufreq_interactive_start(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_frequency_table *freq_table; struct cpufreq_interactive_tunables *tunables; case CPUFREQ_GOV_START: if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); mutex_lock(&gov_lock); freq_table = cpufreq_frequency_get_table(policy->cpu); freq_table = policy->freq_table; if (!tunables->hispeed_freq) tunables->hispeed_freq = policy->max; Loading Loading @@ -1769,9 +1785,21 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->reject_notification = false; mutex_unlock(&gov_lock); break; return 0; } void cpufreq_interactive_stop(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_interactive_tunables *tunables; if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); case CPUFREQ_GOV_STOP: mutex_lock(&gov_lock); ppol = per_cpu(polinfo, policy->cpu); Loading @@ -1785,9 +1813,19 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->reject_notification = false; mutex_unlock(&gov_lock); break; } void cpufreq_interactive_limits(struct cpufreq_policy *policy) { struct cpufreq_interactive_policyinfo *ppol; struct cpufreq_interactive_tunables *tunables; case CPUFREQ_GOV_LIMITS: if (have_governor_per_policy()) tunables = policy->governor_data; else tunables = common_tunables; BUG_ON(!tunables); ppol = per_cpu(polinfo, policy->cpu); __cpufreq_driver_target(policy, Loading @@ -1801,23 +1839,22 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, ppol->min_freq = policy->min; } up_read(&ppol->enable_sem); break; } return 0; } #ifndef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE static #endif struct cpufreq_governor cpufreq_gov_interactive = { static struct interactive_governor interactive_gov = { .gov = { .name = "interactive", .governor = cpufreq_governor_interactive, .max_transition_latency = 10000000, .owner = THIS_MODULE, .init = cpufreq_interactive_init, .exit = cpufreq_interactive_exit, .start = cpufreq_interactive_start, .stop = cpufreq_interactive_stop, .limits = cpufreq_interactive_limits, } }; static int __init cpufreq_interactive_init(void) static int __init cpufreq_interactive_gov_init(void) { struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; Loading @@ -1836,20 +1873,25 @@ static int __init cpufreq_interactive_init(void) /* NB: wake up so the thread does not look hung to the freezer */ wake_up_process_no_notif(speedchange_task); return cpufreq_register_governor(&cpufreq_gov_interactive); return cpufreq_register_governor(CPU_FREQ_GOV_INTERACTIVE); } #ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE fs_initcall(cpufreq_interactive_init); struct cpufreq_governor *cpufreq_default_governor(void) { return CPU_FREQ_GOV_INTERACTIVE; } fs_initcall(cpufreq_interactive_gov_init); #else module_init(cpufreq_interactive_init); module_init(cpufreq_interactive_gov_init); #endif static void __exit cpufreq_interactive_exit(void) static void __exit cpufreq_interactive_gov_exit(void) { int cpu; cpufreq_unregister_governor(&cpufreq_gov_interactive); cpufreq_unregister_governor(CPU_FREQ_GOV_INTERACTIVE); kthread_stop(speedchange_task); put_task_struct(speedchange_task); Loading @@ -1857,7 +1899,7 @@ static void __exit cpufreq_interactive_exit(void) free_policyinfo(cpu); } module_exit(cpufreq_interactive_exit); module_exit(cpufreq_interactive_gov_exit); MODULE_AUTHOR("Mike Chan <mike@android.com>"); MODULE_DESCRIPTION("'cpufreq_interactive' - A cpufreq governor for " Loading