Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223428
b: refs/heads/master
c: fe44d62
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Dec 16, 2010
1 parent ece82f9 commit c4a3956
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 34 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: dbd87b5af055a0cc9bba17795c9a2b0d17795389
refs/heads/master: fe44d62122829959e960bc699318d58966922a69
83 changes: 50 additions & 33 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,23 +636,18 @@ static inline struct task_group *task_group(struct task_struct *p)

#endif /* CONFIG_CGROUP_SCHED */

static u64 irq_time_cpu(int cpu);
static void sched_irq_time_avg_update(struct rq *rq, u64 irq_time);
static void update_rq_clock_task(struct rq *rq, s64 delta);

inline void update_rq_clock(struct rq *rq)
static void update_rq_clock(struct rq *rq)
{
int cpu = cpu_of(rq);
u64 irq_time;
s64 delta;

if (rq->skip_clock_update)
return;

rq->clock = sched_clock_cpu(cpu);
irq_time = irq_time_cpu(cpu);
if (rq->clock - irq_time > rq->clock_task)
rq->clock_task = rq->clock - irq_time;

sched_irq_time_avg_update(rq, irq_time);
delta = sched_clock_cpu(cpu_of(rq)) - rq->clock;
rq->clock += delta;
update_rq_clock_task(rq, delta);
}

/*
Expand Down Expand Up @@ -1946,63 +1941,85 @@ void disable_sched_clock_irqtime(void)
sched_clock_irqtime = 0;
}

static u64 irq_time_cpu(int cpu)
static inline u64 irq_time_cpu(int cpu)
{
if (!sched_clock_irqtime)
return 0;

return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu);
}

/*
* Called before incrementing preempt_count on {soft,}irq_enter
* and before decrementing preempt_count on {soft,}irq_exit.
*/
void account_system_vtime(struct task_struct *curr)
{
unsigned long flags;
s64 delta;
int cpu;
u64 now, delta;

if (!sched_clock_irqtime)
return;

local_irq_save(flags);

cpu = smp_processor_id();
now = sched_clock_cpu(cpu);
delta = now - per_cpu(irq_start_time, cpu);
per_cpu(irq_start_time, cpu) = now;
delta = sched_clock_cpu(cpu) - __this_cpu_read(irq_start_time);
__this_cpu_add(irq_start_time, delta);

/*
* We do not account for softirq time from ksoftirqd here.
* We want to continue accounting softirq time to ksoftirqd thread
* in that case, so as not to confuse scheduler with a special task
* that do not consume any time, but still wants to run.
*/
if (hardirq_count())
per_cpu(cpu_hardirq_time, cpu) += delta;
__this_cpu_add(cpu_hardirq_time, delta);
else if (in_serving_softirq() && !(curr->flags & PF_KSOFTIRQD))
per_cpu(cpu_softirq_time, cpu) += delta;
__this_cpu_add(cpu_softirq_time, delta);

local_irq_restore(flags);
}
EXPORT_SYMBOL_GPL(account_system_vtime);

static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time)
static void update_rq_clock_task(struct rq *rq, s64 delta)
{
if (sched_clock_irqtime && sched_feat(NONIRQ_POWER)) {
u64 delta_irq = curr_irq_time - rq->prev_irq_time;
rq->prev_irq_time = curr_irq_time;
sched_rt_avg_update(rq, delta_irq);
}
s64 irq_delta;

irq_delta = irq_time_cpu(cpu_of(rq)) - rq->prev_irq_time;

/*
* Since irq_time is only updated on {soft,}irq_exit, we might run into
* this case when a previous update_rq_clock() happened inside a
* {soft,}irq region.
*
* When this happens, we stop ->clock_task and only update the
* prev_irq_time stamp to account for the part that fit, so that a next
* update will consume the rest. This ensures ->clock_task is
* monotonic.
*
* It does however cause some slight miss-attribution of {soft,}irq
* time, a more accurate solution would be to update the irq_time using
* the current rq->clock timestamp, except that would require using
* atomic ops.
*/
if (irq_delta > delta)
irq_delta = delta;

rq->prev_irq_time += irq_delta;
delta -= irq_delta;
rq->clock_task += delta;

if (irq_delta && sched_feat(NONIRQ_POWER))
sched_rt_avg_update(rq, irq_delta);
}

#else
#else /* CONFIG_IRQ_TIME_ACCOUNTING */

static u64 irq_time_cpu(int cpu)
static void update_rq_clock_task(struct rq *rq, s64 delta)
{
return 0;
rq->clock_task += delta;
}

static void sched_irq_time_avg_update(struct rq *rq, u64 curr_irq_time) { }

#endif
#endif /* CONFIG_IRQ_TIME_ACCOUNTING */

#include "sched_idletask.c"
#include "sched_fair.c"
Expand Down

0 comments on commit c4a3956

Please sign in to comment.