Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305003
b: refs/heads/master
c: 556061b
h: refs/heads/master
i:
  305001: 408a315
  304999: 2d42a2a
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 14, 2012
1 parent 242b4d1 commit 3518961
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 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: 870a0bb5d636156502769233d02a0d5791d4366a
refs/heads/master: 556061b00c9f2fd6a5524b6bde823ef12f299ecf
53 changes: 39 additions & 14 deletions trunk/kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,6 @@ int tg_nop(struct task_group *tg, void *data)
}
#endif

void update_cpu_load(struct rq *this_rq);

static void set_load_weight(struct task_struct *p)
{
int prio = p->static_prio - MAX_RT_PRIO;
Expand Down Expand Up @@ -2486,22 +2484,13 @@ decay_load_missed(unsigned long load, unsigned long missed_updates, int idx)
* scheduler tick (TICK_NSEC). With tickless idle this will not be called
* every tick. We fix it up based on jiffies.
*/
void update_cpu_load(struct rq *this_rq)
static void __update_cpu_load(struct rq *this_rq, unsigned long this_load,
unsigned long pending_updates)
{
unsigned long this_load = this_rq->load.weight;
unsigned long curr_jiffies = jiffies;
unsigned long pending_updates;
int i, scale;

this_rq->nr_load_updates++;

/* Avoid repeated calls on same jiffy, when moving in and out of idle */
if (curr_jiffies == this_rq->last_load_update_tick)
return;

pending_updates = curr_jiffies - this_rq->last_load_update_tick;
this_rq->last_load_update_tick = curr_jiffies;

/* Update our load: */
this_rq->cpu_load[0] = this_load; /* Fasttrack for idx 0 */
for (i = 1, scale = 2; i < CPU_LOAD_IDX_MAX; i++, scale += scale) {
Expand All @@ -2526,9 +2515,45 @@ void update_cpu_load(struct rq *this_rq)
sched_avg_update(this_rq);
}

/*
* Called from nohz_idle_balance() to update the load ratings before doing the
* idle balance.
*/
void update_idle_cpu_load(struct rq *this_rq)
{
unsigned long curr_jiffies = jiffies;
unsigned long load = this_rq->load.weight;
unsigned long pending_updates;

/*
* Bloody broken means of dealing with nohz, but better than nothing..
* jiffies is updated by one cpu, another cpu can drift wrt the jiffy
* update and see 0 difference the one time and 2 the next, even though
* we ticked at roughtly the same rate.
*
* Hence we only use this from nohz_idle_balance() and skip this
* nonsense when called from the scheduler_tick() since that's
* guaranteed a stable rate.
*/
if (load || curr_jiffies == this_rq->last_load_update_tick)
return;

pending_updates = curr_jiffies - this_rq->last_load_update_tick;
this_rq->last_load_update_tick = curr_jiffies;

__update_cpu_load(this_rq, load, pending_updates);
}

/*
* Called from scheduler_tick()
*/
static void update_cpu_load_active(struct rq *this_rq)
{
update_cpu_load(this_rq);
/*
* See the mess in update_idle_cpu_load().
*/
this_rq->last_load_update_tick = jiffies;
__update_cpu_load(this_rq, this_rq->load.weight, 1);

calc_load_account_active(this_rq);
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -5012,7 +5012,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle)

raw_spin_lock_irq(&this_rq->lock);
update_rq_clock(this_rq);
update_cpu_load(this_rq);
update_idle_cpu_load(this_rq);
raw_spin_unlock_irq(&this_rq->lock);

rebalance_domains(balance_cpu, CPU_IDLE);
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/sched/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ extern void resched_cpu(int cpu);
extern struct rt_bandwidth def_rt_bandwidth;
extern void init_rt_bandwidth(struct rt_bandwidth *rt_b, u64 period, u64 runtime);

extern void update_cpu_load(struct rq *this_rq);
extern void update_idle_cpu_load(struct rq *this_rq);

#ifdef CONFIG_CGROUP_CPUACCT
#include <linux/cgroup.h>
Expand Down

0 comments on commit 3518961

Please sign in to comment.