aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 965625a0977d..ee4814dd98f9 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -320,7 +320,21 @@ int proc_pid_status(struct task_struct *task, char *buffer)
320 return buffer - orig; 320 return buffer - orig;
321} 321}
322 322
323static clock_t task_utime(struct task_struct *p) 323/*
324 * Use precise platform statistics if available:
325 */
326#ifdef CONFIG_VIRT_CPU_ACCOUNTING
327static cputime_t task_utime(struct task_struct *p)
328{
329 return p->utime;
330}
331
332static cputime_t task_stime(struct task_struct *p)
333{
334 return p->stime;
335}
336#else
337static cputime_t task_utime(struct task_struct *p)
324{ 338{
325 clock_t utime = cputime_to_clock_t(p->utime), 339 clock_t utime = cputime_to_clock_t(p->utime),
326 total = utime + cputime_to_clock_t(p->stime); 340 total = utime + cputime_to_clock_t(p->stime);
@@ -337,10 +351,10 @@ static clock_t task_utime(struct task_struct *p)
337 } 351 }
338 utime = (clock_t)temp; 352 utime = (clock_t)temp;
339 353
340 return utime; 354 return clock_t_to_cputime(utime);
341} 355}
342 356
343static clock_t task_stime(struct task_struct *p) 357static cputime_t task_stime(struct task_struct *p)
344{ 358{
345 clock_t stime; 359 clock_t stime;
346 360
@@ -349,10 +363,12 @@ static clock_t task_stime(struct task_struct *p)
349 * the total, to make sure the total observed by userspace 363 * the total, to make sure the total observed by userspace
350 * grows monotonically - apps rely on that): 364 * grows monotonically - apps rely on that):
351 */ 365 */
352 stime = nsec_to_clock_t(p->se.sum_exec_runtime) - task_utime(p); 366 stime = nsec_to_clock_t(p->se.sum_exec_runtime) -
367 cputime_to_clock_t(task_utime(p));
353 368
354 return stime; 369 return clock_t_to_cputime(stime);
355} 370}
371#endif
356 372
357static int do_task_stat(struct task_struct *task, char *buffer, int whole) 373static int do_task_stat(struct task_struct *task, char *buffer, int whole)
358{ 374{
@@ -368,8 +384,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
368 unsigned long long start_time; 384 unsigned long long start_time;
369 unsigned long cmin_flt = 0, cmaj_flt = 0; 385 unsigned long cmin_flt = 0, cmaj_flt = 0;
370 unsigned long min_flt = 0, maj_flt = 0; 386 unsigned long min_flt = 0, maj_flt = 0;
371 cputime_t cutime, cstime; 387 cputime_t cutime, cstime, utime, stime;
372 clock_t utime, stime;
373 unsigned long rsslim = 0; 388 unsigned long rsslim = 0;
374 char tcomm[sizeof(task->comm)]; 389 char tcomm[sizeof(task->comm)];
375 unsigned long flags; 390 unsigned long flags;
@@ -387,8 +402,7 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
387 402
388 sigemptyset(&sigign); 403 sigemptyset(&sigign);
389 sigemptyset(&sigcatch); 404 sigemptyset(&sigcatch);
390 cutime = cstime = cputime_zero; 405 cutime = cstime = utime = stime = cputime_zero;
391 utime = stime = 0;
392 406
393 rcu_read_lock(); 407 rcu_read_lock();
394 if (lock_task_sighand(task, &flags)) { 408 if (lock_task_sighand(task, &flags)) {
@@ -414,15 +428,15 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
414 do { 428 do {
415 min_flt += t->min_flt; 429 min_flt += t->min_flt;
416 maj_flt += t->maj_flt; 430 maj_flt += t->maj_flt;
417 utime += task_utime(t); 431 utime = cputime_add(utime, task_utime(t));
418 stime += task_stime(t); 432 stime = cputime_add(stime, task_stime(t));
419 t = next_thread(t); 433 t = next_thread(t);
420 } while (t != task); 434 } while (t != task);
421 435
422 min_flt += sig->min_flt; 436 min_flt += sig->min_flt;
423 maj_flt += sig->maj_flt; 437 maj_flt += sig->maj_flt;
424 utime += cputime_to_clock_t(sig->utime); 438 utime = cputime_add(utime, sig->utime);
425 stime += cputime_to_clock_t(sig->stime); 439 stime = cputime_add(stime, sig->stime);
426 } 440 }
427 441
428 sid = signal_session(sig); 442 sid = signal_session(sig);
@@ -471,8 +485,8 @@ static int do_task_stat(struct task_struct *task, char *buffer, int whole)
471 cmin_flt, 485 cmin_flt,
472 maj_flt, 486 maj_flt,
473 cmaj_flt, 487 cmaj_flt,
474 utime, 488 cputime_to_clock_t(utime),
475 stime, 489 cputime_to_clock_t(stime),
476 cputime_to_clock_t(cutime), 490 cputime_to_clock_t(cutime),
477 cputime_to_clock_t(cstime), 491 cputime_to_clock_t(cstime),
478 priority, 492 priority,