From 7daf0cae53fd5188aa09ea6006197798b34961dd Mon Sep 17 00:00:00 2001
From: Alexey Makhalov <amakhalov@vmware.com>
Date: Tue, 9 May 2017 12:34:05 -0700
Subject: [PATCH] sysctl: sched_weighted_cpuload uses rla

---
 include/linux/sched/sysctl.h | 1 +
 kernel/sched/fair.c          | 8 +++++++-
 kernel/sysctl.c              | 7 +++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 22db1e63707e..4851e047b071 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -18,6 +18,7 @@ extern unsigned int sysctl_sched_latency;
 extern unsigned int sysctl_sched_min_granularity;
 extern unsigned int sysctl_sched_wakeup_granularity;
 extern unsigned int sysctl_sched_child_runs_first;
+extern unsigned int sysctl_sched_weighted_cpuload_uses_rla;
 
 enum sched_tunable_scaling {
 	SCHED_TUNABLESCALING_NONE,
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c242944f5cbd..5ed6ba7234dc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -35,6 +35,10 @@
 
 #include "sched.h"
 
+#ifdef CONFIG_SMP
+unsigned int sysctl_sched_weighted_cpuload_uses_rla = 1;
+#endif
+
 /*
  * Targeted preemption latency for CPU-bound tasks:
  * (default: 6ms * (1 + ilog(ncpus)), units: nanoseconds)
@@ -4796,7 +4800,9 @@ static void cpu_load_update(struct rq *this_rq, unsigned long this_load,
 /* Used instead of source_load when we know the type == 0 */
 static unsigned long weighted_cpuload(const int cpu)
 {
-	return cfs_rq_runnable_load_avg(&cpu_rq(cpu)->cfs);
+	if (sysctl_sched_weighted_cpuload_uses_rla)
+		return cfs_rq_runnable_load_avg(&cpu_rq(cpu)->cfs);
+	return cpu_rq(cpu)->load.weight;
 }
 
 #ifdef CONFIG_NO_HZ_COMMON
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c1095cdc0fe2..728b5603a7ed 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -354,6 +354,13 @@ static struct ctl_table kern_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+	{
+		.procname	= "sched_weighted_cpuload_uses_rla",
+		.data		= &sysctl_sched_weighted_cpuload_uses_rla,
+		.maxlen		= sizeof(unsigned int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec,
+	},
 #ifdef CONFIG_SCHEDSTATS
 	{
 		.procname	= "sched_schedstats",
-- 
2.11.0