aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index ed90be46fb31..72a2a16e2214 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -51,6 +51,7 @@
51#include <linux/cpu.h> 51#include <linux/cpu.h>
52#include <linux/cpuset.h> 52#include <linux/cpuset.h>
53#include <linux/percpu.h> 53#include <linux/percpu.h>
54#include <linux/cpu_acct.h>
54#include <linux/kthread.h> 55#include <linux/kthread.h>
55#include <linux/seq_file.h> 56#include <linux/seq_file.h>
56#include <linux/sysctl.h> 57#include <linux/sysctl.h>
@@ -3307,9 +3308,13 @@ void account_user_time(struct task_struct *p, cputime_t cputime)
3307{ 3308{
3308 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; 3309 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
3309 cputime64_t tmp; 3310 cputime64_t tmp;
3311 struct rq *rq = this_rq();
3310 3312
3311 p->utime = cputime_add(p->utime, cputime); 3313 p->utime = cputime_add(p->utime, cputime);
3312 3314
3315 if (p != rq->idle)
3316 cpuacct_charge(p, cputime);
3317
3313 /* Add user time to cpustat. */ 3318 /* Add user time to cpustat. */
3314 tmp = cputime_to_cputime64(cputime); 3319 tmp = cputime_to_cputime64(cputime);
3315 if (TASK_NICE(p) > 0) 3320 if (TASK_NICE(p) > 0)
@@ -3374,9 +3379,10 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
3374 cpustat->irq = cputime64_add(cpustat->irq, tmp); 3379 cpustat->irq = cputime64_add(cpustat->irq, tmp);
3375 else if (softirq_count()) 3380 else if (softirq_count())
3376 cpustat->softirq = cputime64_add(cpustat->softirq, tmp); 3381 cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
3377 else if (p != rq->idle) 3382 else if (p != rq->idle) {
3378 cpustat->system = cputime64_add(cpustat->system, tmp); 3383 cpustat->system = cputime64_add(cpustat->system, tmp);
3379 else if (atomic_read(&rq->nr_iowait) > 0) 3384 cpuacct_charge(p, cputime);
3385 } else if (atomic_read(&rq->nr_iowait) > 0)
3380 cpustat->iowait = cputime64_add(cpustat->iowait, tmp); 3386 cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
3381 else 3387 else
3382 cpustat->idle = cputime64_add(cpustat->idle, tmp); 3388 cpustat->idle = cputime64_add(cpustat->idle, tmp);
@@ -3412,8 +3418,10 @@ void account_steal_time(struct task_struct *p, cputime_t steal)
3412 cpustat->iowait = cputime64_add(cpustat->iowait, tmp); 3418 cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
3413 else 3419 else
3414 cpustat->idle = cputime64_add(cpustat->idle, tmp); 3420 cpustat->idle = cputime64_add(cpustat->idle, tmp);
3415 } else 3421 } else {
3416 cpustat->steal = cputime64_add(cpustat->steal, tmp); 3422 cpustat->steal = cputime64_add(cpustat->steal, tmp);
3423 cpuacct_charge(p, -tmp);
3424 }
3417} 3425}
3418 3426
3419/* 3427/*