diff options
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 5a7c76388731..011db2f4c94c 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -453,23 +453,33 @@ struct task_cputime { | |||
453 | cputime_t utime; | 453 | cputime_t utime; |
454 | cputime_t stime; | 454 | cputime_t stime; |
455 | unsigned long long sum_exec_runtime; | 455 | unsigned long long sum_exec_runtime; |
456 | spinlock_t lock; | ||
457 | }; | 456 | }; |
458 | /* Alternate field names when used to cache expirations. */ | 457 | /* Alternate field names when used to cache expirations. */ |
459 | #define prof_exp stime | 458 | #define prof_exp stime |
460 | #define virt_exp utime | 459 | #define virt_exp utime |
461 | #define sched_exp sum_exec_runtime | 460 | #define sched_exp sum_exec_runtime |
462 | 461 | ||
462 | #define INIT_CPUTIME \ | ||
463 | (struct task_cputime) { \ | ||
464 | .utime = cputime_zero, \ | ||
465 | .stime = cputime_zero, \ | ||
466 | .sum_exec_runtime = 0, \ | ||
467 | } | ||
468 | |||
463 | /** | 469 | /** |
464 | * struct thread_group_cputime - thread group interval timer counts | 470 | * struct thread_group_cputimer - thread group interval timer counts |
465 | * @totals: thread group interval timers; substructure for | 471 | * @cputime: thread group interval timers. |
466 | * uniprocessor kernel, per-cpu for SMP kernel. | 472 | * @running: non-zero when there are timers running and |
473 | * @cputime receives updates. | ||
474 | * @lock: lock for fields in this struct. | ||
467 | * | 475 | * |
468 | * This structure contains the version of task_cputime, above, that is | 476 | * This structure contains the version of task_cputime, above, that is |
469 | * used for thread group CPU clock calculations. | 477 | * used for thread group CPU timer calculations. |
470 | */ | 478 | */ |
471 | struct thread_group_cputime { | 479 | struct thread_group_cputimer { |
472 | struct task_cputime totals; | 480 | struct task_cputime cputime; |
481 | int running; | ||
482 | spinlock_t lock; | ||
473 | }; | 483 | }; |
474 | 484 | ||
475 | /* | 485 | /* |
@@ -518,10 +528,10 @@ struct signal_struct { | |||
518 | cputime_t it_prof_incr, it_virt_incr; | 528 | cputime_t it_prof_incr, it_virt_incr; |
519 | 529 | ||
520 | /* | 530 | /* |
521 | * Thread group totals for process CPU clocks. | 531 | * Thread group totals for process CPU timers. |
522 | * See thread_group_cputime(), et al, for details. | 532 | * See thread_group_cputimer(), et al, for details. |
523 | */ | 533 | */ |
524 | struct thread_group_cputime cputime; | 534 | struct thread_group_cputimer cputimer; |
525 | 535 | ||
526 | /* Earliest-expiration cache. */ | 536 | /* Earliest-expiration cache. */ |
527 | struct task_cputime cputime_expires; | 537 | struct task_cputime cputime_expires; |
@@ -558,7 +568,7 @@ struct signal_struct { | |||
558 | * Live threads maintain their own counters and add to these | 568 | * Live threads maintain their own counters and add to these |
559 | * in __exit_signal, except for the group leader. | 569 | * in __exit_signal, except for the group leader. |
560 | */ | 570 | */ |
561 | cputime_t cutime, cstime; | 571 | cputime_t utime, stime, cutime, cstime; |
562 | cputime_t gtime; | 572 | cputime_t gtime; |
563 | cputime_t cgtime; | 573 | cputime_t cgtime; |
564 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; | 574 | unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; |
@@ -567,6 +577,14 @@ struct signal_struct { | |||
567 | struct task_io_accounting ioac; | 577 | struct task_io_accounting ioac; |
568 | 578 | ||
569 | /* | 579 | /* |
580 | * Cumulative ns of schedule CPU time fo dead threads in the | ||
581 | * group, not including a zombie group leader, (This only differs | ||
582 | * from jiffies_to_ns(utime + stime) if sched_clock uses something | ||
583 | * other than jiffies.) | ||
584 | */ | ||
585 | unsigned long long sum_sched_runtime; | ||
586 | |||
587 | /* | ||
570 | * We don't bother to synchronize most readers of this at all, | 588 | * We don't bother to synchronize most readers of this at all, |
571 | * because there is no reader checking a limit that actually needs | 589 | * because there is no reader checking a limit that actually needs |
572 | * to get both rlim_cur and rlim_max atomically, and either one | 590 | * to get both rlim_cur and rlim_max atomically, and either one |
@@ -1401,6 +1419,9 @@ struct task_struct { | |||
1401 | #endif | 1419 | #endif |
1402 | }; | 1420 | }; |
1403 | 1421 | ||
1422 | /* Future-safe accessor for struct task_struct's cpus_allowed. */ | ||
1423 | #define tsk_cpumask(tsk) (&(tsk)->cpus_allowed) | ||
1424 | |||
1404 | /* | 1425 | /* |
1405 | * Priority of a process goes from 0..MAX_PRIO-1, valid RT | 1426 | * Priority of a process goes from 0..MAX_PRIO-1, valid RT |
1406 | * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH | 1427 | * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH |
@@ -2182,27 +2203,14 @@ static inline int spin_needbreak(spinlock_t *lock) | |||
2182 | /* | 2203 | /* |
2183 | * Thread group CPU time accounting. | 2204 | * Thread group CPU time accounting. |
2184 | */ | 2205 | */ |
2185 | 2206 | void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times); | |
2186 | static inline | 2207 | void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times); |
2187 | void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) | ||
2188 | { | ||
2189 | struct task_cputime *totals = &tsk->signal->cputime.totals; | ||
2190 | unsigned long flags; | ||
2191 | |||
2192 | spin_lock_irqsave(&totals->lock, flags); | ||
2193 | *times = *totals; | ||
2194 | spin_unlock_irqrestore(&totals->lock, flags); | ||
2195 | } | ||
2196 | 2208 | ||
2197 | static inline void thread_group_cputime_init(struct signal_struct *sig) | 2209 | static inline void thread_group_cputime_init(struct signal_struct *sig) |
2198 | { | 2210 | { |
2199 | sig->cputime.totals = (struct task_cputime){ | 2211 | sig->cputimer.cputime = INIT_CPUTIME; |
2200 | .utime = cputime_zero, | 2212 | spin_lock_init(&sig->cputimer.lock); |
2201 | .stime = cputime_zero, | 2213 | sig->cputimer.running = 0; |
2202 | .sum_exec_runtime = 0, | ||
2203 | }; | ||
2204 | |||
2205 | spin_lock_init(&sig->cputime.totals.lock); | ||
2206 | } | 2214 | } |
2207 | 2215 | ||
2208 | static inline void thread_group_cputime_free(struct signal_struct *sig) | 2216 | static inline void thread_group_cputime_free(struct signal_struct *sig) |
@@ -2286,9 +2294,13 @@ extern long sched_group_rt_runtime(struct task_group *tg); | |||
2286 | extern int sched_group_set_rt_period(struct task_group *tg, | 2294 | extern int sched_group_set_rt_period(struct task_group *tg, |
2287 | long rt_period_us); | 2295 | long rt_period_us); |
2288 | extern long sched_group_rt_period(struct task_group *tg); | 2296 | extern long sched_group_rt_period(struct task_group *tg); |
2297 | extern int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk); | ||
2289 | #endif | 2298 | #endif |
2290 | #endif | 2299 | #endif |
2291 | 2300 | ||
2301 | extern int task_can_switch_user(struct user_struct *up, | ||
2302 | struct task_struct *tsk); | ||
2303 | |||
2292 | #ifdef CONFIG_TASK_XACCT | 2304 | #ifdef CONFIG_TASK_XACCT |
2293 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) | 2305 | static inline void add_rchar(struct task_struct *tsk, ssize_t amt) |
2294 | { | 2306 | { |