Commit 831451ac authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched: introduce avg_wakeup

Introduce a new avg_wakeup statistic.

avg_wakeup is a measure of how frequently a task wakes up other tasks, it
represents the average time between wakeups, with a limit of avg_runtime
for when it doesn't wake up anybody.
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarMike Galbraith <efault@gmx.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent a6525042
...@@ -1046,6 +1046,9 @@ struct sched_entity { ...@@ -1046,6 +1046,9 @@ struct sched_entity {
u64 exec_max; u64 exec_max;
u64 slice_max; u64 slice_max;
u64 start_runtime;
u64 avg_wakeup;
u64 nr_migrations; u64 nr_migrations;
u64 nr_migrations_cold; u64 nr_migrations_cold;
u64 nr_failed_migrations_affine; u64 nr_failed_migrations_affine;
......
...@@ -1705,6 +1705,9 @@ static void update_avg(u64 *avg, u64 sample) ...@@ -1705,6 +1705,9 @@ static void update_avg(u64 *avg, u64 sample)
static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup) static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
{ {
if (wakeup)
p->se.start_runtime = p->se.sum_exec_runtime;
sched_info_queued(p); sched_info_queued(p);
p->sched_class->enqueue_task(rq, p, wakeup); p->sched_class->enqueue_task(rq, p, wakeup);
p->se.on_rq = 1; p->se.on_rq = 1;
...@@ -1712,10 +1715,15 @@ static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup) ...@@ -1712,10 +1715,15 @@ static void enqueue_task(struct rq *rq, struct task_struct *p, int wakeup)
static void dequeue_task(struct rq *rq, struct task_struct *p, int sleep) static void dequeue_task(struct rq *rq, struct task_struct *p, int sleep)
{ {
if (sleep && p->se.last_wakeup) { if (sleep) {
update_avg(&p->se.avg_overlap, if (p->se.last_wakeup) {
p->se.sum_exec_runtime - p->se.last_wakeup); update_avg(&p->se.avg_overlap,
p->se.last_wakeup = 0; p->se.sum_exec_runtime - p->se.last_wakeup);
p->se.last_wakeup = 0;
} else {
update_avg(&p->se.avg_wakeup,
sysctl_sched_wakeup_granularity);
}
} }
sched_info_dequeued(p); sched_info_dequeued(p);
...@@ -2345,6 +2353,22 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync) ...@@ -2345,6 +2353,22 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
activate_task(rq, p, 1); activate_task(rq, p, 1);
success = 1; success = 1;
/*
* Only attribute actual wakeups done by this task.
*/
if (!in_interrupt()) {
struct sched_entity *se = &current->se;
u64 sample = se->sum_exec_runtime;
if (se->last_wakeup)
sample -= se->last_wakeup;
else
sample -= se->start_runtime;
update_avg(&se->avg_wakeup, sample);
se->last_wakeup = se->sum_exec_runtime;
}
out_running: out_running:
trace_sched_wakeup(rq, p, success); trace_sched_wakeup(rq, p, success);
check_preempt_curr(rq, p, sync); check_preempt_curr(rq, p, sync);
...@@ -2355,8 +2379,6 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync) ...@@ -2355,8 +2379,6 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
p->sched_class->task_wake_up(rq, p); p->sched_class->task_wake_up(rq, p);
#endif #endif
out: out:
current->se.last_wakeup = current->se.sum_exec_runtime;
task_rq_unlock(rq, &flags); task_rq_unlock(rq, &flags);
return success; return success;
...@@ -2386,6 +2408,8 @@ static void __sched_fork(struct task_struct *p) ...@@ -2386,6 +2408,8 @@ static void __sched_fork(struct task_struct *p)
p->se.prev_sum_exec_runtime = 0; p->se.prev_sum_exec_runtime = 0;
p->se.last_wakeup = 0; p->se.last_wakeup = 0;
p->se.avg_overlap = 0; p->se.avg_overlap = 0;
p->se.start_runtime = 0;
p->se.avg_wakeup = sysctl_sched_wakeup_granularity;
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
p->se.wait_start = 0; p->se.wait_start = 0;
......
...@@ -397,6 +397,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) ...@@ -397,6 +397,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
PN(se.vruntime); PN(se.vruntime);
PN(se.sum_exec_runtime); PN(se.sum_exec_runtime);
PN(se.avg_overlap); PN(se.avg_overlap);
PN(se.avg_wakeup);
nr_switches = p->nvcsw + p->nivcsw; nr_switches = p->nvcsw + p->nivcsw;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment