sched: Improve the scheduler
This change is for general scheduler improvement. Change-Id: I50d41aa3338803cbd45ff6314b2bb3978c59282b Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
This commit is contained in:
parent
029925a787
commit
d31aa4ff20
@ -31,6 +31,7 @@
|
||||
#include <linux/syscore_ops.h>
|
||||
#include <linux/tick.h>
|
||||
#include <linux/sched/topology.h>
|
||||
#include <linux/sched/sysctl.h>
|
||||
|
||||
#include <trace/events/power.h>
|
||||
|
||||
@ -658,11 +659,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;
|
||||
|
@ -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
|
||||
|
@ -959,4 +959,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 */
|
||||
|
@ -165,7 +165,7 @@ extern int sched_energy_aware_handler(struct ctl_table *table, int write,
|
||||
|
||||
#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 */
|
||||
|
@ -290,7 +290,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;
|
||||
|
@ -5814,9 +5814,8 @@ out_put_task:
|
||||
EXPORT_SYMBOL_GPL(sched_setaffinity);
|
||||
|
||||
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;
|
||||
@ -5868,19 +5867,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)
|
||||
{
|
||||
@ -5911,7 +5897,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;
|
||||
}
|
||||
|
@ -823,15 +823,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,
|
||||
|
Loading…
Reference in New Issue
Block a user