Skip to content

Commit

Permalink
sched: fix sched_slice()
Browse files Browse the repository at this point in the history
Impact: fix bad-interactivity buglet

Fix sched_slice() to emit a sane result whether a task is currently
enqueued or not.

Signed-off-by: Mike Galbraith <efault@gmx.de>
Tested-by: Jayson King <dev@jaysonking.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

 kernel/sched_fair.c |   30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
  • Loading branch information
Mike Galbraith authored and Ingo Molnar committed Jan 2, 2009
1 parent b58602a commit 0a58244
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,20 +385,6 @@ int sched_nr_latency_handler(struct ctl_table *table, int write,
}
#endif

/*
* delta *= P[w / rw]
*/
static inline unsigned long
calc_delta_weight(unsigned long delta, struct sched_entity *se)
{
for_each_sched_entity(se) {
delta = calc_delta_mine(delta,
se->load.weight, &cfs_rq_of(se)->load);
}

return delta;
}

/*
* delta /= w
*/
Expand Down Expand Up @@ -440,12 +426,20 @@ static u64 __sched_period(unsigned long nr_running)
*/
static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
unsigned long nr_running = cfs_rq->nr_running;
u64 slice = __sched_period(cfs_rq->nr_running + !se->on_rq);

if (unlikely(!se->on_rq))
nr_running++;
for_each_sched_entity(se) {
struct load_weight *load = &cfs_rq->load;

return calc_delta_weight(__sched_period(nr_running), se);
if (unlikely(!se->on_rq)) {
struct load_weight lw = cfs_rq->load;

update_load_add(&lw, se->load.weight);
load = &lw;
}
slice = calc_delta_mine(slice, se->load.weight, load);
}
return slice;
}

/*
Expand Down

0 comments on commit 0a58244

Please sign in to comment.