diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 6f230596bd0c..09a8c15748f1 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -4052,23 +4052,26 @@ DEFINE_PER_CPU(struct kernel_stat, kstat); | |||
4052 | EXPORT_PER_CPU_SYMBOL(kstat); | 4052 | EXPORT_PER_CPU_SYMBOL(kstat); |
4053 | 4053 | ||
4054 | /* | 4054 | /* |
4055 | * Return p->sum_exec_runtime plus any more ns on the sched_clock | 4055 | * Return any ns on the sched_clock that have not yet been banked in |
4056 | * that have not yet been banked in case the task is currently running. | 4056 | * @p in case that task is currently running. |
4057 | */ | 4057 | */ |
4058 | unsigned long long task_sched_runtime(struct task_struct *p) | 4058 | unsigned long long task_delta_exec(struct task_struct *p) |
4059 | { | 4059 | { |
4060 | unsigned long flags; | 4060 | unsigned long flags; |
4061 | u64 ns, delta_exec; | ||
4062 | struct rq *rq; | 4061 | struct rq *rq; |
4062 | u64 ns = 0; | ||
4063 | 4063 | ||
4064 | rq = task_rq_lock(p, &flags); | 4064 | rq = task_rq_lock(p, &flags); |
4065 | ns = p->se.sum_exec_runtime; | 4065 | |
4066 | if (task_current(rq, p)) { | 4066 | if (task_current(rq, p)) { |
4067 | u64 delta_exec; | ||
4068 | |||
4067 | update_rq_clock(rq); | 4069 | update_rq_clock(rq); |
4068 | delta_exec = rq->clock - p->se.exec_start; | 4070 | delta_exec = rq->clock - p->se.exec_start; |
4069 | if ((s64)delta_exec > 0) | 4071 | if ((s64)delta_exec > 0) |
4070 | ns += delta_exec; | 4072 | ns = delta_exec; |
4071 | } | 4073 | } |
4074 | |||
4072 | task_rq_unlock(rq, &flags); | 4075 | task_rq_unlock(rq, &flags); |
4073 | 4076 | ||
4074 | return ns; | 4077 | return ns; |
@@ -4085,6 +4088,7 @@ void account_user_time(struct task_struct *p, cputime_t cputime) | |||
4085 | cputime64_t tmp; | 4088 | cputime64_t tmp; |
4086 | 4089 | ||
4087 | p->utime = cputime_add(p->utime, cputime); | 4090 | p->utime = cputime_add(p->utime, cputime); |
4091 | account_group_user_time(p, cputime); | ||
4088 | 4092 | ||
4089 | /* Add user time to cpustat. */ | 4093 | /* Add user time to cpustat. */ |
4090 | tmp = cputime_to_cputime64(cputime); | 4094 | tmp = cputime_to_cputime64(cputime); |
@@ -4109,6 +4113,7 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime) | |||
4109 | tmp = cputime_to_cputime64(cputime); | 4113 | tmp = cputime_to_cputime64(cputime); |
4110 | 4114 | ||
4111 | p->utime = cputime_add(p->utime, cputime); | 4115 | p->utime = cputime_add(p->utime, cputime); |
4116 | account_group_user_time(p, cputime); | ||
4112 | p->gtime = cputime_add(p->gtime, cputime); | 4117 | p->gtime = cputime_add(p->gtime, cputime); |
4113 | 4118 | ||
4114 | cpustat->user = cputime64_add(cpustat->user, tmp); | 4119 | cpustat->user = cputime64_add(cpustat->user, tmp); |
@@ -4144,6 +4149,7 @@ void account_system_time(struct task_struct *p, int hardirq_offset, | |||
4144 | } | 4149 | } |
4145 | 4150 | ||
4146 | p->stime = cputime_add(p->stime, cputime); | 4151 | p->stime = cputime_add(p->stime, cputime); |
4152 | account_group_system_time(p, cputime); | ||
4147 | 4153 | ||
4148 | /* Add system time to cpustat. */ | 4154 | /* Add system time to cpustat. */ |
4149 | tmp = cputime_to_cputime64(cputime); | 4155 | tmp = cputime_to_cputime64(cputime); |
@@ -4185,6 +4191,7 @@ void account_steal_time(struct task_struct *p, cputime_t steal) | |||
4185 | 4191 | ||
4186 | if (p == rq->idle) { | 4192 | if (p == rq->idle) { |
4187 | p->stime = cputime_add(p->stime, steal); | 4193 | p->stime = cputime_add(p->stime, steal); |
4194 | account_group_system_time(p, steal); | ||
4188 | if (atomic_read(&rq->nr_iowait) > 0) | 4195 | if (atomic_read(&rq->nr_iowait) > 0) |
4189 | cpustat->iowait = cputime64_add(cpustat->iowait, tmp); | 4196 | cpustat->iowait = cputime64_add(cpustat->iowait, tmp); |
4190 | else | 4197 | else |