aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2012-11-21 18:58:35 -0500
committerFrederic Weisbecker <fweisbec@gmail.com>2012-11-28 11:08:10 -0500
commitd37f761dbd276790f70dcf73a287fde2c3464482 (patch)
tree302d4bda699ab2e159b3a180f253019a38bf8132 /include/linux/sched.h
parente80d0a1ae8bb8fee0edd37427836f108b30f596b (diff)
cputime: Consolidate cputime adjustment code
task_cputime_adjusted() and thread_group_cputime_adjusted() essentially share the same code. They just don't use the same source: * The first function uses the cputime in the task struct and the previous adjusted snapshot that ensures monotonicity. * The second adds the cputime of all tasks in the group and the previous adjusted snapshot of the whole group from the signal structure. Just consolidate the common code that does the adjustment. These functions just need to fetch the values from the appropriate source. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e75cab5820ab..5dafac366811 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -434,13 +434,28 @@ struct cpu_itimer {
434}; 434};
435 435
436/** 436/**
437 * struct cputime - snaphsot of system and user cputime
438 * @utime: time spent in user mode
439 * @stime: time spent in system mode
440 *
441 * Gathers a generic snapshot of user and system time.
442 */
443struct cputime {
444 cputime_t utime;
445 cputime_t stime;
446};
447
448/**
437 * struct task_cputime - collected CPU time counts 449 * struct task_cputime - collected CPU time counts
438 * @utime: time spent in user mode, in &cputime_t units 450 * @utime: time spent in user mode, in &cputime_t units
439 * @stime: time spent in kernel mode, in &cputime_t units 451 * @stime: time spent in kernel mode, in &cputime_t units
440 * @sum_exec_runtime: total time spent on the CPU, in nanoseconds 452 * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
441 * 453 *
442 * This structure groups together three kinds of CPU time that are 454 * This is an extension of struct cputime that includes the total runtime
443 * tracked for threads and thread groups. Most things considering 455 * spent by the task from the scheduler point of view.
456 *
457 * As a result, this structure groups together three kinds of CPU time
458 * that are tracked for threads and thread groups. Most things considering
444 * CPU time want to group these counts together and treat all three 459 * CPU time want to group these counts together and treat all three
445 * of them in parallel. 460 * of them in parallel.
446 */ 461 */
@@ -581,7 +596,7 @@ struct signal_struct {
581 cputime_t gtime; 596 cputime_t gtime;
582 cputime_t cgtime; 597 cputime_t cgtime;
583#ifndef CONFIG_VIRT_CPU_ACCOUNTING 598#ifndef CONFIG_VIRT_CPU_ACCOUNTING
584 cputime_t prev_utime, prev_stime; 599 struct cputime prev_cputime;
585#endif 600#endif
586 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 601 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
587 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt; 602 unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
@@ -1340,7 +1355,7 @@ struct task_struct {
1340 cputime_t utime, stime, utimescaled, stimescaled; 1355 cputime_t utime, stime, utimescaled, stimescaled;
1341 cputime_t gtime; 1356 cputime_t gtime;
1342#ifndef CONFIG_VIRT_CPU_ACCOUNTING 1357#ifndef CONFIG_VIRT_CPU_ACCOUNTING
1343 cputime_t prev_utime, prev_stime; 1358 struct cputime prev_cputime;
1344#endif 1359#endif
1345 unsigned long nvcsw, nivcsw; /* context switch counts */ 1360 unsigned long nvcsw, nivcsw; /* context switch counts */
1346 struct timespec start_time; /* monotonic time */ 1361 struct timespec start_time; /* monotonic time */