Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 163024
b: refs/heads/master
c: ad4b78b
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 17, 2009
1 parent 4c2008e commit 553e9d2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eb24073bc1fe3e569a855cf38d529fb650c35524
refs/heads/master: ad4b78bbcbab66998b05d422ac6106b645796e54
2 changes: 2 additions & 0 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ struct sched_entity {
u64 start_runtime;
u64 avg_wakeup;

u64 avg_running;

#ifdef CONFIG_SCHEDSTATS
u64 wait_start;
u64 wait_max;
Expand Down
17 changes: 10 additions & 7 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ static void __sched_fork(struct task_struct *p)
p->se.avg_overlap = 0;
p->se.start_runtime = 0;
p->se.avg_wakeup = sysctl_sched_wakeup_granularity;
p->se.avg_running = 0;

#ifdef CONFIG_SCHEDSTATS
p->se.wait_start = 0;
Expand Down Expand Up @@ -5310,14 +5311,13 @@ static inline void schedule_debug(struct task_struct *prev)
#endif
}

static void put_prev_task(struct rq *rq, struct task_struct *prev)
static void put_prev_task(struct rq *rq, struct task_struct *p)
{
if (prev->state == TASK_RUNNING) {
u64 runtime = prev->se.sum_exec_runtime;
u64 runtime = p->se.sum_exec_runtime - p->se.prev_sum_exec_runtime;

runtime -= prev->se.prev_sum_exec_runtime;
runtime = min_t(u64, runtime, 2*sysctl_sched_migration_cost);
update_avg(&p->se.avg_running, runtime);

if (p->state == TASK_RUNNING) {
/*
* In order to avoid avg_overlap growing stale when we are
* indeed overlapping and hence not getting put to sleep, grow
Expand All @@ -5327,9 +5327,12 @@ static void put_prev_task(struct rq *rq, struct task_struct *prev)
* correlates to the amount of cache footprint a task can
* build up.
*/
update_avg(&prev->se.avg_overlap, runtime);
runtime = min_t(u64, runtime, 2*sysctl_sched_migration_cost);
update_avg(&p->se.avg_overlap, runtime);
} else {
update_avg(&p->se.avg_running, 0);
}
prev->sched_class->put_prev_task(rq, prev);
p->sched_class->put_prev_task(rq, p);
}

/*
Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/sched_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m)
PN(se.sum_exec_runtime);
PN(se.avg_overlap);
PN(se.avg_wakeup);
PN(se.avg_running);

nr_switches = p->nvcsw + p->nivcsw;

Expand Down
14 changes: 11 additions & 3 deletions trunk/kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,9 +1605,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
return;
}

if (!sched_feat(WAKEUP_PREEMPT))
return;

if ((sched_feat(WAKEUP_SYNC) && sync) ||
(sched_feat(WAKEUP_OVERLAP) &&
(se->avg_overlap < sysctl_sched_migration_cost &&
Expand All @@ -1616,6 +1613,17 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
return;
}

if (sched_feat(WAKEUP_RUNNING)) {
if (pse->avg_running < se->avg_running) {
set_next_buddy(pse);
resched_task(curr);
return;
}
}

if (!sched_feat(WAKEUP_PREEMPT))
return;

find_matching_se(&se, &pse);

BUG_ON(!pse);
Expand Down
5 changes: 5 additions & 0 deletions trunk/kernel/sched_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ SCHED_FEAT(WAKEUP_SYNC, 0)
*/
SCHED_FEAT(WAKEUP_OVERLAP, 0)

/*
* Wakeup preemption towards tasks that run short
*/
SCHED_FEAT(WAKEUP_RUNNING, 0)

/*
* Use the SYNC wakeup hint, pipes and the likes use this to indicate
* the remote end is likely to consume the data we just wrote, and
Expand Down

0 comments on commit 553e9d2

Please sign in to comment.