Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 64653
b: refs/heads/master
c: f6cf891
h: refs/heads/master
i:
  64651: 808941c
v: v3
  • Loading branch information
Ingo Molnar committed Aug 28, 2007
1 parent 4f2634c commit f6b1d0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 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: 5f01d519e60a6ca1a7d9be9f2d73c5f521383992
refs/heads/master: f6cf891c4d7128f9f91243fc0b9ce99e10fa1586
1 change: 1 addition & 0 deletions trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ struct sched_entity {

u64 exec_start;
u64 sum_exec_runtime;
u64 prev_sum_exec_runtime;
u64 wait_start_fair;
u64 sleep_start_fair;

Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,7 @@ static void __sched_fork(struct task_struct *p)
p->se.wait_start_fair = 0;
p->se.exec_start = 0;
p->se.sum_exec_runtime = 0;
p->se.prev_sum_exec_runtime = 0;
p->se.delta_exec = 0;
p->se.delta_fair_run = 0;
p->se.delta_fair_sleep = 0;
Expand Down
26 changes: 22 additions & 4 deletions trunk/kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int sleep)
/*
* Preempt the current task with a newly woken task if needed:
*/
static void
static int
__check_preempt_curr_fair(struct cfs_rq *cfs_rq, struct sched_entity *se,
struct sched_entity *curr, unsigned long granularity)
{
Expand All @@ -679,8 +679,11 @@ __check_preempt_curr_fair(struct cfs_rq *cfs_rq, struct sched_entity *se,
* preempt the current task unless the best task has
* a larger than sched_granularity fairness advantage:
*/
if (__delta > niced_granularity(curr, granularity))
if (__delta > niced_granularity(curr, granularity)) {
resched_task(rq_of(cfs_rq)->curr);
return 1;
}
return 0;
}

static inline void
Expand Down Expand Up @@ -725,6 +728,7 @@ static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev)

static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
{
unsigned long gran, ideal_runtime, delta_exec;
struct sched_entity *next;

/*
Expand All @@ -741,8 +745,22 @@ static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
if (next == curr)
return;

__check_preempt_curr_fair(cfs_rq, next, curr,
sched_granularity(cfs_rq));
gran = sched_granularity(cfs_rq);
ideal_runtime = niced_granularity(curr,
max(sysctl_sched_latency / cfs_rq->nr_running,
(unsigned long)sysctl_sched_min_granularity));
/*
* If we executed more than what the latency constraint suggests,
* reduce the rescheduling granularity. This way the total latency
* of how much a task is not scheduled converges to
* sysctl_sched_latency:
*/
delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime;
if (delta_exec > ideal_runtime)
gran = 0;

if (__check_preempt_curr_fair(cfs_rq, next, curr, gran))
curr->prev_sum_exec_runtime = curr->sum_exec_runtime;
}

/**************************************************
Expand Down

0 comments on commit f6b1d0e

Please sign in to comment.