Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118479
b: refs/heads/master
c: 4793241
h: refs/heads/master
i:
  118477: 7b492cf
  118475: 1f952b6
  118471: ff3c365
  118463: 905d151
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Nov 5, 2008
1 parent 1fbed15 commit 8cebaed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 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: d95f98d0691d3aba5e35850011946a08c9b36428
refs/heads/master: 4793241be408b3926ee00c704d7da3b3faf3a05f
6 changes: 4 additions & 2 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ struct cfs_rq {
* 'curr' points to currently running entity on this cfs_rq.
* It is set to NULL otherwise (i.e when none are currently running).
*/
struct sched_entity *curr, *next;
struct sched_entity *curr, *next, *last;

unsigned long nr_spread_over;

Expand Down Expand Up @@ -1805,7 +1805,9 @@ task_hot(struct task_struct *p, u64 now, struct sched_domain *sd)
/*
* Buddy candidates are cache hot:
*/
if (sched_feat(CACHE_HOT_BUDDY) && (&p->se == cfs_rq_of(&p->se)->next))
if (sched_feat(CACHE_HOT_BUDDY) &&
(&p->se == cfs_rq_of(&p->se)->next ||
&p->se == cfs_rq_of(&p->se)->last))
return 1;

if (p->sched_class != &fair_sched_class)
Expand Down
32 changes: 25 additions & 7 deletions trunk/kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ static void __dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
cfs_rq->rb_leftmost = next_node;
}

if (cfs_rq->next == se)
cfs_rq->next = NULL;

rb_erase(&se->run_node, &cfs_rq->tasks_timeline);
}

Expand Down Expand Up @@ -741,6 +738,12 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int sleep)
#endif
}

if (cfs_rq->last == se)
cfs_rq->last = NULL;

if (cfs_rq->next == se)
cfs_rq->next = NULL;

if (se != cfs_rq->curr)
__dequeue_entity(cfs_rq, se);
account_entity_dequeue(cfs_rq, se);
Expand Down Expand Up @@ -798,10 +801,13 @@ static struct sched_entity *pick_next_entity(struct cfs_rq *cfs_rq)
{
struct sched_entity *se = __pick_next_entity(cfs_rq);

if (!cfs_rq->next || wakeup_preempt_entity(cfs_rq->next, se) == 1)
return se;
if (cfs_rq->next && wakeup_preempt_entity(cfs_rq->next, se) < 1)
return cfs_rq->next;

return cfs_rq->next;
if (cfs_rq->last && wakeup_preempt_entity(cfs_rq->last, se) < 1)
return cfs_rq->last;

return se;
}

static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)
Expand Down Expand Up @@ -1319,10 +1325,11 @@ wakeup_preempt_entity(struct sched_entity *curr, struct sched_entity *se)
static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int sync)
{
struct task_struct *curr = rq->curr;
struct cfs_rq *cfs_rq = task_cfs_rq(curr);
struct sched_entity *se = &curr->se, *pse = &p->se;

if (unlikely(rt_prio(p->prio))) {
struct cfs_rq *cfs_rq = task_cfs_rq(curr);

update_rq_clock(rq);
update_curr(cfs_rq);
resched_task(curr);
Expand All @@ -1335,6 +1342,17 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int sync)
if (unlikely(se == pse))
return;

/*
* Only set the backward buddy when the current task is still on the
* rq. This can happen when a wakeup gets interleaved with schedule on
* the ->pre_schedule() or idle_balance() point, either of which can
* drop the rq lock.
*
* Also, during early boot the idle thread is in the fair class, for
* obvious reasons its a bad idea to schedule back to the idle thread.
*/
if (sched_feat(LAST_BUDDY) && likely(se->on_rq && curr != rq->idle))
cfs_rq_of(se)->last = se;
cfs_rq_of(pse)->next = pse;

/*
Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/sched_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ SCHED_FEAT(LB_BIAS, 1)
SCHED_FEAT(LB_WAKEUP_UPDATE, 1)
SCHED_FEAT(ASYM_EFF_LOAD, 1)
SCHED_FEAT(WAKEUP_OVERLAP, 0)
SCHED_FEAT(LAST_BUDDY, 1)

0 comments on commit 8cebaed

Please sign in to comment.