diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-12-15 08:56:09 -0500 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2011-12-15 08:56:19 -0500 |
commit | 648616343cdbe904c585a6c12e323d3b3c72e46f (patch) | |
tree | 514bce1b52663db4ab5662b637c764cf3c2ed1eb /kernel | |
parent | 55b02d2f4445ad625213817a1736bf2884d32547 (diff) |
[S390] cputime: add sparse checking and cleanup
Make cputime_t and cputime64_t nocast to enable sparse checking to
detect incorrect use of cputime. Drop the cputime macros for simple
scalar operations. The conversion macros are still needed.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/acct.c | 4 | ||||
-rw-r--r-- | kernel/cpu.c | 3 | ||||
-rw-r--r-- | kernel/exit.c | 22 | ||||
-rw-r--r-- | kernel/fork.c | 14 | ||||
-rw-r--r-- | kernel/itimer.c | 15 | ||||
-rw-r--r-- | kernel/posix-cpu-timers.c | 132 | ||||
-rw-r--r-- | kernel/sched.c | 80 | ||||
-rw-r--r-- | kernel/sched_stats.h | 6 | ||||
-rw-r--r-- | kernel/signal.c | 6 | ||||
-rw-r--r-- | kernel/sys.c | 6 | ||||
-rw-r--r-- | kernel/tsacct.c | 2 |
11 files changed, 116 insertions, 174 deletions
diff --git a/kernel/acct.c b/kernel/acct.c index fa7eb3de2ddc..203dfead2e06 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -613,8 +613,8 @@ void acct_collect(long exitcode, int group_dead) | |||
613 | pacct->ac_flag |= ACORE; | 613 | pacct->ac_flag |= ACORE; |
614 | if (current->flags & PF_SIGNALED) | 614 | if (current->flags & PF_SIGNALED) |
615 | pacct->ac_flag |= AXSIG; | 615 | pacct->ac_flag |= AXSIG; |
616 | pacct->ac_utime = cputime_add(pacct->ac_utime, current->utime); | 616 | pacct->ac_utime += current->utime; |
617 | pacct->ac_stime = cputime_add(pacct->ac_stime, current->stime); | 617 | pacct->ac_stime += current->stime; |
618 | pacct->ac_minflt += current->min_flt; | 618 | pacct->ac_minflt += current->min_flt; |
619 | pacct->ac_majflt += current->maj_flt; | 619 | pacct->ac_majflt += current->maj_flt; |
620 | spin_unlock_irq(¤t->sighand->siglock); | 620 | spin_unlock_irq(¤t->sighand->siglock); |
diff --git a/kernel/cpu.c b/kernel/cpu.c index 563f13609470..3f8ee8a138c4 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -178,8 +178,7 @@ static inline void check_for_tasks(int cpu) | |||
178 | write_lock_irq(&tasklist_lock); | 178 | write_lock_irq(&tasklist_lock); |
179 | for_each_process(p) { | 179 | for_each_process(p) { |
180 | if (task_cpu(p) == cpu && p->state == TASK_RUNNING && | 180 | if (task_cpu(p) == cpu && p->state == TASK_RUNNING && |
181 | (!cputime_eq(p->utime, cputime_zero) || | 181 | (p->utime || p->stime)) |
182 | !cputime_eq(p->stime, cputime_zero))) | ||
183 | printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " | 182 | printk(KERN_WARNING "Task %s (pid = %d) is on cpu %d " |
184 | "(state = %ld, flags = %x)\n", | 183 | "(state = %ld, flags = %x)\n", |
185 | p->comm, task_pid_nr(p), cpu, | 184 | p->comm, task_pid_nr(p), cpu, |
diff --git a/kernel/exit.c b/kernel/exit.c index d0b7d988f873..5e0d1f4c696e 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -121,9 +121,9 @@ static void __exit_signal(struct task_struct *tsk) | |||
121 | * We won't ever get here for the group leader, since it | 121 | * We won't ever get here for the group leader, since it |
122 | * will have been the last reference on the signal_struct. | 122 | * will have been the last reference on the signal_struct. |
123 | */ | 123 | */ |
124 | sig->utime = cputime_add(sig->utime, tsk->utime); | 124 | sig->utime += tsk->utime; |
125 | sig->stime = cputime_add(sig->stime, tsk->stime); | 125 | sig->stime += tsk->stime; |
126 | sig->gtime = cputime_add(sig->gtime, tsk->gtime); | 126 | sig->gtime += tsk->gtime; |
127 | sig->min_flt += tsk->min_flt; | 127 | sig->min_flt += tsk->min_flt; |
128 | sig->maj_flt += tsk->maj_flt; | 128 | sig->maj_flt += tsk->maj_flt; |
129 | sig->nvcsw += tsk->nvcsw; | 129 | sig->nvcsw += tsk->nvcsw; |
@@ -1255,19 +1255,9 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) | |||
1255 | spin_lock_irq(&p->real_parent->sighand->siglock); | 1255 | spin_lock_irq(&p->real_parent->sighand->siglock); |
1256 | psig = p->real_parent->signal; | 1256 | psig = p->real_parent->signal; |
1257 | sig = p->signal; | 1257 | sig = p->signal; |
1258 | psig->cutime = | 1258 | psig->cutime += tgutime + sig->cutime; |
1259 | cputime_add(psig->cutime, | 1259 | psig->cstime += tgstime + sig->cstime; |
1260 | cputime_add(tgutime, | 1260 | psig->cgtime += p->gtime + sig->gtime + sig->cgtime; |
1261 | sig->cutime)); | ||
1262 | psig->cstime = | ||
1263 | cputime_add(psig->cstime, | ||
1264 | cputime_add(tgstime, | ||
1265 | sig->cstime)); | ||
1266 | psig->cgtime = | ||
1267 | cputime_add(psig->cgtime, | ||
1268 | cputime_add(p->gtime, | ||
1269 | cputime_add(sig->gtime, | ||
1270 | sig->cgtime))); | ||
1271 | psig->cmin_flt += | 1261 | psig->cmin_flt += |
1272 | p->min_flt + sig->min_flt + sig->cmin_flt; | 1262 | p->min_flt + sig->min_flt + sig->cmin_flt; |
1273 | psig->cmaj_flt += | 1263 | psig->cmaj_flt += |
diff --git a/kernel/fork.c b/kernel/fork.c index da4a6a10d088..b058c5820ecd 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -1023,8 +1023,8 @@ void mm_init_owner(struct mm_struct *mm, struct task_struct *p) | |||
1023 | */ | 1023 | */ |
1024 | static void posix_cpu_timers_init(struct task_struct *tsk) | 1024 | static void posix_cpu_timers_init(struct task_struct *tsk) |
1025 | { | 1025 | { |
1026 | tsk->cputime_expires.prof_exp = cputime_zero; | 1026 | tsk->cputime_expires.prof_exp = 0; |
1027 | tsk->cputime_expires.virt_exp = cputime_zero; | 1027 | tsk->cputime_expires.virt_exp = 0; |
1028 | tsk->cputime_expires.sched_exp = 0; | 1028 | tsk->cputime_expires.sched_exp = 0; |
1029 | INIT_LIST_HEAD(&tsk->cpu_timers[0]); | 1029 | INIT_LIST_HEAD(&tsk->cpu_timers[0]); |
1030 | INIT_LIST_HEAD(&tsk->cpu_timers[1]); | 1030 | INIT_LIST_HEAD(&tsk->cpu_timers[1]); |
@@ -1132,14 +1132,10 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
1132 | 1132 | ||
1133 | init_sigpending(&p->pending); | 1133 | init_sigpending(&p->pending); |
1134 | 1134 | ||
1135 | p->utime = cputime_zero; | 1135 | p->utime = p->stime = p->gtime = 0; |
1136 | p->stime = cputime_zero; | 1136 | p->utimescaled = p->stimescaled = 0; |
1137 | p->gtime = cputime_zero; | ||
1138 | p->utimescaled = cputime_zero; | ||
1139 | p->stimescaled = cputime_zero; | ||
1140 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | 1137 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING |
1141 | p->prev_utime = cputime_zero; | 1138 | p->prev_utime = p->prev_stime = 0; |
1142 | p->prev_stime = cputime_zero; | ||
1143 | #endif | 1139 | #endif |
1144 | #if defined(SPLIT_RSS_COUNTING) | 1140 | #if defined(SPLIT_RSS_COUNTING) |
1145 | memset(&p->rss_stat, 0, sizeof(p->rss_stat)); | 1141 | memset(&p->rss_stat, 0, sizeof(p->rss_stat)); |
diff --git a/kernel/itimer.c b/kernel/itimer.c index d802883153da..22000c3db0dd 100644 --- a/kernel/itimer.c +++ b/kernel/itimer.c | |||
@@ -52,22 +52,22 @@ static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, | |||
52 | 52 | ||
53 | cval = it->expires; | 53 | cval = it->expires; |
54 | cinterval = it->incr; | 54 | cinterval = it->incr; |
55 | if (!cputime_eq(cval, cputime_zero)) { | 55 | if (cval) { |
56 | struct task_cputime cputime; | 56 | struct task_cputime cputime; |
57 | cputime_t t; | 57 | cputime_t t; |
58 | 58 | ||
59 | thread_group_cputimer(tsk, &cputime); | 59 | thread_group_cputimer(tsk, &cputime); |
60 | if (clock_id == CPUCLOCK_PROF) | 60 | if (clock_id == CPUCLOCK_PROF) |
61 | t = cputime_add(cputime.utime, cputime.stime); | 61 | t = cputime.utime + cputime.stime; |
62 | else | 62 | else |
63 | /* CPUCLOCK_VIRT */ | 63 | /* CPUCLOCK_VIRT */ |
64 | t = cputime.utime; | 64 | t = cputime.utime; |
65 | 65 | ||
66 | if (cputime_le(cval, t)) | 66 | if (cval < t) |
67 | /* about to fire */ | 67 | /* about to fire */ |
68 | cval = cputime_one_jiffy; | 68 | cval = cputime_one_jiffy; |
69 | else | 69 | else |
70 | cval = cputime_sub(cval, t); | 70 | cval = cval - t; |
71 | } | 71 | } |
72 | 72 | ||
73 | spin_unlock_irq(&tsk->sighand->siglock); | 73 | spin_unlock_irq(&tsk->sighand->siglock); |
@@ -161,10 +161,9 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id, | |||
161 | 161 | ||
162 | cval = it->expires; | 162 | cval = it->expires; |
163 | cinterval = it->incr; | 163 | cinterval = it->incr; |
164 | if (!cputime_eq(cval, cputime_zero) || | 164 | if (cval || nval) { |
165 | !cputime_eq(nval, cputime_zero)) { | 165 | if (nval > 0) |
166 | if (cputime_gt(nval, cputime_zero)) | 166 | nval += cputime_one_jiffy; |
167 | nval = cputime_add(nval, cputime_one_jiffy); | ||
168 | set_process_cpu_timer(tsk, clock_id, &nval, &cval); | 167 | set_process_cpu_timer(tsk, clock_id, &nval, &cval); |
169 | } | 168 | } |
170 | it->expires = nval; | 169 | it->expires = nval; |
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index e7cb76dc18f5..125cb67daa21 100644 --- a/kernel/posix-cpu-timers.c +++ b/kernel/posix-cpu-timers.c | |||
@@ -78,7 +78,7 @@ static inline int cpu_time_before(const clockid_t which_clock, | |||
78 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { | 78 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { |
79 | return now.sched < then.sched; | 79 | return now.sched < then.sched; |
80 | } else { | 80 | } else { |
81 | return cputime_lt(now.cpu, then.cpu); | 81 | return now.cpu < then.cpu; |
82 | } | 82 | } |
83 | } | 83 | } |
84 | static inline void cpu_time_add(const clockid_t which_clock, | 84 | static inline void cpu_time_add(const clockid_t which_clock, |
@@ -88,7 +88,7 @@ static inline void cpu_time_add(const clockid_t which_clock, | |||
88 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { | 88 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { |
89 | acc->sched += val.sched; | 89 | acc->sched += val.sched; |
90 | } else { | 90 | } else { |
91 | acc->cpu = cputime_add(acc->cpu, val.cpu); | 91 | acc->cpu += val.cpu; |
92 | } | 92 | } |
93 | } | 93 | } |
94 | static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock, | 94 | static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock, |
@@ -98,25 +98,12 @@ static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock, | |||
98 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { | 98 | if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) { |
99 | a.sched -= b.sched; | 99 | a.sched -= b.sched; |
100 | } else { | 100 | } else { |
101 | a.cpu = cputime_sub(a.cpu, b.cpu); | 101 | a.cpu -= b.cpu; |
102 | } | 102 | } |
103 | return a; | 103 | return a; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | * Divide and limit the result to res >= 1 | ||
108 | * | ||
109 | * This is necessary to prevent signal delivery starvation, when the result of | ||
110 | * the division would be rounded down to 0. | ||
111 | */ | ||
112 | static inline cputime_t cputime_div_non_zero(cputime_t time, unsigned long div) | ||
113 | { | ||
114 | cputime_t res = cputime_div(time, div); | ||
115 | |||
116 | return max_t(cputime_t, res, 1); | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Update expiry time from increment, and increase overrun count, | 107 | * Update expiry time from increment, and increase overrun count, |
121 | * given the current clock sample. | 108 | * given the current clock sample. |
122 | */ | 109 | */ |
@@ -148,28 +135,26 @@ static void bump_cpu_timer(struct k_itimer *timer, | |||
148 | } else { | 135 | } else { |
149 | cputime_t delta, incr; | 136 | cputime_t delta, incr; |
150 | 137 | ||
151 | if (cputime_lt(now.cpu, timer->it.cpu.expires.cpu)) | 138 | if (now.cpu < timer->it.cpu.expires.cpu) |
152 | return; | 139 | return; |
153 | incr = timer->it.cpu.incr.cpu; | 140 | incr = timer->it.cpu.incr.cpu; |
154 | delta = cputime_sub(cputime_add(now.cpu, incr), | 141 | delta = now.cpu + incr - timer->it.cpu.expires.cpu; |
155 | timer->it.cpu.expires.cpu); | ||
156 | /* Don't use (incr*2 < delta), incr*2 might overflow. */ | 142 | /* Don't use (incr*2 < delta), incr*2 might overflow. */ |
157 | for (i = 0; cputime_lt(incr, cputime_sub(delta, incr)); i++) | 143 | for (i = 0; incr < delta - incr; i++) |
158 | incr = cputime_add(incr, incr); | 144 | incr += incr; |
159 | for (; i >= 0; incr = cputime_halve(incr), i--) { | 145 | for (; i >= 0; incr = incr >> 1, i--) { |
160 | if (cputime_lt(delta, incr)) | 146 | if (delta < incr) |
161 | continue; | 147 | continue; |
162 | timer->it.cpu.expires.cpu = | 148 | timer->it.cpu.expires.cpu += incr; |
163 | cputime_add(timer->it.cpu.expires.cpu, incr); | ||
164 | timer->it_overrun += 1 << i; | 149 | timer->it_overrun += 1 << i; |
165 | delta = cputime_sub(delta, incr); | 150 | delta -= incr; |
166 | } | 151 | } |
167 | } | 152 | } |
168 | } | 153 | } |
169 | 154 | ||
170 | static inline cputime_t prof_ticks(struct task_struct *p) | 155 | static inline cputime_t prof_ticks(struct task_struct *p) |
171 | { | 156 | { |
172 | return cputime_add(p->utime, p->stime); | 157 | return p->utime + p->stime; |
173 | } | 158 | } |
174 | static inline cputime_t virt_ticks(struct task_struct *p) | 159 | static inline cputime_t virt_ticks(struct task_struct *p) |
175 | { | 160 | { |
@@ -248,8 +233,8 @@ void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times) | |||
248 | 233 | ||
249 | t = tsk; | 234 | t = tsk; |
250 | do { | 235 | do { |
251 | times->utime = cputime_add(times->utime, t->utime); | 236 | times->utime += t->utime; |
252 | times->stime = cputime_add(times->stime, t->stime); | 237 | times->stime += t->stime; |
253 | times->sum_exec_runtime += task_sched_runtime(t); | 238 | times->sum_exec_runtime += task_sched_runtime(t); |
254 | } while_each_thread(tsk, t); | 239 | } while_each_thread(tsk, t); |
255 | out: | 240 | out: |
@@ -258,10 +243,10 @@ out: | |||
258 | 243 | ||
259 | static void update_gt_cputime(struct task_cputime *a, struct task_cputime *b) | 244 | static void update_gt_cputime(struct task_cputime *a, struct task_cputime *b) |
260 | { | 245 | { |
261 | if (cputime_gt(b->utime, a->utime)) | 246 | if (b->utime > a->utime) |
262 | a->utime = b->utime; | 247 | a->utime = b->utime; |
263 | 248 | ||
264 | if (cputime_gt(b->stime, a->stime)) | 249 | if (b->stime > a->stime) |
265 | a->stime = b->stime; | 250 | a->stime = b->stime; |
266 | 251 | ||
267 | if (b->sum_exec_runtime > a->sum_exec_runtime) | 252 | if (b->sum_exec_runtime > a->sum_exec_runtime) |
@@ -306,7 +291,7 @@ static int cpu_clock_sample_group(const clockid_t which_clock, | |||
306 | return -EINVAL; | 291 | return -EINVAL; |
307 | case CPUCLOCK_PROF: | 292 | case CPUCLOCK_PROF: |
308 | thread_group_cputime(p, &cputime); | 293 | thread_group_cputime(p, &cputime); |
309 | cpu->cpu = cputime_add(cputime.utime, cputime.stime); | 294 | cpu->cpu = cputime.utime + cputime.stime; |
310 | break; | 295 | break; |
311 | case CPUCLOCK_VIRT: | 296 | case CPUCLOCK_VIRT: |
312 | thread_group_cputime(p, &cputime); | 297 | thread_group_cputime(p, &cputime); |
@@ -470,26 +455,24 @@ static void cleanup_timers(struct list_head *head, | |||
470 | unsigned long long sum_exec_runtime) | 455 | unsigned long long sum_exec_runtime) |
471 | { | 456 | { |
472 | struct cpu_timer_list *timer, *next; | 457 | struct cpu_timer_list *timer, *next; |
473 | cputime_t ptime = cputime_add(utime, stime); | 458 | cputime_t ptime = utime + stime; |
474 | 459 | ||
475 | list_for_each_entry_safe(timer, next, head, entry) { | 460 | list_for_each_entry_safe(timer, next, head, entry) { |
476 | list_del_init(&timer->entry); | 461 | list_del_init(&timer->entry); |
477 | if (cputime_lt(timer->expires.cpu, ptime)) { | 462 | if (timer->expires.cpu < ptime) { |
478 | timer->expires.cpu = cputime_zero; | 463 | timer->expires.cpu = 0; |
479 | } else { | 464 | } else { |
480 | timer->expires.cpu = cputime_sub(timer->expires.cpu, | 465 | timer->expires.cpu -= ptime; |
481 | ptime); | ||
482 | } | 466 | } |
483 | } | 467 | } |
484 | 468 | ||
485 | ++head; | 469 | ++head; |
486 | list_for_each_entry_safe(timer, next, head, entry) { | 470 | list_for_each_entry_safe(timer, next, head, entry) { |
487 | list_del_init(&timer->entry); | 471 | list_del_init(&timer->entry); |
488 | if (cputime_lt(timer->expires.cpu, utime)) { | 472 | if (timer->expires.cpu < utime) { |
489 | timer->expires.cpu = cputime_zero; | 473 | timer->expires.cpu = 0; |
490 | } else { | 474 | } else { |
491 | timer->expires.cpu = cputime_sub(timer->expires.cpu, | 475 | timer->expires.cpu -= utime; |
492 | utime); | ||
493 | } | 476 | } |
494 | } | 477 | } |
495 | 478 | ||
@@ -520,8 +503,7 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk) | |||
520 | struct signal_struct *const sig = tsk->signal; | 503 | struct signal_struct *const sig = tsk->signal; |
521 | 504 | ||
522 | cleanup_timers(tsk->signal->cpu_timers, | 505 | cleanup_timers(tsk->signal->cpu_timers, |
523 | cputime_add(tsk->utime, sig->utime), | 506 | tsk->utime + sig->utime, tsk->stime + sig->stime, |
524 | cputime_add(tsk->stime, sig->stime), | ||
525 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); | 507 | tsk->se.sum_exec_runtime + sig->sum_sched_runtime); |
526 | } | 508 | } |
527 | 509 | ||
@@ -540,8 +522,7 @@ static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) | |||
540 | 522 | ||
541 | static inline int expires_gt(cputime_t expires, cputime_t new_exp) | 523 | static inline int expires_gt(cputime_t expires, cputime_t new_exp) |
542 | { | 524 | { |
543 | return cputime_eq(expires, cputime_zero) || | 525 | return expires == 0 || expires > new_exp; |
544 | cputime_gt(expires, new_exp); | ||
545 | } | 526 | } |
546 | 527 | ||
547 | /* | 528 | /* |
@@ -651,7 +632,7 @@ static int cpu_timer_sample_group(const clockid_t which_clock, | |||
651 | default: | 632 | default: |
652 | return -EINVAL; | 633 | return -EINVAL; |
653 | case CPUCLOCK_PROF: | 634 | case CPUCLOCK_PROF: |
654 | cpu->cpu = cputime_add(cputime.utime, cputime.stime); | 635 | cpu->cpu = cputime.utime + cputime.stime; |
655 | break; | 636 | break; |
656 | case CPUCLOCK_VIRT: | 637 | case CPUCLOCK_VIRT: |
657 | cpu->cpu = cputime.utime; | 638 | cpu->cpu = cputime.utime; |
@@ -918,12 +899,12 @@ static void check_thread_timers(struct task_struct *tsk, | |||
918 | unsigned long soft; | 899 | unsigned long soft; |
919 | 900 | ||
920 | maxfire = 20; | 901 | maxfire = 20; |
921 | tsk->cputime_expires.prof_exp = cputime_zero; | 902 | tsk->cputime_expires.prof_exp = 0; |
922 | while (!list_empty(timers)) { | 903 | while (!list_empty(timers)) { |
923 | struct cpu_timer_list *t = list_first_entry(timers, | 904 | struct cpu_timer_list *t = list_first_entry(timers, |
924 | struct cpu_timer_list, | 905 | struct cpu_timer_list, |
925 | entry); | 906 | entry); |
926 | if (!--maxfire || cputime_lt(prof_ticks(tsk), t->expires.cpu)) { | 907 | if (!--maxfire || prof_ticks(tsk) < t->expires.cpu) { |
927 | tsk->cputime_expires.prof_exp = t->expires.cpu; | 908 | tsk->cputime_expires.prof_exp = t->expires.cpu; |
928 | break; | 909 | break; |
929 | } | 910 | } |
@@ -933,12 +914,12 @@ static void check_thread_timers(struct task_struct *tsk, | |||
933 | 914 | ||
934 | ++timers; | 915 | ++timers; |
935 | maxfire = 20; | 916 | maxfire = 20; |
936 | tsk->cputime_expires.virt_exp = cputime_zero; | 917 | tsk->cputime_expires.virt_exp = 0; |
937 | while (!list_empty(timers)) { | 918 | while (!list_empty(timers)) { |
938 | struct cpu_timer_list *t = list_first_entry(timers, | 919 | struct cpu_timer_list *t = list_first_entry(timers, |
939 | struct cpu_timer_list, | 920 | struct cpu_timer_list, |
940 | entry); | 921 | entry); |
941 | if (!--maxfire || cputime_lt(virt_ticks(tsk), t->expires.cpu)) { | 922 | if (!--maxfire || virt_ticks(tsk) < t->expires.cpu) { |
942 | tsk->cputime_expires.virt_exp = t->expires.cpu; | 923 | tsk->cputime_expires.virt_exp = t->expires.cpu; |
943 | break; | 924 | break; |
944 | } | 925 | } |
@@ -1009,20 +990,19 @@ static u32 onecputick; | |||
1009 | static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it, | 990 | static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it, |
1010 | cputime_t *expires, cputime_t cur_time, int signo) | 991 | cputime_t *expires, cputime_t cur_time, int signo) |
1011 | { | 992 | { |
1012 | if (cputime_eq(it->expires, cputime_zero)) | 993 | if (!it->expires) |
1013 | return; | 994 | return; |
1014 | 995 | ||
1015 | if (cputime_ge(cur_time, it->expires)) { | 996 | if (cur_time >= it->expires) { |
1016 | if (!cputime_eq(it->incr, cputime_zero)) { | 997 | if (it->incr) { |
1017 | it->expires = cputime_add(it->expires, it->incr); | 998 | it->expires += it->incr; |
1018 | it->error += it->incr_error; | 999 | it->error += it->incr_error; |
1019 | if (it->error >= onecputick) { | 1000 | if (it->error >= onecputick) { |
1020 | it->expires = cputime_sub(it->expires, | 1001 | it->expires -= cputime_one_jiffy; |
1021 | cputime_one_jiffy); | ||
1022 | it->error -= onecputick; | 1002 | it->error -= onecputick; |
1023 | } | 1003 | } |
1024 | } else { | 1004 | } else { |
1025 | it->expires = cputime_zero; | 1005 | it->expires = 0; |
1026 | } | 1006 | } |
1027 | 1007 | ||
1028 | trace_itimer_expire(signo == SIGPROF ? | 1008 | trace_itimer_expire(signo == SIGPROF ? |
@@ -1031,9 +1011,7 @@ static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it, | |||
1031 | __group_send_sig_info(signo, SEND_SIG_PRIV, tsk); | 1011 | __group_send_sig_info(signo, SEND_SIG_PRIV, tsk); |
1032 | } | 1012 | } |
1033 | 1013 | ||
1034 | if (!cputime_eq(it->expires, cputime_zero) && | 1014 | if (it->expires && (!*expires || it->expires < *expires)) { |
1035 | (cputime_eq(*expires, cputime_zero) || | ||
1036 | cputime_lt(it->expires, *expires))) { | ||
1037 | *expires = it->expires; | 1015 | *expires = it->expires; |
1038 | } | 1016 | } |
1039 | } | 1017 | } |
@@ -1048,9 +1026,7 @@ static void check_cpu_itimer(struct task_struct *tsk, struct cpu_itimer *it, | |||
1048 | */ | 1026 | */ |
1049 | static inline int task_cputime_zero(const struct task_cputime *cputime) | 1027 | static inline int task_cputime_zero(const struct task_cputime *cputime) |
1050 | { | 1028 | { |
1051 | if (cputime_eq(cputime->utime, cputime_zero) && | 1029 | if (!cputime->utime && !cputime->stime && !cputime->sum_exec_runtime) |
1052 | cputime_eq(cputime->stime, cputime_zero) && | ||
1053 | cputime->sum_exec_runtime == 0) | ||
1054 | return 1; | 1030 | return 1; |
1055 | return 0; | 1031 | return 0; |
1056 | } | 1032 | } |
@@ -1076,15 +1052,15 @@ static void check_process_timers(struct task_struct *tsk, | |||
1076 | */ | 1052 | */ |
1077 | thread_group_cputimer(tsk, &cputime); | 1053 | thread_group_cputimer(tsk, &cputime); |
1078 | utime = cputime.utime; | 1054 | utime = cputime.utime; |
1079 | ptime = cputime_add(utime, cputime.stime); | 1055 | ptime = utime + cputime.stime; |
1080 | sum_sched_runtime = cputime.sum_exec_runtime; | 1056 | sum_sched_runtime = cputime.sum_exec_runtime; |
1081 | maxfire = 20; | 1057 | maxfire = 20; |
1082 | prof_expires = cputime_zero; | 1058 | prof_expires = 0; |
1083 | while (!list_empty(timers)) { | 1059 | while (!list_empty(timers)) { |
1084 | struct cpu_timer_list *tl = list_first_entry(timers, | 1060 | struct cpu_timer_list *tl = list_first_entry(timers, |
1085 | struct cpu_timer_list, | 1061 | struct cpu_timer_list, |
1086 | entry); | 1062 | entry); |
1087 | if (!--maxfire || cputime_lt(ptime, tl->expires.cpu)) { | 1063 | if (!--maxfire || ptime < tl->expires.cpu) { |
1088 | prof_expires = tl->expires.cpu; | 1064 | prof_expires = tl->expires.cpu; |
1089 | break; | 1065 | break; |
1090 | } | 1066 | } |
@@ -1094,12 +1070,12 @@ static void check_process_timers(struct task_struct *tsk, | |||
1094 | 1070 | ||
1095 | ++timers; | 1071 | ++timers; |
1096 | maxfire = 20; | 1072 | maxfire = 20; |
1097 | virt_expires = cputime_zero; | 1073 | virt_expires = 0; |
1098 | while (!list_empty(timers)) { | 1074 | while (!list_empty(timers)) { |
1099 | struct cpu_timer_list *tl = list_first_entry(timers, | 1075 | struct cpu_timer_list *tl = list_first_entry(timers, |
1100 | struct cpu_timer_list, | 1076 | struct cpu_timer_list, |
1101 | entry); | 1077 | entry); |
1102 | if (!--maxfire || cputime_lt(utime, tl->expires.cpu)) { | 1078 | if (!--maxfire || utime < tl->expires.cpu) { |
1103 | virt_expires = tl->expires.cpu; | 1079 | virt_expires = tl->expires.cpu; |
1104 | break; | 1080 | break; |
1105 | } | 1081 | } |
@@ -1154,8 +1130,7 @@ static void check_process_timers(struct task_struct *tsk, | |||
1154 | } | 1130 | } |
1155 | } | 1131 | } |
1156 | x = secs_to_cputime(soft); | 1132 | x = secs_to_cputime(soft); |
1157 | if (cputime_eq(prof_expires, cputime_zero) || | 1133 | if (!prof_expires || x < prof_expires) { |
1158 | cputime_lt(x, prof_expires)) { | ||
1159 | prof_expires = x; | 1134 | prof_expires = x; |
1160 | } | 1135 | } |
1161 | } | 1136 | } |
@@ -1249,12 +1224,9 @@ out: | |||
1249 | static inline int task_cputime_expired(const struct task_cputime *sample, | 1224 | static inline int task_cputime_expired(const struct task_cputime *sample, |
1250 | const struct task_cputime *expires) | 1225 | const struct task_cputime *expires) |
1251 | { | 1226 | { |
1252 | if (!cputime_eq(expires->utime, cputime_zero) && | 1227 | if (expires->utime && sample->utime >= expires->utime) |
1253 | cputime_ge(sample->utime, expires->utime)) | ||
1254 | return 1; | 1228 | return 1; |
1255 | if (!cputime_eq(expires->stime, cputime_zero) && | 1229 | if (expires->stime && sample->utime + sample->stime >= expires->stime) |
1256 | cputime_ge(cputime_add(sample->utime, sample->stime), | ||
1257 | expires->stime)) | ||
1258 | return 1; | 1230 | return 1; |
1259 | if (expires->sum_exec_runtime != 0 && | 1231 | if (expires->sum_exec_runtime != 0 && |
1260 | sample->sum_exec_runtime >= expires->sum_exec_runtime) | 1232 | sample->sum_exec_runtime >= expires->sum_exec_runtime) |
@@ -1389,18 +1361,18 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx, | |||
1389 | * it to be relative, *newval argument is relative and we update | 1361 | * it to be relative, *newval argument is relative and we update |
1390 | * it to be absolute. | 1362 | * it to be absolute. |
1391 | */ | 1363 | */ |
1392 | if (!cputime_eq(*oldval, cputime_zero)) { | 1364 | if (*oldval) { |
1393 | if (cputime_le(*oldval, now.cpu)) { | 1365 | if (*oldval <= now.cpu) { |
1394 | /* Just about to fire. */ | 1366 | /* Just about to fire. */ |
1395 | *oldval = cputime_one_jiffy; | 1367 | *oldval = cputime_one_jiffy; |
1396 | } else { | 1368 | } else { |
1397 | *oldval = cputime_sub(*oldval, now.cpu); | 1369 | *oldval -= now.cpu; |
1398 | } | 1370 | } |
1399 | } | 1371 | } |
1400 | 1372 | ||
1401 | if (cputime_eq(*newval, cputime_zero)) | 1373 | if (!*newval) |
1402 | return; | 1374 | return; |
1403 | *newval = cputime_add(*newval, now.cpu); | 1375 | *newval += now.cpu; |
1404 | } | 1376 | } |
1405 | 1377 | ||
1406 | /* | 1378 | /* |
diff --git a/kernel/sched.c b/kernel/sched.c index d6b149ccf925..18cad4467e61 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -2166,7 +2166,7 @@ static int irqtime_account_hi_update(void) | |||
2166 | 2166 | ||
2167 | local_irq_save(flags); | 2167 | local_irq_save(flags); |
2168 | latest_ns = this_cpu_read(cpu_hardirq_time); | 2168 | latest_ns = this_cpu_read(cpu_hardirq_time); |
2169 | if (cputime64_gt(nsecs_to_cputime64(latest_ns), cpustat->irq)) | 2169 | if (nsecs_to_cputime64(latest_ns) > cpustat->irq) |
2170 | ret = 1; | 2170 | ret = 1; |
2171 | local_irq_restore(flags); | 2171 | local_irq_restore(flags); |
2172 | return ret; | 2172 | return ret; |
@@ -2181,7 +2181,7 @@ static int irqtime_account_si_update(void) | |||
2181 | 2181 | ||
2182 | local_irq_save(flags); | 2182 | local_irq_save(flags); |
2183 | latest_ns = this_cpu_read(cpu_softirq_time); | 2183 | latest_ns = this_cpu_read(cpu_softirq_time); |
2184 | if (cputime64_gt(nsecs_to_cputime64(latest_ns), cpustat->softirq)) | 2184 | if (nsecs_to_cputime64(latest_ns) > cpustat->softirq) |
2185 | ret = 1; | 2185 | ret = 1; |
2186 | local_irq_restore(flags); | 2186 | local_irq_restore(flags); |
2187 | return ret; | 2187 | return ret; |
@@ -3868,19 +3868,17 @@ void account_user_time(struct task_struct *p, cputime_t cputime, | |||
3868 | cputime_t cputime_scaled) | 3868 | cputime_t cputime_scaled) |
3869 | { | 3869 | { |
3870 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 3870 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
3871 | cputime64_t tmp; | ||
3872 | 3871 | ||
3873 | /* Add user time to process. */ | 3872 | /* Add user time to process. */ |
3874 | p->utime = cputime_add(p->utime, cputime); | 3873 | p->utime += cputime; |
3875 | p->utimescaled = cputime_add(p->utimescaled, cputime_scaled); | 3874 | p->utimescaled += cputime_scaled; |
3876 | account_group_user_time(p, cputime); | 3875 | account_group_user_time(p, cputime); |
3877 | 3876 | ||
3878 | /* Add user time to cpustat. */ | 3877 | /* Add user time to cpustat. */ |
3879 | tmp = cputime_to_cputime64(cputime); | ||
3880 | if (TASK_NICE(p) > 0) | 3878 | if (TASK_NICE(p) > 0) |
3881 | cpustat->nice = cputime64_add(cpustat->nice, tmp); | 3879 | cpustat->nice += (__force cputime64_t) cputime; |
3882 | else | 3880 | else |
3883 | cpustat->user = cputime64_add(cpustat->user, tmp); | 3881 | cpustat->user += (__force cputime64_t) cputime; |
3884 | 3882 | ||
3885 | cpuacct_update_stats(p, CPUACCT_STAT_USER, cputime); | 3883 | cpuacct_update_stats(p, CPUACCT_STAT_USER, cputime); |
3886 | /* Account for user time used */ | 3884 | /* Account for user time used */ |
@@ -3896,24 +3894,21 @@ void account_user_time(struct task_struct *p, cputime_t cputime, | |||
3896 | static void account_guest_time(struct task_struct *p, cputime_t cputime, | 3894 | static void account_guest_time(struct task_struct *p, cputime_t cputime, |
3897 | cputime_t cputime_scaled) | 3895 | cputime_t cputime_scaled) |
3898 | { | 3896 | { |
3899 | cputime64_t tmp; | ||
3900 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 3897 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
3901 | 3898 | ||
3902 | tmp = cputime_to_cputime64(cputime); | ||
3903 | |||
3904 | /* Add guest time to process. */ | 3899 | /* Add guest time to process. */ |
3905 | p->utime = cputime_add(p->utime, cputime); | 3900 | p->utime += cputime; |
3906 | p->utimescaled = cputime_add(p->utimescaled, cputime_scaled); | 3901 | p->utimescaled += cputime_scaled; |
3907 | account_group_user_time(p, cputime); | 3902 | account_group_user_time(p, cputime); |
3908 | p->gtime = cputime_add(p->gtime, cputime); | 3903 | p->gtime += cputime; |
3909 | 3904 | ||
3910 | /* Add guest time to cpustat. */ | 3905 | /* Add guest time to cpustat. */ |
3911 | if (TASK_NICE(p) > 0) { | 3906 | if (TASK_NICE(p) > 0) { |
3912 | cpustat->nice = cputime64_add(cpustat->nice, tmp); | 3907 | cpustat->nice += (__force cputime64_t) cputime; |
3913 | cpustat->guest_nice = cputime64_add(cpustat->guest_nice, tmp); | 3908 | cpustat->guest_nice += (__force cputime64_t) cputime; |
3914 | } else { | 3909 | } else { |
3915 | cpustat->user = cputime64_add(cpustat->user, tmp); | 3910 | cpustat->user += (__force cputime64_t) cputime; |
3916 | cpustat->guest = cputime64_add(cpustat->guest, tmp); | 3911 | cpustat->guest += (__force cputime64_t) cputime; |
3917 | } | 3912 | } |
3918 | } | 3913 | } |
3919 | 3914 | ||
@@ -3928,15 +3923,13 @@ static inline | |||
3928 | void __account_system_time(struct task_struct *p, cputime_t cputime, | 3923 | void __account_system_time(struct task_struct *p, cputime_t cputime, |
3929 | cputime_t cputime_scaled, cputime64_t *target_cputime64) | 3924 | cputime_t cputime_scaled, cputime64_t *target_cputime64) |
3930 | { | 3925 | { |
3931 | cputime64_t tmp = cputime_to_cputime64(cputime); | ||
3932 | |||
3933 | /* Add system time to process. */ | 3926 | /* Add system time to process. */ |
3934 | p->stime = cputime_add(p->stime, cputime); | 3927 | p->stime += cputime; |
3935 | p->stimescaled = cputime_add(p->stimescaled, cputime_scaled); | 3928 | p->stimescaled += cputime_scaled; |
3936 | account_group_system_time(p, cputime); | 3929 | account_group_system_time(p, cputime); |
3937 | 3930 | ||
3938 | /* Add system time to cpustat. */ | 3931 | /* Add system time to cpustat. */ |
3939 | *target_cputime64 = cputime64_add(*target_cputime64, tmp); | 3932 | *target_cputime64 += (__force cputime64_t) cputime; |
3940 | cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime); | 3933 | cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime); |
3941 | 3934 | ||
3942 | /* Account for system time used */ | 3935 | /* Account for system time used */ |
@@ -3978,9 +3971,8 @@ void account_system_time(struct task_struct *p, int hardirq_offset, | |||
3978 | void account_steal_time(cputime_t cputime) | 3971 | void account_steal_time(cputime_t cputime) |
3979 | { | 3972 | { |
3980 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 3973 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
3981 | cputime64_t cputime64 = cputime_to_cputime64(cputime); | ||
3982 | 3974 | ||
3983 | cpustat->steal = cputime64_add(cpustat->steal, cputime64); | 3975 | cpustat->steal += (__force cputime64_t) cputime; |
3984 | } | 3976 | } |
3985 | 3977 | ||
3986 | /* | 3978 | /* |
@@ -3990,13 +3982,12 @@ void account_steal_time(cputime_t cputime) | |||
3990 | void account_idle_time(cputime_t cputime) | 3982 | void account_idle_time(cputime_t cputime) |
3991 | { | 3983 | { |
3992 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 3984 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
3993 | cputime64_t cputime64 = cputime_to_cputime64(cputime); | ||
3994 | struct rq *rq = this_rq(); | 3985 | struct rq *rq = this_rq(); |
3995 | 3986 | ||
3996 | if (atomic_read(&rq->nr_iowait) > 0) | 3987 | if (atomic_read(&rq->nr_iowait) > 0) |
3997 | cpustat->iowait = cputime64_add(cpustat->iowait, cputime64); | 3988 | cpustat->iowait += (__force cputime64_t) cputime; |
3998 | else | 3989 | else |
3999 | cpustat->idle = cputime64_add(cpustat->idle, cputime64); | 3990 | cpustat->idle += (__force cputime64_t) cputime; |
4000 | } | 3991 | } |
4001 | 3992 | ||
4002 | static __always_inline bool steal_account_process_tick(void) | 3993 | static __always_inline bool steal_account_process_tick(void) |
@@ -4046,16 +4037,15 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, | |||
4046 | struct rq *rq) | 4037 | struct rq *rq) |
4047 | { | 4038 | { |
4048 | cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy); | 4039 | cputime_t one_jiffy_scaled = cputime_to_scaled(cputime_one_jiffy); |
4049 | cputime64_t tmp = cputime_to_cputime64(cputime_one_jiffy); | ||
4050 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | 4040 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; |
4051 | 4041 | ||
4052 | if (steal_account_process_tick()) | 4042 | if (steal_account_process_tick()) |
4053 | return; | 4043 | return; |
4054 | 4044 | ||
4055 | if (irqtime_account_hi_update()) { | 4045 | if (irqtime_account_hi_update()) { |
4056 | cpustat->irq = cputime64_add(cpustat->irq, tmp); | 4046 | cpustat->irq += (__force cputime64_t) cputime_one_jiffy; |
4057 | } else if (irqtime_account_si_update()) { | 4047 | } else if (irqtime_account_si_update()) { |
4058 | cpustat->softirq = cputime64_add(cpustat->softirq, tmp); | 4048 | cpustat->softirq += (__force cputime64_t) cputime_one_jiffy; |
4059 | } else if (this_cpu_ksoftirqd() == p) { | 4049 | } else if (this_cpu_ksoftirqd() == p) { |
4060 | /* | 4050 | /* |
4061 | * ksoftirqd time do not get accounted in cpu_softirq_time. | 4051 | * ksoftirqd time do not get accounted in cpu_softirq_time. |
@@ -4171,7 +4161,7 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | |||
4171 | 4161 | ||
4172 | void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | 4162 | void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) |
4173 | { | 4163 | { |
4174 | cputime_t rtime, utime = p->utime, total = cputime_add(utime, p->stime); | 4164 | cputime_t rtime, utime = p->utime, total = utime + p->stime; |
4175 | 4165 | ||
4176 | /* | 4166 | /* |
4177 | * Use CFS's precise accounting: | 4167 | * Use CFS's precise accounting: |
@@ -4179,11 +4169,11 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | |||
4179 | rtime = nsecs_to_cputime(p->se.sum_exec_runtime); | 4169 | rtime = nsecs_to_cputime(p->se.sum_exec_runtime); |
4180 | 4170 | ||
4181 | if (total) { | 4171 | if (total) { |
4182 | u64 temp = rtime; | 4172 | u64 temp = (__force u64) rtime; |
4183 | 4173 | ||
4184 | temp *= utime; | 4174 | temp *= (__force u64) utime; |
4185 | do_div(temp, total); | 4175 | do_div(temp, (__force u32) total); |
4186 | utime = (cputime_t)temp; | 4176 | utime = (__force cputime_t) temp; |
4187 | } else | 4177 | } else |
4188 | utime = rtime; | 4178 | utime = rtime; |
4189 | 4179 | ||
@@ -4191,7 +4181,7 @@ void task_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | |||
4191 | * Compare with previous values, to keep monotonicity: | 4181 | * Compare with previous values, to keep monotonicity: |
4192 | */ | 4182 | */ |
4193 | p->prev_utime = max(p->prev_utime, utime); | 4183 | p->prev_utime = max(p->prev_utime, utime); |
4194 | p->prev_stime = max(p->prev_stime, cputime_sub(rtime, p->prev_utime)); | 4184 | p->prev_stime = max(p->prev_stime, rtime - p->prev_utime); |
4195 | 4185 | ||
4196 | *ut = p->prev_utime; | 4186 | *ut = p->prev_utime; |
4197 | *st = p->prev_stime; | 4187 | *st = p->prev_stime; |
@@ -4208,21 +4198,20 @@ void thread_group_times(struct task_struct *p, cputime_t *ut, cputime_t *st) | |||
4208 | 4198 | ||
4209 | thread_group_cputime(p, &cputime); | 4199 | thread_group_cputime(p, &cputime); |
4210 | 4200 | ||
4211 | total = cputime_add(cputime.utime, cputime.stime); | 4201 | total = cputime.utime + cputime.stime; |
4212 | rtime = nsecs_to_cputime(cputime.sum_exec_runtime); | 4202 | rtime = nsecs_to_cputime(cputime.sum_exec_runtime); |
4213 | 4203 | ||
4214 | if (total) { | 4204 | if (total) { |
4215 | u64 temp = rtime; | 4205 | u64 temp = (__force u64) rtime; |
4216 | 4206 | ||
4217 | temp *= cputime.utime; | 4207 | temp *= (__force u64) cputime.utime; |
4218 | do_div(temp, total); | 4208 | do_div(temp, (__force u32) total); |
4219 | utime = (cputime_t)temp; | 4209 | utime = (__force cputime_t) temp; |
4220 | } else | 4210 | } else |
4221 | utime = rtime; | 4211 | utime = rtime; |
4222 | 4212 | ||
4223 | sig->prev_utime = max(sig->prev_utime, utime); | 4213 | sig->prev_utime = max(sig->prev_utime, utime); |
4224 | sig->prev_stime = max(sig->prev_stime, | 4214 | sig->prev_stime = max(sig->prev_stime, rtime - sig->prev_utime); |
4225 | cputime_sub(rtime, sig->prev_utime)); | ||
4226 | 4215 | ||
4227 | *ut = sig->prev_utime; | 4216 | *ut = sig->prev_utime; |
4228 | *st = sig->prev_stime; | 4217 | *st = sig->prev_stime; |
@@ -9769,7 +9758,8 @@ static void cpuacct_update_stats(struct task_struct *tsk, | |||
9769 | ca = task_ca(tsk); | 9758 | ca = task_ca(tsk); |
9770 | 9759 | ||
9771 | do { | 9760 | do { |
9772 | __percpu_counter_add(&ca->cpustat[idx], val, batch); | 9761 | __percpu_counter_add(&ca->cpustat[idx], |
9762 | (__force s64) val, batch); | ||
9773 | ca = ca->parent; | 9763 | ca = ca->parent; |
9774 | } while (ca); | 9764 | } while (ca); |
9775 | rcu_read_unlock(); | 9765 | rcu_read_unlock(); |
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h index 87f9e36ea56e..4b71dbef271d 100644 --- a/kernel/sched_stats.h +++ b/kernel/sched_stats.h | |||
@@ -283,8 +283,7 @@ static inline void account_group_user_time(struct task_struct *tsk, | |||
283 | return; | 283 | return; |
284 | 284 | ||
285 | raw_spin_lock(&cputimer->lock); | 285 | raw_spin_lock(&cputimer->lock); |
286 | cputimer->cputime.utime = | 286 | cputimer->cputime.utime += cputime; |
287 | cputime_add(cputimer->cputime.utime, cputime); | ||
288 | raw_spin_unlock(&cputimer->lock); | 287 | raw_spin_unlock(&cputimer->lock); |
289 | } | 288 | } |
290 | 289 | ||
@@ -307,8 +306,7 @@ static inline void account_group_system_time(struct task_struct *tsk, | |||
307 | return; | 306 | return; |
308 | 307 | ||
309 | raw_spin_lock(&cputimer->lock); | 308 | raw_spin_lock(&cputimer->lock); |
310 | cputimer->cputime.stime = | 309 | cputimer->cputime.stime += cputime; |
311 | cputime_add(cputimer->cputime.stime, cputime); | ||
312 | raw_spin_unlock(&cputimer->lock); | 310 | raw_spin_unlock(&cputimer->lock); |
313 | } | 311 | } |
314 | 312 | ||
diff --git a/kernel/signal.c b/kernel/signal.c index b3f78d09a105..739ef2bf105c 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -1629,10 +1629,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig) | |||
1629 | info.si_uid = __task_cred(tsk)->uid; | 1629 | info.si_uid = __task_cred(tsk)->uid; |
1630 | rcu_read_unlock(); | 1630 | rcu_read_unlock(); |
1631 | 1631 | ||
1632 | info.si_utime = cputime_to_clock_t(cputime_add(tsk->utime, | 1632 | info.si_utime = cputime_to_clock_t(tsk->utime + tsk->signal->utime); |
1633 | tsk->signal->utime)); | 1633 | info.si_stime = cputime_to_clock_t(tsk->stime + tsk->signal->stime); |
1634 | info.si_stime = cputime_to_clock_t(cputime_add(tsk->stime, | ||
1635 | tsk->signal->stime)); | ||
1636 | 1634 | ||
1637 | info.si_status = tsk->exit_code & 0x7f; | 1635 | info.si_status = tsk->exit_code & 0x7f; |
1638 | if (tsk->exit_code & 0x80) | 1636 | if (tsk->exit_code & 0x80) |
diff --git a/kernel/sys.c b/kernel/sys.c index 481611fbd079..ddf8155bf3f8 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -1605,7 +1605,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1605 | unsigned long maxrss = 0; | 1605 | unsigned long maxrss = 0; |
1606 | 1606 | ||
1607 | memset((char *) r, 0, sizeof *r); | 1607 | memset((char *) r, 0, sizeof *r); |
1608 | utime = stime = cputime_zero; | 1608 | utime = stime = 0; |
1609 | 1609 | ||
1610 | if (who == RUSAGE_THREAD) { | 1610 | if (who == RUSAGE_THREAD) { |
1611 | task_times(current, &utime, &stime); | 1611 | task_times(current, &utime, &stime); |
@@ -1635,8 +1635,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r) | |||
1635 | 1635 | ||
1636 | case RUSAGE_SELF: | 1636 | case RUSAGE_SELF: |
1637 | thread_group_times(p, &tgutime, &tgstime); | 1637 | thread_group_times(p, &tgutime, &tgstime); |
1638 | utime = cputime_add(utime, tgutime); | 1638 | utime += tgutime; |
1639 | stime = cputime_add(stime, tgstime); | 1639 | stime += tgstime; |
1640 | r->ru_nvcsw += p->signal->nvcsw; | 1640 | r->ru_nvcsw += p->signal->nvcsw; |
1641 | r->ru_nivcsw += p->signal->nivcsw; | 1641 | r->ru_nivcsw += p->signal->nivcsw; |
1642 | r->ru_minflt += p->signal->min_flt; | 1642 | r->ru_minflt += p->signal->min_flt; |
diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 5bbfac85866e..23b4d784ebdd 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c | |||
@@ -127,7 +127,7 @@ void acct_update_integrals(struct task_struct *tsk) | |||
127 | 127 | ||
128 | local_irq_save(flags); | 128 | local_irq_save(flags); |
129 | time = tsk->stime + tsk->utime; | 129 | time = tsk->stime + tsk->utime; |
130 | dtime = cputime_sub(time, tsk->acct_timexpd); | 130 | dtime = time - tsk->acct_timexpd; |
131 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); | 131 | jiffies_to_timeval(cputime_to_jiffies(dtime), &value); |
132 | delta = value.tv_sec; | 132 | delta = value.tv_sec; |
133 | delta = delta * USEC_PER_SEC + value.tv_usec; | 133 | delta = delta * USEC_PER_SEC + value.tv_usec; |