[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1238198368.4039.320.camel@laptop>
Date: Sat, 28 Mar 2009 00:59:28 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Ingo Molnar <mingo@...e.hu>, Peter Lojkin <ia6432@...ox.ru>,
Roland McGrath <roland@...hat.com>,
linux-kernel@...r.kernel.org, stable@...nel.org
Subject: Re: [PATCH 2/2] posix-timers: fix RLIMIT_CPU &&
setitimer(CPUCLOCK_PROF)
On Fri, 2009-03-27 at 01:06 +0100, Oleg Nesterov wrote:
> 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@...hat.com>
Nice catch,
Acked-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> --- 6.29/kernel/posix-cpu-timers.c~2_UPDATE_RLIM 2009-03-23 18:13:57.000000000 +0100
> +++ 6.29/kernel/posix-cpu-timers.c 2009-03-27 00:45:31.000000000 +0100
> @@ -18,7 +18,7 @@ void update_rlimit_cpu(unsigned long rli
>
> cputime = secs_to_cputime(rlim_new);
> if (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
> - cputime_lt(current->signal->it_prof_expires, cputime)) {
> + cputime_gt(current->signal->it_prof_expires, cputime)) {
> spin_lock_irq(¤t->sighand->siglock);
> set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
> spin_unlock_irq(¤t->sighand->siglock);
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists