Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49c0c6d9 authored by Joonwoo Park's avatar Joonwoo Park Committed by Matt Wagantall
Browse files

sched: check HMP scheduler tunables validity



Check tunables validity to take valid values only.

CRs-fixed: 812443
Change-Id: Ibb9ec0d6946247068174ab7abe775a6389412d5b
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
parent 957da6a7
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -3649,17 +3649,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);
}

/*
@@ -3725,11 +3746,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;
+9 −4
Original line number Diff line number Diff line
@@ -306,14 +306,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",
@@ -392,7 +394,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",
@@ -441,7 +444,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