aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index c51b5d276665..260c22cc530a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4039,55 +4039,22 @@ EXPORT_PER_CPU_SYMBOL(kstat);
4039/* 4039/*
4040 * Return any ns on the sched_clock that have not yet been banked in 4040 * Return any ns on the sched_clock that have not yet been banked in
4041 * @p in case that task is currently running. 4041 * @p in case that task is currently running.
4042 *
4043 * Called with task_rq_lock() held on @rq.
4044 */ 4042 */
4045static unsigned long long task_delta_exec(struct task_struct *p, struct rq *rq) 4043unsigned long long task_delta_exec(struct task_struct *p)
4046{ 4044{
4045 struct rq *rq;
4046 unsigned long flags;
4047 u64 ns = 0;
4048
4049 rq = task_rq_lock(p, &flags);
4047 if (task_current(rq, p)) { 4050 if (task_current(rq, p)) {
4048 u64 delta_exec; 4051 u64 delta_exec;
4049 4052
4050 update_rq_clock(rq); 4053 update_rq_clock(rq);
4051 delta_exec = rq->clock - p->se.exec_start; 4054 delta_exec = rq->clock - p->se.exec_start;
4052 if ((s64)delta_exec > 0) 4055 if ((s64)delta_exec > 0)
4053 return delta_exec; 4056 ns = delta_exec;
4054 } 4057 }
4055 return 0;
4056}
4057
4058/*
4059 * Return p->sum_exec_runtime plus any more ns on the sched_clock
4060 * that have not yet been banked in case the task is currently running.
4061 */
4062unsigned long long task_sched_runtime(struct task_struct *p)
4063{
4064 unsigned long flags;
4065 u64 ns;
4066 struct rq *rq;
4067
4068 rq = task_rq_lock(p, &flags);
4069 ns = p->se.sum_exec_runtime + task_delta_exec(p, rq);
4070 task_rq_unlock(rq, &flags);
4071
4072 return ns;
4073}
4074
4075/*
4076 * Return sum_exec_runtime for the thread group plus any more ns on the
4077 * sched_clock that have not yet been banked in case the task is currently
4078 * running.
4079 */
4080unsigned long long thread_group_sched_runtime(struct task_struct *p)
4081{
4082 unsigned long flags;
4083 u64 ns;
4084 struct rq *rq;
4085 struct task_cputime totals;
4086
4087 rq = task_rq_lock(p, &flags);
4088 thread_group_cputime(p, &totals);
4089 ns = totals.sum_exec_runtime + task_delta_exec(p, rq);
4090 task_rq_unlock(rq, &flags);
4091 4058
4092 return ns; 4059 return ns;
4093} 4060}