diff options
| author | Srivatsa Vaddagiri <vatsa@codeaurora.org> | 2016-09-09 19:50:27 +0530 |
|---|---|---|
| committer | Pavankumar Kondeti <pkondeti@codeaurora.org> | 2016-12-16 16:50:52 +0530 |
| commit | 92dc28458ccc3ab3aff715c77c744d0bdebd7506 (patch) | |
| tree | fcec6ced0d4d074acc6f72f79552eb0e0f539b86 /kernel | |
| parent | 0dee0d1411e4ba837089a769a5bcce57a5a14df2 (diff) | |
sched: Track average sleep time
Similar to tracking average burst length for tasks, average sleep time
indicates how much a task sleeps on an average before waking up to run.
Very low sleep and burst lengths indicates tasks that could be
sensitive to task-wake latencies and hence should not be packed.
Change-Id: Ife68a9a9a9e596246aab5029f60e41c5bad781e4
Signed-off-by: Srivatsa Vaddagiri <vatsa@codeaurora.org>
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sched/core.c | 4 | ||||
| -rw-r--r-- | kernel/sched/hmp.c | 14 | ||||
| -rw-r--r-- | kernel/sched/sched.h | 4 |
3 files changed, 13 insertions, 9 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1a288e2de50d..1a48b0fc4d3f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2100,7 +2100,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) set_task_cpu(p, cpu); } - set_task_last_wake(p, wallclock); + note_task_waking(p, wallclock); #endif /* CONFIG_SMP */ ttwu_queue(p, cpu); stat: @@ -2169,7 +2169,7 @@ static void try_to_wake_up_local(struct task_struct *p) update_task_ravg(rq->curr, rq, TASK_UPDATE, wallclock, 0); update_task_ravg(p, rq, TASK_WAKE, wallclock, 0); ttwu_activate(rq, p, ENQUEUE_WAKEUP); - set_task_last_wake(p, wallclock); + note_task_waking(p, wallclock); } ttwu_do_wakeup(rq, p, 0); diff --git a/kernel/sched/hmp.c b/kernel/sched/hmp.c index 95e618ee1124..158fc748873b 100644 --- a/kernel/sched/hmp.c +++ b/kernel/sched/hmp.c @@ -74,11 +74,6 @@ inline void clear_ed_task(struct task_struct *p, struct rq *rq) rq->ed_task = NULL; } -inline void set_task_last_wake(struct task_struct *p, u64 wallclock) -{ - p->last_wake_ts = wallclock; -} - inline void set_task_last_switch_out(struct task_struct *p, u64 wallclock) { p->last_switch_out_ts = wallclock; @@ -1567,6 +1562,7 @@ void init_new_task_load(struct task_struct *p, bool idle_task) * the avg_burst to go below the threshold. */ p->ravg.avg_burst = 2 * (u64)sysctl_sched_short_burst; + p->ravg.avg_sleep_time = 0; p->ravg.curr_window_cpu = kcalloc(nr_cpu_ids, sizeof(u32), GFP_KERNEL); p->ravg.prev_window_cpu = kcalloc(nr_cpu_ids, sizeof(u32), GFP_KERNEL); @@ -4510,6 +4506,14 @@ void update_avg_burst(struct task_struct *p) p->ravg.curr_burst = 0; } +void note_task_waking(struct task_struct *p, u64 wallclock) +{ + u64 sleep_time = wallclock - p->last_switch_out_ts; + + p->last_wake_ts = wallclock; + update_avg(&p->ravg.avg_sleep_time, sleep_time); +} + #ifdef CONFIG_CGROUP_SCHED u64 cpu_upmigrate_discourage_read_u64(struct cgroup_subsys_state *css, struct cftype *cft) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b9a109e5ef94..74035e1605ec 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1092,7 +1092,7 @@ extern void mark_task_starting(struct task_struct *p); extern void set_window_start(struct rq *rq); extern void migrate_sync_cpu(int cpu, int new_cpu); extern void update_cluster_topology(void); -extern void set_task_last_wake(struct task_struct *p, u64 wallclock); +extern void note_task_waking(struct task_struct *p, u64 wallclock); extern void set_task_last_switch_out(struct task_struct *p, u64 wallclock); extern void init_clusters(void); extern int __init set_sched_enable_hmp(char *str); @@ -1490,7 +1490,7 @@ static inline void set_window_start(struct rq *rq) { } static inline void migrate_sync_cpu(int cpu, int new_cpu) {} static inline void init_clusters(void) {} static inline void update_cluster_topology(void) { } -static inline void set_task_last_wake(struct task_struct *p, u64 wallclock) { } +static inline void note_task_waking(struct task_struct *p, u64 wallclock) { } static inline void set_task_last_switch_out(struct task_struct *p, u64 wallclock) { } |
