From 00b29ff45534314b54a018aba0e9d9a11f3bac9a Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Thu, 2 Feb 2017 14:24:34 +0530 Subject: [PATCH 1/2] sysctl: disallow setting sched_time_avg_ms to 0 The sched average period can not be 0, disallow setting it to 0. Otherwise CPUs stuck in sched_avg_update(). Change-Id: Ib9fcc5b35dface09d848ba7a737dc4ac0f05d8ee Signed-off-by: Pavankumar Kondeti --- kernel/sysctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index a2a87c3ad44e..210d73fe7daa 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -591,7 +591,8 @@ static struct ctl_table kern_table[] = { .data = &sysctl_sched_time_avg, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, + .extra1 = &one, }, { .procname = "sched_shares_window_ns", From 00861ed665330b2749a7fc6439cc559fe685c0bf Mon Sep 17 00:00:00 2001 From: Pavankumar Kondeti Date: Fri, 3 Feb 2017 10:39:40 +0530 Subject: [PATCH 2/2] sysctl: define upper limit for sched_freq_reporting_policy Setting sched_freq_reporting_policy tunable to an unsupported values results in a warning from the scheduler. The previous policy setting is also lost. As sched_freq_reporting_policy can not be set to an incorrect value now, remove the WARN_ON_ONCE from the scheduler. Change-Id: I58d7e5dfefb7d11d2309bc05a1dd66acdc11b766 Signed-off-by: Pavankumar Kondeti --- include/linux/sched/sysctl.h | 8 ++++++++ kernel/sched/hmp.c | 2 +- kernel/sched/sched.h | 4 ---- kernel/sysctl.c | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 418eb97110a3..ef8a092251aa 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -45,6 +45,14 @@ extern unsigned int sysctl_sched_initial_task_util; extern unsigned int sysctl_sched_cstate_aware; #ifdef CONFIG_SCHED_HMP + +enum freq_reporting_policy { + FREQ_REPORT_MAX_CPU_LOAD_TOP_TASK, + FREQ_REPORT_CPU_LOAD, + FREQ_REPORT_TOP_TASK, + FREQ_REPORT_INVALID_POLICY +}; + extern int sysctl_sched_freq_inc_notify; extern int sysctl_sched_freq_dec_notify; extern unsigned int sysctl_sched_freq_reporting_policy; diff --git a/kernel/sched/hmp.c b/kernel/sched/hmp.c index 95125c5518e2..14d7ddd9cfd9 100644 --- a/kernel/sched/hmp.c +++ b/kernel/sched/hmp.c @@ -3198,7 +3198,7 @@ static inline u64 freq_policy_load(struct rq *rq, u64 load) case FREQ_REPORT_CPU_LOAD: break; default: - WARN_ON_ONCE(1); + break; } return load; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index d907eeb297a3..2f6f67179838 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1069,10 +1069,6 @@ enum sched_boost_policy { #define WINDOW_STATS_AVG 3 #define WINDOW_STATS_INVALID_POLICY 4 -#define FREQ_REPORT_MAX_CPU_LOAD_TOP_TASK 0 -#define FREQ_REPORT_CPU_LOAD 1 -#define FREQ_REPORT_TOP_TASK 2 - #define SCHED_UPMIGRATE_MIN_NICE 15 #define EXITING_TASK_MARKER 0xdeaddead diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 210d73fe7daa..7112dc54d88e 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -133,6 +133,7 @@ static int ten_thousand = 10000; #endif #ifdef CONFIG_SCHED_HMP static int one_thousand = 1000; +static int max_freq_reporting_policy = FREQ_REPORT_INVALID_POLICY - 1; #endif /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */ @@ -297,6 +298,7 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec_minmax, .extra1 = &zero, + .extra2 = &max_freq_reporting_policy, }, { .procname = "sched_freq_inc_notify",