summaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2017-01-30 22:09:22 -0500
committerIngo Molnar <mingo@kernel.org>2017-02-01 03:13:48 -0500
commita1cecf2ba78e0a6de00ff99df34b662728535aa5 (patch)
tree6435af480632b1605e8075e24cc1170b29a6603f /include/linux/sched.h
parent16a6d9be90373fb0b521850cd0185a4d460dd152 (diff)
sched/cputime: Introduce special task_cputime_t() API to return old-typed cputime
This API returns a task's cputime in cputime_t in order to ease the conversion of cputime internals to use nsecs units instead. Blindly converting all cputime readers to use this API now will later let us convert more smoothly and step by step all these places to use the new nsec based cputime. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Stanislaw Gruszka <sgruszka@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Wanpeng Li <wanpeng.li@hotmail.com> Link: http://lkml.kernel.org/r/1485832191-26889-7-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 252ff25983c8..9cc722f77799 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -615,6 +615,13 @@ struct task_cputime {
615 unsigned long long sum_exec_runtime; 615 unsigned long long sum_exec_runtime;
616}; 616};
617 617
618/* Temporary type to ease cputime_t to nsecs conversion */
619struct task_cputime_t {
620 cputime_t utime;
621 cputime_t stime;
622 unsigned long long sum_exec_runtime;
623};
624
618/* Alternate field names when used to cache expirations. */ 625/* Alternate field names when used to cache expirations. */
619#define virt_exp utime 626#define virt_exp utime
620#define prof_exp stime 627#define prof_exp stime
@@ -748,7 +755,7 @@ struct signal_struct {
748 struct thread_group_cputimer cputimer; 755 struct thread_group_cputimer cputimer;
749 756
750 /* Earliest-expiration cache. */ 757 /* Earliest-expiration cache. */
751 struct task_cputime cputime_expires; 758 struct task_cputime_t cputime_expires;
752 759
753#ifdef CONFIG_NO_HZ_FULL 760#ifdef CONFIG_NO_HZ_FULL
754 atomic_t tick_dep_mask; 761 atomic_t tick_dep_mask;
@@ -1682,7 +1689,7 @@ struct task_struct {
1682/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */ 1689/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
1683 unsigned long min_flt, maj_flt; 1690 unsigned long min_flt, maj_flt;
1684 1691
1685 struct task_cputime cputime_expires; 1692 struct task_cputime_t cputime_expires;
1686 struct list_head cpu_timers[3]; 1693 struct list_head cpu_timers[3];
1687 1694
1688/* process credentials */ 1695/* process credentials */
@@ -2286,6 +2293,19 @@ static inline void task_cputime_scaled(struct task_struct *t,
2286} 2293}
2287#endif 2294#endif
2288 2295
2296static inline void task_cputime_t(struct task_struct *t,
2297 cputime_t *utime, cputime_t *stime)
2298{
2299 task_cputime(t, utime, stime);
2300}
2301
2302static inline void task_cputime_t_scaled(struct task_struct *t,
2303 cputime_t *utimescaled,
2304 cputime_t *stimescaled)
2305{
2306 task_cputime_scaled(t, utimescaled, stimescaled);
2307}
2308
2289extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); 2309extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
2290extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); 2310extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
2291 2311
@@ -3499,7 +3519,13 @@ static __always_inline bool need_resched(void)
3499 * Thread group CPU time accounting. 3519 * Thread group CPU time accounting.
3500 */ 3520 */
3501void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times); 3521void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
3502void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times); 3522void thread_group_cputimer(struct task_struct *tsk, struct task_cputime_t *times);
3523
3524static inline void thread_group_cputime_t(struct task_struct *tsk,
3525 struct task_cputime_t *times)
3526{
3527 thread_group_cputime(tsk, (struct task_cputime *)times);
3528}
3503 3529
3504/* 3530/*
3505 * Reevaluate whether the task has signals pending delivery. 3531 * Reevaluate whether the task has signals pending delivery.