[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-8f2e586567b1bad72dac7c3810fe9a2ef7117506@git.kernel.org>
Date: Wed, 8 Apr 2009 16:09:49 GMT
From: Oleg Nesterov <oleg@...hat.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
ia6432@...ox.ru, peterz@...radead.org, roland@...hat.com,
tglx@...utronix.de, oleg@...hat.com, mingo@...e.hu
Subject: [tip:timers/urgent] posix-timers: fix RLIMIT_CPU && setitimer(CPUCLOCK_PROF)
Commit-ID: 8f2e586567b1bad72dac7c3810fe9a2ef7117506
Gitweb: http://git.kernel.org/tip/8f2e586567b1bad72dac7c3810fe9a2ef7117506
Author: Oleg Nesterov <oleg@...hat.com>
AuthorDate: Fri, 27 Mar 2009 01:06:10 +0100
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Wed, 8 Apr 2009 17:51:39 +0200
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@...hat.com>
Acked-by: Peter Zijlstra <peterz@...radead.org>
Cc: Peter Lojkin <ia6432@...ox.ru>
Cc: Roland McGrath <roland@...hat.com>
Cc: stable@...nel.org
LKML-Reference: <20090327000610.GA10108@...hat.com>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
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 8e5d9a6..bb53185 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)
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