From: Peter Zijlstra <peterz@infradead.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>, Peter Lojkin <ia6432@inbox.ru>,
Roland McGrath <roland@redhat.com>,
linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH 2/2] posix-timers: fix RLIMIT_CPU && setitimer(CPUCLOCK_PROF)
Date: Sat, 28 Mar 2009 00:59:28 +0100 [thread overview]
Message-ID: <1238198368.4039.320.camel@laptop> (raw)
In-Reply-To: <20090327000610.GA10108@redhat.com>
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@redhat.com>
Nice catch,
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.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);
>
next prev parent reply other threads:[~2009-03-28 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-27 0:06 Oleg Nesterov
2009-03-27 23:59 ` Peter Zijlstra [this message]
2009-04-08 16:09 ` [tip:timers/urgent] " Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1238198368.4039.320.camel@laptop \
--to=peterz@infradead.org \
--cc=ia6432@inbox.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=stable@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®