sched: check HMP scheduler tunables validity

Check tunables validity to take valid values only.

CRs-fixed: 812443
Change-Id: Ibb9ec0d6946247068174ab7abe775a6389412d5b
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
This commit is contained in:
Joonwoo Park 2015-03-27 10:03:59 -07:00
parent 9b352820cb
commit 4251f58faa
2 changed files with 33 additions and 12 deletions

View file

@ -2573,17 +2573,38 @@ void post_big_small_task_count_change(const struct cpumask *cpus)
DEFINE_MUTEX(policy_mutex);
#ifdef CONFIG_SCHED_FREQ_INPUT
static inline int invalid_value_freq_input(unsigned int *data)
{
if (data == &sysctl_sched_migration_fixup)
return !(*data == 0 || *data == 1);
if (data == &sysctl_sched_freq_account_wait_time)
return !(*data == 0 || *data == 1);
return 0;
}
#else
static inline int invalid_value_freq_input(unsigned int *data)
{
return 0;
}
#endif
static inline int invalid_value(unsigned int *data)
{
int val = *data;
unsigned int val = *data;
if (data == &sysctl_sched_ravg_hist_size)
return (val < 2 || val > RAVG_HIST_SIZE_MAX);
if (data == &sysctl_sched_window_stats_policy)
return (val >= WINDOW_STATS_INVALID_POLICY);
return val >= WINDOW_STATS_INVALID_POLICY;
return 0;
if (data == &sysctl_sched_account_wait_time)
return !(val == 0 || val == 1);
return invalid_value_freq_input(data);
}
/*
@ -2649,11 +2670,6 @@ int sched_hmp_proc_update_handler(struct ctl_table *table, int write,
sched_min_runtime = ((u64) sysctl_sched_min_runtime) * 1000;
return 0;
}
if ((sysctl_sched_downmigrate_pct > sysctl_sched_upmigrate_pct) ||
*data > 100) {
*data = old_val;
return -EINVAL;
}
if (data == (unsigned int *)&sysctl_sched_upmigrate_min_nice)
update_min_nice = 1;

View file

@ -309,14 +309,16 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_sched_freq_inc_notify,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
},
{
.procname = "sched_freq_dec_notify",
.data = &sysctl_sched_freq_dec_notify,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
},
{
.procname = "sched_migration_fixup",
@ -395,7 +397,8 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_sched_spill_nr_run,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
},
{
.procname = "sched_upmigrate",
@ -444,7 +447,9 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_sched_enable_power_aware,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec,
.proc_handler = proc_dointvec_minmax,
.extra1 = &zero,
.extra2 = &one,
},
#endif /* CONFIG_SCHED_HMP */
#ifdef CONFIG_SCHED_DEBUG