aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/*