From 561c96abe1014a20d72ca1b7cde27ce7d030f3c1 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 24 May 2019 19:18:36 -0700 Subject: [PATCH] Revert "sched: Improve the scheduler" This reverts commit a3dd94a1bb80ec98924070f28ba80d93a4d559a6. Bug:133481659 Test: build Change-Id: Ib23609315f3446223521612621fe54469537c172 Signed-off-by: Wei Wang --- drivers/cpufreq/cpufreq.c | 32 ++------------------------------ drivers/cpufreq/freq_table.c | 3 --- include/linux/cpufreq.h | 2 -- include/linux/sched/sysctl.h | 2 +- kernel/compat.c | 2 +- kernel/sched/core.c | 18 ++++++++++++++++-- kernel/sysctl.c | 9 +++++++++ 7 files changed, 29 insertions(+), 39 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 5aa6f91831d5..60d0a4de82f3 100755 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -660,40 +661,11 @@ 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 df38cc64a87a..deafbdfa31d1 100755 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c @@ -62,9 +62,6 @@ 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 834403072a70..e0f6d42b3622 100755 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -957,6 +957,4 @@ 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 c4da504fbfc0..72e441cc7575 100755 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -136,7 +136,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 45ae3ace49c2..8a06a1477449 100755 --- 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 = sched_setaffinity(pid, new_mask); + retval = msm_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 91e357b56d90..bdec84524e71 100755 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4932,8 +4932,9 @@ out_put_task: } char sched_lib_name[LIB_PATH_LENGTH]; +unsigned int sched_lib_mask_check; unsigned int sched_lib_mask_force; -bool is_sched_lib_based_app(pid_t pid) +static inline bool is_sched_lib_based_app(pid_t pid) { const char *name = NULL; struct vm_area_struct *vma; @@ -4985,6 +4986,19 @@ 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) { @@ -5015,7 +5029,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 = sched_setaffinity(pid, new_mask); + retval = msm_sched_setaffinity(pid, new_mask); free_cpumask_var(new_mask); return retval; } diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 3280774e1d69..396eb8e7bc33 100755 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -644,6 +644,15 @@ 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,