summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorPavankumar Kondeti <pkondeti@codeaurora.org>2015-06-08 09:08:47 +0530
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:25:17 -0700
commit6d742ce87b0337f422edf9c114357758e6feb01f (patch)
tree6169cd473bc056ec6b8bfa60972f1ddb25ba4260 /include/linux
parentefa673322fd6917acb69361fc01f746a13b3fcde (diff)
sched: Add separate load tracking histogram to predict loads
Current window based load tracking only saves history for five windows. A historically heavy task's heavy load will be completely forgotten after five windows of light load. Even before the five window expires, a heavy task wakes up on same CPU it used to run won't trigger any frequency change until end of the window. It would starve for the entire window. It also adds one "small" load window to history because it's accumulating load at a low frequency, further reducing the tracked load for this heavy task. Ideally, scheduler should be able to identify such tasks and notify governor to increase frequency immediately after it wakes up. Add a histogram for each task to track a much longer load history. A prediction will be made based on runtime of previous or current window, histogram data and load tracked in recent windows. Prediction of all tasks that is currently running or runnable on a CPU is aggregated and reported to CPUFreq governor in sched_get_cpus_busy(). sched_get_cpus_busy() now returns predicted busy time in addition to previous window busy time and new task busy time, scaled to the CPU maximum possible frequency. Tunables: - /proc/sys/kernel/sched_gov_alert_freq (KHz) This tunable can be used to further filter the notifications. Frequency alert notification is sent only when the predicted load exceeds previous window load by sched_gov_alert_freq converted to load. Change-Id: If29098cd2c5499163ceaff18668639db76ee8504 Suggested-by: Saravana Kannan <skannan@codeaurora.org> Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org> Signed-off-by: Junjie Wu <junjiew@codeaurora.org> [joonwoop@codeaurora.org: fixed merge conflicts around __migrate_task() and removed changes for CONFIG_SCHED_QHMP.]
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h9
-rw-r--r--include/linux/sched/sysctl.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 59eb23e73fa0..6d43a9cb8757 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1260,6 +1260,7 @@ struct sched_statistics {
#endif
#define RAVG_HIST_SIZE_MAX 5
+#define NUM_BUSY_BUCKETS 10
/* ravg represents frequency scaled cpu-demand of tasks */
struct ravg {
@@ -1284,6 +1285,11 @@ struct ravg {
*
* 'prev_window' represents task's contribution to cpu busy time
* statistics (rq->prev_runnable_sum) in previous window
+ *
+ * 'pred_demand' represents task's current predicted cpu busy time
+ *
+ * 'busy_buckets' groups historical busy time into different buckets
+ * used for prediction
*/
u64 mark_start;
u32 sum, demand;
@@ -1291,6 +1297,8 @@ struct ravg {
#ifdef CONFIG_SCHED_FREQ_INPUT
u32 curr_window, prev_window;
u16 active_windows;
+ u32 pred_demand;
+ u8 busy_buckets[NUM_BUSY_BUCKETS];
#endif
};
@@ -2134,6 +2142,7 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
struct sched_load {
unsigned long prev_load;
unsigned long new_task_load;
+ unsigned long predicted_load;
};
#if defined(CONFIG_SCHED_FREQ_INPUT)
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 676502dec830..437314e569be 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -72,6 +72,7 @@ extern unsigned int sysctl_sched_enable_colocation;
extern unsigned int sysctl_sched_restrict_cluster_spill;
#if defined(CONFIG_SCHED_FREQ_INPUT)
extern unsigned int sysctl_sched_new_task_windows;
+extern unsigned int sysctl_sched_pred_alert_freq;
#endif
#else /* CONFIG_SCHED_HMP */