aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/posix-cpu-timers.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/posix-cpu-timers.c')
-rw-r--r--kernel/posix-cpu-timers.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index e976e505648d..e33a21cb9407 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -18,7 +18,7 @@ void update_rlimit_cpu(unsigned long rlim_new)
18 18
19 cputime = secs_to_cputime(rlim_new); 19 cputime = secs_to_cputime(rlim_new);
20 if (cputime_eq(current->signal->it_prof_expires, cputime_zero) || 20 if (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
21 cputime_lt(current->signal->it_prof_expires, cputime)) { 21 cputime_gt(current->signal->it_prof_expires, cputime)) {
22 spin_lock_irq(&current->sighand->siglock); 22 spin_lock_irq(&current->sighand->siglock);
23 set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL); 23 set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
24 spin_unlock_irq(&current->sighand->siglock); 24 spin_unlock_irq(&current->sighand->siglock);
@@ -224,7 +224,7 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
224 cpu->cpu = virt_ticks(p); 224 cpu->cpu = virt_ticks(p);
225 break; 225 break;
226 case CPUCLOCK_SCHED: 226 case CPUCLOCK_SCHED:
227 cpu->sched = p->se.sum_exec_runtime + task_delta_exec(p); 227 cpu->sched = task_sched_runtime(p);
228 break; 228 break;
229 } 229 }
230 return 0; 230 return 0;
@@ -305,18 +305,19 @@ static int cpu_clock_sample_group(const clockid_t which_clock,
305{ 305{
306 struct task_cputime cputime; 306 struct task_cputime cputime;
307 307
308 thread_group_cputime(p, &cputime);
309 switch (CPUCLOCK_WHICH(which_clock)) { 308 switch (CPUCLOCK_WHICH(which_clock)) {
310 default: 309 default:
311 return -EINVAL; 310 return -EINVAL;
312 case CPUCLOCK_PROF: 311 case CPUCLOCK_PROF:
312 thread_group_cputime(p, &cputime);
313 cpu->cpu = cputime_add(cputime.utime, cputime.stime); 313 cpu->cpu = cputime_add(cputime.utime, cputime.stime);
314 break; 314 break;
315 case CPUCLOCK_VIRT: 315 case CPUCLOCK_VIRT:
316 thread_group_cputime(p, &cputime);
316 cpu->cpu = cputime.utime; 317 cpu->cpu = cputime.utime;
317 break; 318 break;
318 case CPUCLOCK_SCHED: 319 case CPUCLOCK_SCHED:
319 cpu->sched = cputime.sum_exec_runtime + task_delta_exec(p); 320 cpu->sched = thread_group_sched_runtime(p);
320 break; 321 break;
321 } 322 }
322 return 0; 323 return 0;
@@ -520,11 +521,12 @@ void posix_cpu_timers_exit(struct task_struct *tsk)
520} 521}
521void posix_cpu_timers_exit_group(struct task_struct *tsk) 522void posix_cpu_timers_exit_group(struct task_struct *tsk)
522{ 523{
523 struct task_cputime cputime; 524 struct signal_struct *const sig = tsk->signal;
524 525
525 thread_group_cputimer(tsk, &cputime);
526 cleanup_timers(tsk->signal->cpu_timers, 526 cleanup_timers(tsk->signal->cpu_timers,
527 cputime.utime, cputime.stime, cputime.sum_exec_runtime); 527 cputime_add(tsk->utime, sig->utime),
528 cputime_add(tsk->stime, sig->stime),
529 tsk->se.sum_exec_runtime + sig->sum_sched_runtime);
528} 530}
529 531
530static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) 532static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now)
@@ -1370,7 +1372,8 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
1370 if (task_cputime_expired(&group_sample, &sig->cputime_expires)) 1372 if (task_cputime_expired(&group_sample, &sig->cputime_expires))
1371 return 1; 1373 return 1;
1372 } 1374 }
1373 return 0; 1375
1376 return sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY;
1374} 1377}
1375 1378
1376/* 1379/*
@@ -1418,19 +1421,19 @@ void run_posix_cpu_timers(struct task_struct *tsk)
1418 * timer call will interfere. 1421 * timer call will interfere.
1419 */ 1422 */
1420 list_for_each_entry_safe(timer, next, &firing, it.cpu.entry) { 1423 list_for_each_entry_safe(timer, next, &firing, it.cpu.entry) {
1421 int firing; 1424 int cpu_firing;
1425
1422 spin_lock(&timer->it_lock); 1426 spin_lock(&timer->it_lock);
1423 list_del_init(&timer->it.cpu.entry); 1427 list_del_init(&timer->it.cpu.entry);
1424 firing = timer->it.cpu.firing; 1428 cpu_firing = timer->it.cpu.firing;
1425 timer->it.cpu.firing = 0; 1429 timer->it.cpu.firing = 0;
1426 /* 1430 /*
1427 * The firing flag is -1 if we collided with a reset 1431 * The firing flag is -1 if we collided with a reset
1428 * of the timer, which already reported this 1432 * of the timer, which already reported this
1429 * almost-firing as an overrun. So don't generate an event. 1433 * almost-firing as an overrun. So don't generate an event.
1430 */ 1434 */
1431 if (likely(firing >= 0)) { 1435 if (likely(cpu_firing >= 0))
1432 cpu_timer_fire(timer); 1436 cpu_timer_fire(timer);
1433 }
1434 spin_unlock(&timer->it_lock); 1437 spin_unlock(&timer->it_lock);
1435 } 1438 }
1436} 1439}