aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 17e2c1db2bde..e6ba726941ae 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5187,6 +5187,16 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
5187 *ut = p->utime; 5187 *ut = p->utime;
5188 *st = p->stime; 5188 *st = p->stime;
5189} 5189}
5190
5191void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
5192{
5193 struct task_cputime cputime;
5194
5195 thread_group_cputime(p, &cputime);
5196
5197 *ut = cputime.utime;
5198 *st = cputime.stime;
5199}
5190#else 5200#else
5191 5201
5192#ifndef nsecs_to_cputime 5202#ifndef nsecs_to_cputime
@@ -5220,6 +5230,37 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
5220 *ut = p->prev_utime; 5230 *ut = p->prev_utime;
5221 *st = p->prev_stime; 5231 *st = p->prev_stime;
5222} 5232}
5233
5234/*
5235 * Must be called with siglock held.
5236 */
5237void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st)
5238{
5239 struct signal_struct *sig = p->signal;
5240 struct task_cputime cputime;
5241 cputime_t rtime, utime, total;
5242
5243 thread_group_cputime(p, &cputime);
5244
5245 total = cputime_add(cputime.utime, cputime.stime);
5246 rtime = nsecs_to_cputime(cputime.sum_exec_runtime);
5247
5248 if (total) {
5249 u64 temp;
5250
5251 temp = (u64)(rtime * cputime.utime);
5252 do_div(temp, total);
5253 utime = (cputime_t)temp;
5254 } else
5255 utime = rtime;
5256
5257 sig->prev_utime = max(sig->prev_utime, utime);
5258 sig->prev_stime = max(sig->prev_stime,
5259 cputime_sub(rtime, sig->prev_utime));
5260
5261 *ut = sig->prev_utime;
5262 *st = sig->prev_stime;
5263}
5223#endif 5264#endif
5224 5265
5225/* 5266/*