diff options
author | Oleg Nesterov <oleg@redhat.com> | 2009-03-26 20:06:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-04-08 11:51:39 -0400 |
commit | 8f2e586567b1bad72dac7c3810fe9a2ef7117506 (patch) | |
tree | 23da00a7e4b78f71c5d32ba350d0039b5016124e /kernel | |
parent | 6279a751fe096a21dc7704e918d570d3ff06e769 (diff) |
posix-timers: fix RLIMIT_CPU && setitimer(CPUCLOCK_PROF)
update_rlimit_cpu() tries to optimize out set_process_cpu_timer() in case
when we already have CPUCLOCK_PROF timer which should expire first. But it
uses cputime_lt() instead of cputime_gt().
Test case:
int main(void)
{
struct itimerval it = {
.it_value = { .tv_sec = 1000 },
};
assert(!setitimer(ITIMER_PROF, &it, NULL));
struct rlimit rl = {
.rlim_cur = 1,
.rlim_max = 1,
};
assert(!setrlimit(RLIMIT_CPU, &rl));
for (;;)
;
return 0;
}
Without this patch, the task is not killed as RLIMIT_CPU demands.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Peter Lojkin <ia6432@inbox.ru>
Cc: Roland McGrath <roland@redhat.com>
Cc: stable@kernel.org
LKML-Reference: <20090327000610.GA10108@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/posix-cpu-timers.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c index 8e5d9a68b022..bb53185d8c78 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(¤t->sighand->siglock); | 22 | spin_lock_irq(¤t->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(¤t->sighand->siglock); | 24 | spin_unlock_irq(¤t->sighand->siglock); |