]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
posix-timers: fix RLIMIT_CPU && setitimer(CPUCLOCK_PROF)
authorOleg Nesterov <oleg@redhat.com>
Thu, 9 Apr 2009 18:20:08 +0000 (18:20 +0000)
committerChris Wright <chrisw@sous-sol.org>
Mon, 27 Apr 2009 17:36:59 +0000 (10:36 -0700)
commit55e3b46ded854d9fc2408d0d15a6a5aea4986333
tree0f4c076bffe04deaf6b9d8cc67fdc7b6e3b74755
parent3fe90c4dc50b1c4030d73d196a5d812ea906a4c9
posix-timers: fix RLIMIT_CPU && setitimer(CPUCLOCK_PROF)

upstream commit: 8f2e586567b1bad72dac7c3810fe9a2ef7117506

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>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
kernel/posix-cpu-timers.c