Skip to content

Commit

Permalink
sched: Move code around
Browse files Browse the repository at this point in the history
In preparation to other code movement, move weighted_cpuload(),
source_load() and target_load() before the class includes.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 15, 2009
1 parent e26af0e commit f5f08f3
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,45 @@ static int tg_nop(struct task_group *tg, void *data)
#endif

#ifdef CONFIG_SMP
static unsigned long source_load(int cpu, int type);
static unsigned long target_load(int cpu, int type);
/* Used instead of source_load when we know the type == 0 */
static unsigned long weighted_cpuload(const int cpu)
{
return cpu_rq(cpu)->load.weight;
}

/*
* Return a low guess at the load of a migration-source cpu weighted
* according to the scheduling class and "nice" value.
*
* We want to under-estimate the load of migration sources, to
* balance conservatively.
*/
static unsigned long source_load(int cpu, int type)
{
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);

if (type == 0 || !sched_feat(LB_BIAS))
return total;

return min(rq->cpu_load[type-1], total);
}

/*
* Return a high guess at the load of a migration-target cpu weighted
* according to the scheduling class and "nice" value.
*/
static unsigned long target_load(int cpu, int type)
{
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);

if (type == 0 || !sched_feat(LB_BIAS))
return total;

return max(rq->cpu_load[type-1], total);
}

static int task_hot(struct task_struct *p, u64 now, struct sched_domain *sd);

static unsigned long cpu_avg_load_per_task(int cpu)
Expand Down Expand Up @@ -1959,13 +1996,6 @@ static inline void check_class_changed(struct rq *rq, struct task_struct *p,
}

#ifdef CONFIG_SMP

/* Used instead of source_load when we know the type == 0 */
static unsigned long weighted_cpuload(const int cpu)
{
return cpu_rq(cpu)->load.weight;
}

/*
* Is this task likely cache-hot:
*/
Expand Down Expand Up @@ -2240,39 +2270,6 @@ void kick_process(struct task_struct *p)
}
EXPORT_SYMBOL_GPL(kick_process);

/*
* Return a low guess at the load of a migration-source cpu weighted
* according to the scheduling class and "nice" value.
*
* We want to under-estimate the load of migration sources, to
* balance conservatively.
*/
static unsigned long source_load(int cpu, int type)
{
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);

if (type == 0 || !sched_feat(LB_BIAS))
return total;

return min(rq->cpu_load[type-1], total);
}

/*
* Return a high guess at the load of a migration-target cpu weighted
* according to the scheduling class and "nice" value.
*/
static unsigned long target_load(int cpu, int type)
{
struct rq *rq = cpu_rq(cpu);
unsigned long total = weighted_cpuload(cpu);

if (type == 0 || !sched_feat(LB_BIAS))
return total;

return max(rq->cpu_load[type-1], total);
}

/*
* find_idlest_group finds and returns the least busy CPU group within the
* domain.
Expand Down

0 comments on commit f5f08f3

Please sign in to comment.