diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index dfb6f8dd4010..9254eebd5702 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -657,11 +658,40 @@ static ssize_t show_##file_name \ } show_one(cpuinfo_min_freq, cpuinfo.min_freq); -show_one(cpuinfo_max_freq, cpuinfo.max_freq); show_one(cpuinfo_transition_latency, cpuinfo.transition_latency); show_one(scaling_min_freq, min); show_one(scaling_max_freq, max); +unsigned int cpuinfo_max_freq_cached; + +static bool should_use_cached_freq(int cpu) +{ + /* This is a safe check. may not be needed */ + if (!cpuinfo_max_freq_cached) + return false; + + /* + * perfd already configure sched_lib_mask_force to + * 0xf0 from user space. so re-using it. + */ + if (!(BIT(cpu) & sched_lib_mask_force)) + return false; + + return is_sched_lib_based_app(current->pid); +} + +static ssize_t show_cpuinfo_max_freq(struct cpufreq_policy *policy, char *buf) +{ + unsigned int freq = policy->cpuinfo.max_freq; + + if (should_use_cached_freq(policy->cpu)) + freq = cpuinfo_max_freq_cached << 1; + else + freq = policy->cpuinfo.max_freq; + + return scnprintf(buf, PAGE_SIZE, "%u\n", freq); +} + __weak unsigned int arch_freq_get_on_cpu(int cpu) { return 0; diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 3bbbf9e6960c..7f205ec61244 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -58,6 +58,9 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy, policy->min = policy->cpuinfo.min_freq = min_freq; policy->max = policy->cpuinfo.max_freq = max_freq; + if (max_freq > cpuinfo_max_freq_cached) + cpuinfo_max_freq_cached = max_freq; + if (policy->min == ~0) return -EINVAL; else diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index fb519ed77374..e7e7e793aeb0 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -937,4 +937,6 @@ unsigned int cpufreq_generic_get(unsigned int cpu); int cpufreq_generic_init(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table, unsigned int transition_latency); + +extern unsigned int cpuinfo_max_freq_cached; #endif /* _LINUX_CPUFREQ_H */ diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 1375fd7dcf5a..53059dad7b36 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -133,7 +133,7 @@ extern int sched_little_cluster_coloc_fmin_khz_handler(struct ctl_table *table, #define LIB_PATH_LENGTH 512 extern char sched_lib_name[LIB_PATH_LENGTH]; -extern unsigned int sched_lib_mask_check; extern unsigned int sched_lib_mask_force; +extern bool is_sched_lib_based_app(pid_t pid); #endif /* _LINUX_SCHED_SYSCTL_H */ diff --git a/kernel/compat.c b/kernel/compat.c index f3925fca9339..7e83733d4c95 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -334,7 +334,7 @@ COMPAT_SYSCALL_DEFINE3(sched_setaffinity, compat_pid_t, pid, if (retval) goto out; - retval = msm_sched_setaffinity(pid, new_mask); + retval = sched_setaffinity(pid, new_mask); out: free_cpumask_var(new_mask); return retval; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 12bea110ccb5..beebafd3e8cf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4903,9 +4903,8 @@ out_put_task: } char sched_lib_name[LIB_PATH_LENGTH]; -unsigned int sched_lib_mask_check; unsigned int sched_lib_mask_force; -static inline bool is_sched_lib_based_app(pid_t pid) +bool is_sched_lib_based_app(pid_t pid) { const char *name = NULL; struct vm_area_struct *vma; @@ -4957,19 +4956,6 @@ put_task_struct: return found; } -long msm_sched_setaffinity(pid_t pid, struct cpumask *new_mask) -{ - if (sched_lib_mask_check != 0 && sched_lib_mask_force != 0 && - (cpumask_bits(new_mask)[0] == sched_lib_mask_check) && - is_sched_lib_based_app(pid)) { - - cpumask_t forced_mask = { {sched_lib_mask_force} }; - - cpumask_copy(new_mask, &forced_mask); - } - return sched_setaffinity(pid, new_mask); -} - static int get_user_cpu_mask(unsigned long __user *user_mask_ptr, unsigned len, struct cpumask *new_mask) { @@ -5000,7 +4986,7 @@ SYSCALL_DEFINE3(sched_setaffinity, pid_t, pid, unsigned int, len, retval = get_user_cpu_mask(user_mask_ptr, len, new_mask); if (retval == 0) - retval = msm_sched_setaffinity(pid, new_mask); + retval = sched_setaffinity(pid, new_mask); free_cpumask_var(new_mask); return retval; } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 450e5cf523ac..578242a32bea 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -595,15 +595,6 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dostring, }, - { - .procname = "sched_lib_mask_check", - .data = &sched_lib_mask_check, - .maxlen = sizeof(unsigned int), - .mode = 0644, - .proc_handler = proc_douintvec_minmax, - .extra1 = &zero, - .extra2 = &two_hundred_fifty_five, - }, { .procname = "sched_lib_mask_force", .data = &sched_lib_mask_force,