summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrivatsa Vaddagiri <vatsa@codeaurora.org>2016-09-09 19:59:12 +0530
committerPavankumar Kondeti <pkondeti@codeaurora.org>2016-12-20 14:15:59 +0530
commitf3e2e2863a2a7eaca13d6051cb36ca28f100a754 (patch)
tree677105c483e451d287ca0d492fb89c5ee70f0b0f
parentc0a8f9e80a88354a7e2271a5cb61c61ac76a8818 (diff)
sched: Avoid packing tasks with low sleep time
Low sleep time can be an indication that waking tasks will not receive any vruntime bonus and hence would suffer from latency when packed. short-burst tasks sleeping on an average more than sched_short_sleep_ns are not eligible for packing. This policy covers the case where a task runs in short bursts and sleeping for smaller duration in between. Change-Id: Ib81fa37809b85c267949cd433bc6115dd89f100e Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org> Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
-rw-r--r--include/linux/sched/sysctl.h1
-rw-r--r--kernel/sched/hmp.c5
-rw-r--r--kernel/sched/sched.h3
-rw-r--r--kernel/sysctl.c7
4 files changed, 14 insertions, 2 deletions
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index a1bf22116cce..0538de6dfb6f 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -73,6 +73,7 @@ extern unsigned int sysctl_sched_enable_thread_grouping;
extern unsigned int sysctl_sched_freq_aggregate_threshold_pct;
extern unsigned int sysctl_sched_prefer_sync_wakee_to_waker;
extern unsigned int sysctl_sched_short_burst;
+extern unsigned int sysctl_sched_short_sleep;
#else /* CONFIG_SCHED_HMP */
diff --git a/kernel/sched/hmp.c b/kernel/sched/hmp.c
index 158fc748873b..652e19ea7bb0 100644
--- a/kernel/sched/hmp.c
+++ b/kernel/sched/hmp.c
@@ -959,9 +959,12 @@ unsigned int __read_mostly sysctl_sched_restrict_cluster_spill;
/*
* Scheduler tries to avoid waking up idle CPUs for tasks running
* in short bursts. If the task average burst is less than
- * sysctl_sched_short_burst nanoseconds, it is eligible for packing.
+ * sysctl_sched_short_burst nanoseconds and it sleeps on an average
+ * for more than sysctl_sched_short_sleep nanoseconds, then the
+ * task is eligible for packing.
*/
unsigned int __read_mostly sysctl_sched_short_burst;
+unsigned int __read_mostly sysctl_sched_short_sleep = 1 * NSEC_PER_MSEC;
static void
_update_up_down_migrate(unsigned int *up_migrate, unsigned int *down_migrate)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 5f23462f3a60..afccfd0878b1 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1420,7 +1420,8 @@ static inline u64 cpu_cravg_sync(int cpu, int sync)
static inline bool is_short_burst_task(struct task_struct *p)
{
- return p->ravg.avg_burst < sysctl_sched_short_burst;
+ return p->ravg.avg_burst < sysctl_sched_short_burst &&
+ p->ravg.avg_sleep_time > sysctl_sched_short_sleep;
}
extern void check_for_migration(struct rq *rq, struct task_struct *p);
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ba69f4c96d7c..12ea4f09c04b 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -514,6 +514,13 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
+ {
+ .procname = "sched_short_sleep_ns",
+ .data = &sysctl_sched_short_sleep,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
#endif /* CONFIG_SCHED_HMP */
#ifdef CONFIG_SCHED_DEBUG
{