summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-12-19 17:04:55 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-12-19 17:04:55 -0800
commit5a66e9b789aaaf58fa9ef91d83dd0e509f0eb624 (patch)
treec10a62794297c2b3adf542d819f6642bc50b3ba0
parente26b0777dc92ab47d16b0134e57cd1c9e1083a9a (diff)
parent92dc28458ccc3ab3aff715c77c744d0bdebd7506 (diff)
Merge "sched: Track average sleep time"
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/trace/events/sched.h7
-rw-r--r--kernel/sched/core.c4
-rw-r--r--kernel/sched/hmp.c14
-rw-r--r--kernel/sched/sched.h4
5 files changed, 19 insertions, 12 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index c58ba6c22caf..36007d90a678 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1395,7 +1395,7 @@ struct ravg {
u32 sum_history[RAVG_HIST_SIZE_MAX];
u32 *curr_window_cpu, *prev_window_cpu;
u32 curr_window, prev_window;
- u64 curr_burst, avg_burst;
+ u64 curr_burst, avg_burst, avg_sleep_time;
u16 active_windows;
u32 pred_demand;
u8 busy_buckets[NUM_BUSY_BUCKETS];
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 501ca9874456..0a59832e0515 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -135,6 +135,7 @@ TRACE_EVENT(sched_task_load,
__field( u64, latency )
__field( int, grp_id )
__field( u64, avg_burst )
+ __field( u64, avg_sleep )
),
TP_fast_assign(
@@ -152,13 +153,15 @@ TRACE_EVENT(sched_task_load,
p->ravg.mark_start : 0;
__entry->grp_id = p->grp ? p->grp->id : 0;
__entry->avg_burst = p->ravg.avg_burst;
+ __entry->avg_sleep = p->ravg.avg_sleep_time;
),
- TP_printk("%d (%s): demand=%u boost=%d reason=%d sync=%d need_idle=%d flags=%x grp=%d best_cpu=%d latency=%llu avg_burst=%llu",
+ TP_printk("%d (%s): demand=%u boost=%d reason=%d sync=%d need_idle=%d flags=%x grp=%d best_cpu=%d latency=%llu avg_burst=%llu avg_sleep=%llu",
__entry->pid, __entry->comm, __entry->demand,
__entry->boost, __entry->reason, __entry->sync,
__entry->need_idle, __entry->flags, __entry->grp_id,
- __entry->best_cpu, __entry->latency, __entry->avg_burst)
+ __entry->best_cpu, __entry->latency, __entry->avg_burst,
+ __entry->avg_sleep)
);
TRACE_EVENT(sched_set_preferred_cluster,
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ca577a09ce5e..b70a76058b00 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2115,7 +2115,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:
@@ -2184,7 +2184,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 ae7442007e8b..5f23462f3a60 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1120,7 +1120,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);
@@ -1518,7 +1518,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) { }