aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorVenkatesh Pallipadi <venki@google.com>2010-12-21 20:09:02 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-26 06:33:21 -0500
commit70a89a6620f658d47a1488515bada4b8ee6291d8 (patch)
tree8419e284dde540acf0dc858f0f9083d401e3c37d /kernel/sched.c
parenta1dabb6bfffccb897eff3e1d102dacf2a4bedf3b (diff)
sched: Refactor account_system_time separating id-update
Refactor account_system_time, to separate out the logic of identifying the update needed and code that does actual update. This is used by following patch for IRQ_TIME_ACCOUNTING, which has different identification logic and same update logic. Tested-by: Shaun Ruffell <sruffell@digium.com> Signed-off-by: Venkatesh Pallipadi <venki@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1292980144-28796-4-git-send-email-venki@google.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c46
1 files changed, 31 insertions, 15 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 8b89b3bba565..e3fa92106ed7 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3568,6 +3568,32 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime,
3568} 3568}
3569 3569
3570/* 3570/*
3571 * Account system cpu time to a process and desired cpustat field
3572 * @p: the process that the cpu time gets accounted to
3573 * @cputime: the cpu time spent in kernel space since the last update
3574 * @cputime_scaled: cputime scaled by cpu frequency
3575 * @target_cputime64: pointer to cpustat field that has to be updated
3576 */
3577static inline
3578void __account_system_time(struct task_struct *p, cputime_t cputime,
3579 cputime_t cputime_scaled, cputime64_t *target_cputime64)
3580{
3581 cputime64_t tmp = cputime_to_cputime64(cputime);
3582
3583 /* Add system time to process. */
3584 p->stime = cputime_add(p->stime, cputime);
3585 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
3586 account_group_system_time(p, cputime);
3587
3588 /* Add system time to cpustat. */
3589 *target_cputime64 = cputime64_add(*target_cputime64, tmp);
3590 cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime);
3591
3592 /* Account for system time used */
3593 acct_update_integrals(p);
3594}
3595
3596/*
3571 * Account system cpu time to a process. 3597 * Account system cpu time to a process.
3572 * @p: the process that the cpu time gets accounted to 3598 * @p: the process that the cpu time gets accounted to
3573 * @hardirq_offset: the offset to subtract from hardirq_count() 3599 * @hardirq_offset: the offset to subtract from hardirq_count()
@@ -3578,31 +3604,21 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
3578 cputime_t cputime, cputime_t cputime_scaled) 3604 cputime_t cputime, cputime_t cputime_scaled)
3579{ 3605{
3580 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 3606 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
3581 cputime64_t tmp; 3607 cputime64_t *target_cputime64;
3582 3608
3583 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) { 3609 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
3584 account_guest_time(p, cputime, cputime_scaled); 3610 account_guest_time(p, cputime, cputime_scaled);
3585 return; 3611 return;
3586 } 3612 }
3587 3613
3588 /* Add system time to process. */
3589 p->stime = cputime_add(p->stime, cputime);
3590 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
3591 account_group_system_time(p, cputime);
3592
3593 /* Add system time to cpustat. */
3594 tmp = cputime_to_cputime64(cputime);
3595 if (hardirq_count() - hardirq_offset) 3614 if (hardirq_count() - hardirq_offset)
3596 cpustat->irq = cputime64_add(cpustat->irq, tmp); 3615 target_cputime64 = &cpustat->irq;
3597 else if (in_serving_softirq()) 3616 else if (in_serving_softirq())
3598 cpustat->softirq = cputime64_add(cpustat->softirq, tmp); 3617 target_cputime64 = &cpustat->softirq;
3599 else 3618 else
3600 cpustat->system = cputime64_add(cpustat->system, tmp); 3619 target_cputime64 = &cpustat->system;
3601 3620
3602 cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime); 3621 __account_system_time(p, cputime, cputime_scaled, target_cputime64);
3603
3604 /* Account for system time used */
3605 acct_update_integrals(p);
3606} 3622}
3607 3623
3608/* 3624/*