diff options
-rw-r--r-- | arch/alpha/kernel/osf_sys.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/apm_32.c | 11 | ||||
-rw-r--r-- | drivers/isdn/mISDN/stack.c | 7 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 8 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 7 | ||||
-rw-r--r-- | fs/proc/array.c | 4 | ||||
-rw-r--r-- | include/linux/sched.h | 23 | ||||
-rw-r--r-- | include/linux/tsacct_kern.h | 3 | ||||
-rw-r--r-- | kernel/acct.c | 6 | ||||
-rw-r--r-- | kernel/cpu.c | 4 | ||||
-rw-r--r-- | kernel/delayacct.c | 7 | ||||
-rw-r--r-- | kernel/exit.c | 10 | ||||
-rw-r--r-- | kernel/posix-cpu-timers.c | 28 | ||||
-rw-r--r-- | kernel/sched/cputime.c | 13 | ||||
-rw-r--r-- | kernel/signal.c | 12 | ||||
-rw-r--r-- | kernel/tsacct.c | 44 |
16 files changed, 144 insertions, 49 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 14db93e4c8a8..dbc1760f418b 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
@@ -1139,6 +1139,7 @@ struct rusage32 { | |||
1139 | SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru) | 1139 | SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru) |
1140 | { | 1140 | { |
1141 | struct rusage32 r; | 1141 | struct rusage32 r; |
1142 | cputime_t utime, stime; | ||
1142 | 1143 | ||
1143 | if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) | 1144 | if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) |
1144 | return -EINVAL; | 1145 | return -EINVAL; |
@@ -1146,8 +1147,9 @@ SYSCALL_DEFINE2(osf_getrusage, int, who, struct rusage32 __user *, ru) | |||
1146 | memset(&r, 0, sizeof(r)); | 1147 | memset(&r, 0, sizeof(r)); |
1147 | switch (who) { | 1148 | switch (who) { |
1148 | case RUSAGE_SELF: | 1149 | case RUSAGE_SELF: |
1149 | jiffies_to_timeval32(current->utime, &r.ru_utime); | 1150 | task_cputime(current, &utime, &stime); |
1150 | jiffies_to_timeval32(current->stime, &r.ru_stime); | 1151 | jiffies_to_timeval32(utime, &r.ru_utime); |
1152 | jiffies_to_timeval32(stime, &r.ru_stime); | ||
1151 | r.ru_minflt = current->min_flt; | 1153 | r.ru_minflt = current->min_flt; |
1152 | r.ru_majflt = current->maj_flt; | 1154 | r.ru_majflt = current->maj_flt; |
1153 | break; | 1155 | break; |
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index d65464e43503..8d7012b7f402 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
@@ -899,6 +899,7 @@ static void apm_cpu_idle(void) | |||
899 | static int use_apm_idle; /* = 0 */ | 899 | static int use_apm_idle; /* = 0 */ |
900 | static unsigned int last_jiffies; /* = 0 */ | 900 | static unsigned int last_jiffies; /* = 0 */ |
901 | static unsigned int last_stime; /* = 0 */ | 901 | static unsigned int last_stime; /* = 0 */ |
902 | cputime_t stime; | ||
902 | 903 | ||
903 | int apm_idle_done = 0; | 904 | int apm_idle_done = 0; |
904 | unsigned int jiffies_since_last_check = jiffies - last_jiffies; | 905 | unsigned int jiffies_since_last_check = jiffies - last_jiffies; |
@@ -906,23 +907,23 @@ static void apm_cpu_idle(void) | |||
906 | 907 | ||
907 | WARN_ONCE(1, "deprecated apm_cpu_idle will be deleted in 2012"); | 908 | WARN_ONCE(1, "deprecated apm_cpu_idle will be deleted in 2012"); |
908 | recalc: | 909 | recalc: |
910 | task_cputime(current, NULL, &stime); | ||
909 | if (jiffies_since_last_check > IDLE_CALC_LIMIT) { | 911 | if (jiffies_since_last_check > IDLE_CALC_LIMIT) { |
910 | use_apm_idle = 0; | 912 | use_apm_idle = 0; |
911 | last_jiffies = jiffies; | ||
912 | last_stime = current->stime; | ||
913 | } else if (jiffies_since_last_check > idle_period) { | 913 | } else if (jiffies_since_last_check > idle_period) { |
914 | unsigned int idle_percentage; | 914 | unsigned int idle_percentage; |
915 | 915 | ||
916 | idle_percentage = current->stime - last_stime; | 916 | idle_percentage = stime - last_stime; |
917 | idle_percentage *= 100; | 917 | idle_percentage *= 100; |
918 | idle_percentage /= jiffies_since_last_check; | 918 | idle_percentage /= jiffies_since_last_check; |
919 | use_apm_idle = (idle_percentage > idle_threshold); | 919 | use_apm_idle = (idle_percentage > idle_threshold); |
920 | if (apm_info.forbid_idle) | 920 | if (apm_info.forbid_idle) |
921 | use_apm_idle = 0; | 921 | use_apm_idle = 0; |
922 | last_jiffies = jiffies; | ||
923 | last_stime = current->stime; | ||
924 | } | 922 | } |
925 | 923 | ||
924 | last_jiffies = jiffies; | ||
925 | last_stime = stime; | ||
926 | |||
926 | bucket = IDLE_LEAKY_MAX; | 927 | bucket = IDLE_LEAKY_MAX; |
927 | 928 | ||
928 | while (!need_resched()) { | 929 | while (!need_resched()) { |
diff --git a/drivers/isdn/mISDN/stack.c b/drivers/isdn/mISDN/stack.c index 5f21f629b7ae..deda591f70b9 100644 --- a/drivers/isdn/mISDN/stack.c +++ b/drivers/isdn/mISDN/stack.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/mISDNif.h> | 19 | #include <linux/mISDNif.h> |
20 | #include <linux/kthread.h> | 20 | #include <linux/kthread.h> |
21 | #include <linux/sched.h> | ||
21 | #include "core.h" | 22 | #include "core.h" |
22 | 23 | ||
23 | static u_int *debug; | 24 | static u_int *debug; |
@@ -202,6 +203,9 @@ static int | |||
202 | mISDNStackd(void *data) | 203 | mISDNStackd(void *data) |
203 | { | 204 | { |
204 | struct mISDNstack *st = data; | 205 | struct mISDNstack *st = data; |
206 | #ifdef MISDN_MSG_STATS | ||
207 | cputime_t utime, stime; | ||
208 | #endif | ||
205 | int err = 0; | 209 | int err = 0; |
206 | 210 | ||
207 | sigfillset(¤t->blocked); | 211 | sigfillset(¤t->blocked); |
@@ -303,9 +307,10 @@ mISDNStackd(void *data) | |||
303 | "msg %d sleep %d stopped\n", | 307 | "msg %d sleep %d stopped\n", |
304 | dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt, | 308 | dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt, |
305 | st->stopped_cnt); | 309 | st->stopped_cnt); |
310 | task_cputime(st->thread, &utime, &stime); | ||
306 | printk(KERN_DEBUG | 311 | printk(KERN_DEBUG |
307 | "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", | 312 | "mISDNStackd daemon for %s utime(%ld) stime(%ld)\n", |
308 | dev_name(&st->dev->dev), st->thread->utime, st->thread->stime); | 313 | dev_name(&st->dev->dev), utime, stime); |
309 | printk(KERN_DEBUG | 314 | printk(KERN_DEBUG |
310 | "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", | 315 | "mISDNStackd daemon for %s nvcsw(%ld) nivcsw(%ld)\n", |
311 | dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw); | 316 | dev_name(&st->dev->dev), st->thread->nvcsw, st->thread->nivcsw); |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 0c42cdbabecf..49d0b43458b7 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/elf.h> | 33 | #include <linux/elf.h> |
34 | #include <linux/utsname.h> | 34 | #include <linux/utsname.h> |
35 | #include <linux/coredump.h> | 35 | #include <linux/coredump.h> |
36 | #include <linux/sched.h> | ||
36 | #include <asm/uaccess.h> | 37 | #include <asm/uaccess.h> |
37 | #include <asm/param.h> | 38 | #include <asm/param.h> |
38 | #include <asm/page.h> | 39 | #include <asm/page.h> |
@@ -1320,8 +1321,11 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
1320 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); | 1321 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); |
1321 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); | 1322 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); |
1322 | } else { | 1323 | } else { |
1323 | cputime_to_timeval(p->utime, &prstatus->pr_utime); | 1324 | cputime_t utime, stime; |
1324 | cputime_to_timeval(p->stime, &prstatus->pr_stime); | 1325 | |
1326 | task_cputime(p, &utime, &stime); | ||
1327 | cputime_to_timeval(utime, &prstatus->pr_utime); | ||
1328 | cputime_to_timeval(stime, &prstatus->pr_stime); | ||
1325 | } | 1329 | } |
1326 | cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime); | 1330 | cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime); |
1327 | cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime); | 1331 | cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime); |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index dc84732e554f..cb240dd3b402 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -1375,8 +1375,11 @@ static void fill_prstatus(struct elf_prstatus *prstatus, | |||
1375 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); | 1375 | cputime_to_timeval(cputime.utime, &prstatus->pr_utime); |
1376 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); | 1376 | cputime_to_timeval(cputime.stime, &prstatus->pr_stime); |
1377 | } else { | 1377 | } else { |
1378 | cputime_to_timeval(p->utime, &prstatus->pr_utime); | 1378 | cputime_t utime, stime; |
1379 | cputime_to_timeval(p->stime, &prstatus->pr_stime); | 1379 | |
1380 | task_cputime(p, &utime, &stime); | ||
1381 | cputime_to_timeval(utime, &prstatus->pr_utime); | ||
1382 | cputime_to_timeval(stime, &prstatus->pr_stime); | ||
1380 | } | 1383 | } |
1381 | cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime); | 1384 | cputime_to_timeval(p->signal->cutime, &prstatus->pr_cutime); |
1382 | cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime); | 1385 | cputime_to_timeval(p->signal->cstime, &prstatus->pr_cstime); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 6a91e6ffbcbd..f7ed9ee46eb9 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -449,7 +449,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
449 | do { | 449 | do { |
450 | min_flt += t->min_flt; | 450 | min_flt += t->min_flt; |
451 | maj_flt += t->maj_flt; | 451 | maj_flt += t->maj_flt; |
452 | gtime += t->gtime; | 452 | gtime += task_gtime(t); |
453 | t = next_thread(t); | 453 | t = next_thread(t); |
454 | } while (t != task); | 454 | } while (t != task); |
455 | 455 | ||
@@ -472,7 +472,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, | |||
472 | min_flt = task->min_flt; | 472 | min_flt = task->min_flt; |
473 | maj_flt = task->maj_flt; | 473 | maj_flt = task->maj_flt; |
474 | task_cputime_adjusted(task, &utime, &stime); | 474 | task_cputime_adjusted(task, &utime, &stime); |
475 | gtime = task->gtime; | 475 | gtime = task_gtime(task); |
476 | } | 476 | } |
477 | 477 | ||
478 | /* scale priority and nice values from timeslices to -20..20 */ | 478 | /* scale priority and nice values from timeslices to -20..20 */ |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6fc8f45de4e9..a9c608b6154e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1792,6 +1792,29 @@ static inline void put_task_struct(struct task_struct *t) | |||
1792 | __put_task_struct(t); | 1792 | __put_task_struct(t); |
1793 | } | 1793 | } |
1794 | 1794 | ||
1795 | static inline cputime_t task_gtime(struct task_struct *t) | ||
1796 | { | ||
1797 | return t->gtime; | ||
1798 | } | ||
1799 | |||
1800 | static inline void task_cputime(struct task_struct *t, | ||
1801 | cputime_t *utime, cputime_t *stime) | ||
1802 | { | ||
1803 | if (utime) | ||
1804 | *utime = t->utime; | ||
1805 | if (stime) | ||
1806 | *stime = t->stime; | ||
1807 | } | ||
1808 | |||
1809 | static inline void task_cputime_scaled(struct task_struct *t, | ||
1810 | cputime_t *utimescaled, | ||
1811 | cputime_t *stimescaled) | ||
1812 | { | ||
1813 | if (utimescaled) | ||
1814 | *utimescaled = t->utimescaled; | ||
1815 | if (stimescaled) | ||
1816 | *stimescaled = t->stimescaled; | ||
1817 | } | ||
1795 | extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); | 1818 | extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); |
1796 | extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); | 1819 | extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st); |
1797 | 1820 | ||
diff --git a/include/linux/tsacct_kern.h b/include/linux/tsacct_kern.h index 44893e5ec8f7..3251965bf4cc 100644 --- a/include/linux/tsacct_kern.h +++ b/include/linux/tsacct_kern.h | |||
@@ -23,12 +23,15 @@ static inline void bacct_add_tsk(struct user_namespace *user_ns, | |||
23 | #ifdef CONFIG_TASK_XACCT | 23 | #ifdef CONFIG_TASK_XACCT |
24 | extern void xacct_add_tsk(struct taskstats *stats, struct task_struct *p); | 24 | extern void xacct_add_tsk(struct taskstats *stats, struct task_struct *p); |
25 | extern void acct_update_integrals(struct task_struct *tsk); | 25 | extern void acct_update_integrals(struct task_struct *tsk); |
26 | extern void acct_account_cputime(struct task_struct *tsk); | ||
26 | extern void acct_clear_integrals(struct task_struct *tsk); | 27 | extern void acct_clear_integrals(struct task_struct *tsk); |
27 | #else | 28 | #else |
28 | static inline void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | 29 | static inline void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) |
29 | {} | 30 | {} |
30 | static inline void acct_update_integrals(struct task_struct *tsk) | 31 | static inline void acct_update_integrals(struct task_struct *tsk) |
31 | {} | 32 | {} |
33 | static inline void acct_account_cputime(struct task_struct *tsk) | ||
34 | {} | ||
32 | static inline void acct_clear_integrals(struct task_struct *tsk) | 35 | static inline void acct_clear_integrals(struct task_struct *tsk) |
33 | {} | 36 | {} |
34 | #endif /* CONFIG_TASK_XACCT */ | 37 | #endif /* CONFIG_TASK_XACCT */ |
diff --git a/kernel/acct.c b/kernel/acct.c index 051e071a06e7..e8b1627ab9c7 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -566,6 +566,7 @@ out: | |||
566 | void acct_collect(long exitcode, int group_dead) | 566 | void acct_collect(long exitcode, int group_dead) |
567 | { | 567 | { |
568 | struct pacct_struct *pacct = ¤t->signal->pacct; | 568 | struct pacct_struct *pacct = ¤t->signal->pacct; |
569 | cputime_t utime, stime; | ||
569 | unsigned long vsize = 0; | 570 | unsigned long vsize = 0; |
570 | 571 | ||
571 | if (group_dead && current->mm) { | 572 | if (group_dead && current->mm) { |
@@ -593,8 +594,9 @@ void acct_collect(long exitcode, int group_dead) | |||
593 | pacct->ac_flag |= ACORE; | 594 | pacct->ac_flag |= ACORE; |
594 | if (current->flags & PF_SIGNALED) | 595 | if (current->flags & PF_SIGNALED) |
595 | pacct->ac_flag |= AXSIG; | 596 | pacct->ac_flag |= AXSIG; |
596 | pacct->ac_utime += current->utime; | 597 | task_cputime(current, &utime, &stime); |
597 | pacct->ac_stime += current->stime; | 598 | pacct->ac_utime += utime; |
599 | pacct->ac_stime += stime; | ||
598 | pacct->ac_minflt += current->min_flt; | 600 | pacct->ac_minflt += current->min_flt; |
599 | pacct->ac_majflt += current->maj_flt; | 601 | pacct->ac_majflt += current->maj_flt; |
600 | spin_unlock_irq(¤t->sighand->siglock); | 602 | spin_unlock_irq(¤t->sighand->siglock); |
diff --git a/kernel/cpu.c b/kernel/cpu.c index 3046a503242c..e5d5e8e1e030 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -224,11 +224,13 @@ void clear_tasks_mm_cpumask(int cpu) | |||
224 | static inline void check_for_tasks(int cpu) | 224 | static inline void check_for_tasks(int cpu) |
225 | { | 225 | { |
226 | struct task_struct *p; | 226 | struct task_struct *p; |
227 | cputime_t utime, stime; | ||
227 | 228 | ||
228 | write_lock_irq(&tasklist_lock); | 229 | write_lock_irq(&tasklist_lock); |
229 | for_each_process(p) { | 230 | for_each_process(p) { |
231 | task_cputime(p, &utime, &stime); | ||
230 | if (task_cpu(p) == cpu && p->state == TASK_RUNNING && | 232 | if (task_cpu(p) == cpu && p->state == TASK_RUNNING && |
231 | (p->utime || p->stime)) | 233 | (utime || stime)) |
232 | printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " | 234 | printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " |
233 | "(state = %ld, flags = %x)\n", | 235 | "(state = %ld, flags = %x)\n", |
234 | p->comm, task_pid_nr(p), cpu, | 236 | p->comm, task_pid_nr(p), cpu, |
diff --git a/kernel/delayacct.c b/kernel/delayacct.c index 418b3f7053aa..d473988c1d0b 100644 --- a/kernel/delayacct.c +++ b/kernel/delayacct.c | |||
@@ -106,6 +106,7 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk) | |||
106 | unsigned long long t2, t3; | 106 | unsigned long long t2, t3; |
107 | unsigned long flags; | 107 | unsigned long flags; |
108 | struct timespec ts; | 108 | struct timespec ts; |
109 | cputime_t utime, stime, stimescaled, utimescaled; | ||
109 | 110 | ||
110 | /* Though tsk->delays accessed later, early exit avoids | 111 | /* Though tsk->delays accessed later, early exit avoids |
111 | * unnecessary returning of other data | 112 | * unnecessary returning of other data |
@@ -114,12 +115,14 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk) | |||
114 | goto done; | 115 | goto done; |
115 | 116 | ||
116 | tmp = (s64)d->cpu_run_real_total; | 117 | tmp = (s64)d->cpu_run_real_total; |
117 | cputime_to_timespec(tsk->utime + tsk->stime, &ts); | 118 | task_cputime(tsk, &utime, &stime); |
119 | cputime_to_timespec(utime + stime, &ts); | ||
118 | tmp += timespec_to_ns(&ts); | 120 | tmp += timespec_to_ns(&ts); |
119 | d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp; | 121 | d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp; |
120 | 122 | ||
121 | tmp = (s64)d->cpu_scaled_run_real_total; | 123 | tmp = (s64)d->cpu_scaled_run_real_total; |
122 | cputime_to_timespec(tsk->utimescaled + tsk->stimescaled, &ts); | 124 | task_cputime_scaled(tsk, &utimescaled, &stimescaled); |
125 | cputime_to_timespec(utimescaled + stimescaled, &ts); | ||
123 | tmp += timespec_to_ns(&ts); | 126 | tmp += timespec_to_ns(&ts); |
124 | d->cpu_scaled_run_real_total = | 127 | d->cpu_scaled_run_real_total = |
125 | (tmp < (s64)d->cpu_scaled_run_real_total) ? 0 : tmp; | 128 | (tmp < (s64)d->cpu_scaled_run_real_total) ? 0 : tmp; |
diff --git a/kernel/exit.c b/kernel/exit.c index b4df21937216..7dd20408707c 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -85,6 +85,7 @@ static void __exit_signal(struct task_struct *tsk) | |||
85 | bool group_dead = thread_group_leader(tsk); | 85 | bool group_dead = thread_group_leader(tsk); |
86 | struct sighand_struct *sighand; | 86 | struct sighand_struct *sighand; |
87 | struct tty_struct *uninitialized_var(tty); | 87 | struct tty_struct *uninitialized_var(tty); |
88 | cputime_t utime, stime; | ||
88 | 89 | ||
89 | sighand = rcu_dereference_check(tsk->sighand, | 90 | sighand = rcu_dereference_check(tsk->sighand, |
90 | lockdep_tasklist_lock_is_held()); | 91 | lockdep_tasklist_lock_is_held()); |
@@ -123,9 +124,10 @@ static void __exit_signal(struct task_struct *tsk) | |||
123 | * We won't ever get here for the group leader, since it | 124 | * We won't ever get here for the group leader, since it |
124 | * will have been the last reference on the signal_struct. | 125 | * will have been the last reference on the signal_struct. |
125 | */ | 126 | */ |
126 | sig->utime += tsk->utime; | 127 | task_cputime(tsk, &utime, &stime); |
127 | sig->stime += tsk->stime; | 128 | sig->utime += utime; |
128 | sig->gtime += tsk->gtime; | 129 | sig->stime += stime; |
130 | sig->gtime += task_gtime(tsk); | ||
129 | sig->min_flt += tsk->min_flt; | 131 | sig->min_flt += tsk->min_flt; |
130 | sig->maj_flt += tsk->maj_flt; | 132 | sig->maj_flt += tsk->maj_flt; |
131 | sig->nvcsw += tsk->nvcsw; | 133 | sig->nvcsw += tsk->nvcsw; |
@@ -1092,7 +1094,7 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) | |||
1092 | sig = p->signal; | 1094 | sig = p->signal; |
1093 | psig->cutime += tgutime + sig->cutime; | 1095 | psig->cutime += tgutime + sig->cutime; |
1094 | psig->cstime += tgstime + sig->cstime; | 1096 | psig->cstime += tgstime + sig->cstime; |
1095 | psig->cgtime += p->gtime + sig->gtime + sig->cgtime; | 1097 | psig->cgtime += task_gtime(p) + sig->gtime + sig->cgtime; |
1096 | psig->cmin_flt += | 1098 | psig->cmin_flt += |
1097 | p->min_flt + sig->min_flt + sig->cmin_flt; | 1099 | p->min_flt + sig->min_flt + sig->cmin_flt; |
1098 | psig->cmaj_flt += | 1100 | psig->cmaj_flt += |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index a278cad1d5d6..165d47698477 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -155,11 +155,19 @@ static void bump_cpu_timer(struct k_itimer *timer, | |||
155 | 155 | ||
156 | static inline cputime_t prof_ticks(struct task_struct *p) | 156 | static inline cputime_t prof_ticks(struct task_struct *p) |
157 | { | 157 | { |
158 | return p->utime + p->stime; | 158 | cputime_t utime, stime; |
159 | |||
160 | task_cputime(p, &utime, &stime); | ||
161 | |||
162 | return utime + stime; | ||
159 | } | 163 | } |
160 | static inline cputime_t virt_ticks(struct task_struct *p) | 164 | static inline cputime_t virt_ticks(struct task_struct *p) |
161 | { | 165 | { |
162 | return p->utime; | 166 | cputime_t utime; |
167 | |||
168 | task_cputime(p, &utime, NULL); | ||
169 | |||
170 | return utime; | ||
163 | } | 171 | } |
164 | 172 | ||
165 | static int | 173 | static int |
@@ -471,18 +479,23 @@ static void cleanup_timers(struct list_head *head, | |||
471 | */ | 479 | */ |
472 | void posix_cpu_timers_exit(struct task_struct *tsk) | 480 | void posix_cpu_timers_exit(struct task_struct *tsk) |
473 | { | 481 | { |
482 | cputime_t utime, stime; | ||
483 | |||
474 | add_device_randomness((const void*) &tsk->se.sum_exec_runtime, | 484 | add_device_randomness((const void*) &tsk->se.sum_exec_runtime, |
475 | sizeof(unsigned long long)); | 485 | sizeof(unsigned long long)); |
486 | task_cputime(tsk, &utime, &stime); | ||
476 | cleanup_timers(tsk->cpu_timers, | 487 | cleanup_timers(tsk->cpu_timers, |
477 | tsk->utime, tsk->stime, tsk->se.sum_exec_runtime); | 488 | utime, stime, tsk->se.sum_exec_runtime); |
478 | 489 | ||
479 | } | 490 | } |
480 | void posix_cpu_timers_exit_group(struct task_struct *tsk) | 491 | void posix_cpu_timers_exit_group(struct task_struct *tsk) |
481 | { | 492 | { |
482 | struct signal_struct *const sig = tsk->signal; | 493 | struct signal_struct *const sig = tsk->signal; |
494 | cputime_t utime, stime; | ||
483 | 495 | ||
496 | task_cputime(tsk, &utime, &stime); | ||
484 | cleanup_timers(tsk->signal->cpu_timers, | 497 | cleanup_timers(tsk->signal->cpu_timers, |
485 | tsk->utime + sig->utime, tsk->stime + sig->stime, | 498 | utime + sig->utime, stime + sig->stime, |
486 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); | 499 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); |
487 | } | 500 | } |
488 | 501 | ||
@@ -1226,11 +1239,14 @@ static inline int task_cputime_expired(const struct task_cputime *sample, | |||
1226 | static inline int fastpath_timer_check(struct task_struct *tsk) | 1239 | static inline int fastpath_timer_check(struct task_struct *tsk) |
1227 | { | 1240 | { |
1228 | struct signal_struct *sig; | 1241 | struct signal_struct *sig; |
1242 | cputime_t utime, stime; | ||
1243 | |||
1244 | task_cputime(tsk, &utime, &stime); | ||
1229 | 1245 | ||
1230 | if (!task_cputime_zero(&tsk->cputime_expires)) { | 1246 | if (!task_cputime_zero(&tsk->cputime_expires)) { |
1231 | struct task_cputime task_sample = { | 1247 | struct task_cputime task_sample = { |
1232 | .utime = tsk->utime, | 1248 | .utime = utime, |
1233 | .stime = tsk->stime, | 1249 | .stime = stime, |
1234 | .sum_exec_runtime = tsk->se.sum_exec_runtime | 1250 | .sum_exec_runtime = tsk->se.sum_exec_runtime |
1235 | }; | 1251 | }; |
1236 | 1252 | ||
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index e1939d38bf73..c533deaf06d5 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c | |||
@@ -164,7 +164,7 @@ void account_user_time(struct task_struct *p, cputime_t cputime, | |||
164 | task_group_account_field(p, index, (__force u64) cputime); | 164 | task_group_account_field(p, index, (__force u64) cputime); |
165 | 165 | ||
166 | /* Account for user time used */ | 166 | /* Account for user time used */ |
167 | acct_update_integrals(p); | 167 | acct_account_cputime(p); |
168 | } | 168 | } |
169 | 169 | ||
170 | /* | 170 | /* |
@@ -214,7 +214,7 @@ void __account_system_time(struct task_struct *p, cputime_t cputime, | |||
214 | task_group_account_field(p, index, (__force u64) cputime); | 214 | task_group_account_field(p, index, (__force u64) cputime); |
215 | 215 | ||
216 | /* Account for system time used */ | 216 | /* Account for system time used */ |
217 | acct_update_integrals(p); | 217 | acct_account_cputime(p); |
218 | } | 218 | } |
219 | 219 | ||
220 | /* | 220 | /* |
@@ -296,6 +296,7 @@ static __always_inline bool steal_account_process_tick(void) | |||
296 | void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) | 296 | void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) |
297 | { | 297 | { |
298 | struct signal_struct *sig = tsk->signal; | 298 | struct signal_struct *sig = tsk->signal; |
299 | cputime_t utime, stime; | ||
299 | struct task_struct *t; | 300 | struct task_struct *t; |
300 | 301 | ||
301 | times->utime = sig->utime; | 302 | times->utime = sig->utime; |
@@ -309,8 +310,9 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) | |||
309 | 310 | ||
310 | t = tsk; | 311 | t = tsk; |
311 | do { | 312 | do { |
312 | times->utime += t->utime; | 313 | task_cputime(tsk, &utime, &stime); |
313 | times->stime += t->stime; | 314 | times->utime += utime; |
315 | times->stime += stime; | ||
314 | times->sum_exec_runtime += task_sched_runtime(t); | 316 | times->sum_exec_runtime += task_sched_runtime(t); |
315 | } while_each_thread(tsk, t); | 317 | } while_each_thread(tsk, t); |
316 | out: | 318 | out: |
@@ -588,11 +590,10 @@ static void cputime_adjust(struct task_cputime *curr, | |||
588 | void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st) | 590 | void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st) |
589 | { | 591 | { |
590 | struct task_cputime cputime = { | 592 | struct task_cputime cputime = { |
591 | .utime = p->utime, | ||
592 | .stime = p->stime, | ||
593 | .sum_exec_runtime = p->se.sum_exec_runtime, | 593 | .sum_exec_runtime = p->se.sum_exec_runtime, |
594 | }; | 594 | }; |
595 | 595 | ||
596 | task_cputime(p, &cputime.utime, &cputime.stime); | ||
596 | cputime_adjust(&cputime, &p->prev_cputime, ut, st); | 597 | cputime_adjust(&cputime, &p->prev_cputime, ut, st); |
597 | } | 598 | } |
598 | 599 | ||
diff --git a/kernel/signal.c b/kernel/signal.c index 372771e948c2..776a45a3661b 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -1638,6 +1638,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig) | |||
1638 | unsigned long flags; | 1638 | unsigned long flags; |
1639 | struct sighand_struct *psig; | 1639 | struct sighand_struct *psig; |
1640 | bool autoreap = false; | 1640 | bool autoreap = false; |
1641 | cputime_t utime, stime; | ||
1641 | 1642 | ||
1642 | BUG_ON(sig == -1); | 1643 | BUG_ON(sig == -1); |
1643 | 1644 | ||
@@ -1675,8 +1676,9 @@ bool do_notify_parent(struct task_struct *tsk, int sig) | |||
1675 | task_uid(tsk)); | 1676 | task_uid(tsk)); |
1676 | rcu_read_unlock(); | 1677 | rcu_read_unlock(); |
1677 | 1678 | ||
1678 | info.si_utime = cputime_to_clock_t(tsk->utime + tsk->signal->utime); | 1679 | task_cputime(tsk, &utime, &stime); |
1679 | info.si_stime = cputime_to_clock_t(tsk->stime + tsk->signal->stime); | 1680 | info.si_utime = cputime_to_clock_t(utime + tsk->signal->utime); |
1681 | info.si_stime = cputime_to_clock_t(stime + tsk->signal->stime); | ||
1680 | 1682 | ||
1681 | info.si_status = tsk->exit_code & 0x7f; | 1683 | info.si_status = tsk->exit_code & 0x7f; |
1682 | if (tsk->exit_code & 0x80) | 1684 | if (tsk->exit_code & 0x80) |
@@ -1740,6 +1742,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, | |||
1740 | unsigned long flags; | 1742 | unsigned long flags; |
1741 | struct task_struct *parent; | 1743 | struct task_struct *parent; |
1742 | struct sighand_struct *sighand; | 1744 | struct sighand_struct *sighand; |
1745 | cputime_t utime, stime; | ||
1743 | 1746 | ||
1744 | if (for_ptracer) { | 1747 | if (for_ptracer) { |
1745 | parent = tsk->parent; | 1748 | parent = tsk->parent; |
@@ -1758,8 +1761,9 @@ static void do_notify_parent_cldstop(struct task_struct *tsk, | |||
1758 | info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk)); | 1761 | info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk)); |
1759 | rcu_read_unlock(); | 1762 | rcu_read_unlock(); |
1760 | 1763 | ||
1761 | info.si_utime = cputime_to_clock_t(tsk->utime); | 1764 | task_cputime(tsk, &utime, &stime); |
1762 | info.si_stime = cputime_to_clock_t(tsk->stime); | 1765 | info.si_utime = cputime_to_clock_t(utime); |
1766 | info.si_stime = cputime_to_clock_t(stime); | ||
1763 | 1767 | ||
1764 | info.si_code = why; | 1768 | info.si_code = why; |
1765 | switch (why) { | 1769 | switch (why) { |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 625df0b44690..a1dd9a1b1327 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -32,6 +32,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, | |||
32 | { | 32 | { |
33 | const struct cred *tcred; | 33 | const struct cred *tcred; |
34 | struct timespec uptime, ts; | 34 | struct timespec uptime, ts; |
35 | cputime_t utime, stime, utimescaled, stimescaled; | ||
35 | u64 ac_etime; | 36 | u64 ac_etime; |
36 | 37 | ||
37 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); | 38 | BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); |
@@ -65,10 +66,15 @@ void bacct_add_tsk(struct user_namespace *user_ns, | |||
65 | stats->ac_ppid = pid_alive(tsk) ? | 66 | stats->ac_ppid = pid_alive(tsk) ? |
66 | task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0; | 67 | task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0; |
67 | rcu_read_unlock(); | 68 | rcu_read_unlock(); |
68 | stats->ac_utime = cputime_to_usecs(tsk->utime); | 69 | |
69 | stats->ac_stime = cputime_to_usecs(tsk->stime); | 70 | task_cputime(tsk, &utime, &stime); |
70 | stats->ac_utimescaled = cputime_to_usecs(tsk->utimescaled); | 71 | stats->ac_utime = cputime_to_usecs(utime); |
71 | stats->ac_stimescaled = cputime_to_usecs(tsk->stimescaled); | 72 | stats->ac_stime = cputime_to_usecs(stime); |
73 | |||
74 | task_cputime_scaled(tsk, &utimescaled, &stimescaled); | ||
75 | stats->ac_utimescaled = cputime_to_usecs(utimescaled); | ||
76 | stats->ac_stimescaled = cputime_to_usecs(stimescaled); | ||
77 | |||
72 | stats->ac_minflt = tsk->min_flt; | 78 | stats->ac_minflt = tsk->min_flt; |
73 | stats->ac_majflt = tsk->maj_flt; | 79 | stats->ac_majflt = tsk->maj_flt; |
74 | 80 | ||
@@ -115,11 +121,8 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) | |||
115 | #undef KB | 121 | #undef KB |
116 | #undef MB | 122 | #undef MB |
117 | 123 | ||
118 | /** | 124 | static void __acct_update_integrals(struct task_struct *tsk, |
119 | * acct_update_integrals - update mm integral fields in task_struct | 125 | cputime_t utime, cputime_t stime) |
120 | * @tsk: task_struct for accounting | ||
121 | */ | ||
122 | void acct_update_integrals(struct task_struct *tsk) | ||
123 | { | 126 | { |
124 | if (likely(tsk->mm)) { | 127 | if (likely(tsk->mm)) { |
125 | cputime_t time, dtime; | 128 | cputime_t time, dtime; |
@@ -128,7 +131,7 @@ void acct_update_integrals(struct task_struct *tsk) | |||
128 | u64 delta; | 131 | u64 delta; |
129 | 132 | ||
130 | local_irq_save(flags); | 133 | local_irq_save(flags); |
131 | time = tsk->stime + tsk->utime; | 134 | time = stime + utime; |
132 | dtime = time - tsk->acct_timexpd; | 135 | dtime = time - tsk->acct_timexpd; |
133 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); | 136 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); |
134 | delta = value.tv_sec; | 137 | delta = value.tv_sec; |
@@ -145,6 +148,27 @@ void acct_update_integrals(struct task_struct *tsk) | |||
145 | } | 148 | } |
146 | 149 | ||
147 | /** | 150 | /** |
151 | * acct_update_integrals - update mm integral fields in task_struct | ||
152 | * @tsk: task_struct for accounting | ||
153 | */ | ||
154 | void acct_update_integrals(struct task_struct *tsk) | ||
155 | { | ||
156 | cputime_t utime, stime; | ||
157 | |||
158 | task_cputime(tsk, &utime, &stime); | ||
159 | __acct_update_integrals(tsk, utime, stime); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * acct_account_cputime - update mm integral after cputime update | ||
164 | * @tsk: task_struct for accounting | ||
165 | */ | ||
166 | void acct_account_cputime(struct task_struct *tsk) | ||
167 | { | ||
168 | __acct_update_integrals(tsk, tsk->utime, tsk->stime); | ||
169 | } | ||
170 | |||
171 | /** | ||
148 | * acct_clear_integrals - clear the mm integral fields in task_struct | 172 | * acct_clear_integrals - clear the mm integral fields in task_struct |
149 | * @tsk: task_struct whose accounting fields are cleared | 173 | * @tsk: task_struct whose accounting fields are cleared |
150 | */ | 174 | */ |