aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 3d1ad130c24e..d906f72b42d2 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4047,23 +4047,26 @@ DEFINE_PER_CPU(struct kernel_stat, kstat);
4047EXPORT_PER_CPU_SYMBOL(kstat); 4047EXPORT_PER_CPU_SYMBOL(kstat);
4048 4048
4049/* 4049/*
4050 * Return p->sum_exec_runtime plus any more ns on the sched_clock 4050 * Return any ns on the sched_clock that have not yet been banked in
4051 * that have not yet been banked in case the task is currently running. 4051 * @p in case that task is currently running.
4052 */ 4052 */
4053unsigned long long task_sched_runtime(struct task_struct *p) 4053unsigned long long task_delta_exec(struct task_struct *p)
4054{ 4054{
4055 unsigned long flags; 4055 unsigned long flags;
4056 u64 ns, delta_exec;
4057 struct rq *rq; 4056 struct rq *rq;
4057 u64 ns = 0;
4058 4058
4059 rq = task_rq_lock(p, &flags); 4059 rq = task_rq_lock(p, &flags);
4060 ns = p->se.sum_exec_runtime; 4060
4061 if (task_current(rq, p)) { 4061 if (task_current(rq, p)) {
4062 u64 delta_exec;
4063
4062 update_rq_clock(rq); 4064 update_rq_clock(rq);
4063 delta_exec = rq->clock - p->se.exec_start; 4065 delta_exec = rq->clock - p->se.exec_start;
4064 if ((s64)delta_exec > 0) 4066 if ((s64)delta_exec > 0)
4065 ns += delta_exec; 4067 ns = delta_exec;
4066 } 4068 }
4069
4067 task_rq_unlock(rq, &flags); 4070 task_rq_unlock(rq, &flags);
4068 4071
4069 return ns; 4072 return ns;
@@ -4080,6 +4083,7 @@ void account_user_time(struct task_struct *p, cputime_t cputime)
4080 cputime64_t tmp; 4083 cputime64_t tmp;
4081 4084
4082 p->utime = cputime_add(p->utime, cputime); 4085 p->utime = cputime_add(p->utime, cputime);
4086 account_group_user_time(p, cputime);
4083 4087
4084 /* Add user time to cpustat. */ 4088 /* Add user time to cpustat. */
4085 tmp = cputime_to_cputime64(cputime); 4089 tmp = cputime_to_cputime64(cputime);
@@ -4104,6 +4108,7 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime)
4104 tmp = cputime_to_cputime64(cputime); 4108 tmp = cputime_to_cputime64(cputime);
4105 4109
4106 p->utime = cputime_add(p->utime, cputime); 4110 p->utime = cputime_add(p->utime, cputime);
4111 account_group_user_time(p, cputime);
4107 p->gtime = cputime_add(p->gtime, cputime); 4112 p->gtime = cputime_add(p->gtime, cputime);
4108 4113
4109 cpustat->user = cputime64_add(cpustat->user, tmp); 4114 cpustat->user = cputime64_add(cpustat->user, tmp);
@@ -4139,6 +4144,7 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
4139 } 4144 }
4140 4145
4141 p->stime = cputime_add(p->stime, cputime); 4146 p->stime = cputime_add(p->stime, cputime);
4147 account_group_system_time(p, cputime);
4142 4148
4143 /* Add system time to cpustat. */ 4149 /* Add system time to cpustat. */
4144 tmp = cputime_to_cputime64(cputime); 4150 tmp = cputime_to_cputime64(cputime);
@@ -4180,6 +4186,7 @@ void account_steal_time(struct task_struct *p, cputime_t steal)
4180 4186
4181 if (p == rq->idle) { 4187 if (p == rq->idle) {
4182 p->stime = cputime_add(p->stime, steal); 4188 p->stime = cputime_add(p->stime, steal);
4189 account_group_system_time(p, steal);
4183 if (atomic_read(&rq->nr_iowait) > 0) 4190 if (atomic_read(&rq->nr_iowait) > 0)
4184 cpustat->iowait = cputime64_add(cpustat->iowait, tmp); 4191 cpustat->iowait = cputime64_add(cpustat->iowait, tmp);
4185 else 4192 else