All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Lojkin <ia6432@inbox.ru>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	rjw@sisk.pl
Subject: Re: 2.6.28, limiting cpu time doesn't work
Date: Sun, 22 Mar 2009 21:14:36 +0100	[thread overview]
Message-ID: <20090322201436.GA12838@redhat.com> (raw)
In-Reply-To: <E1LkN4B-0002yU-00.ia6432-inbox-ru@f205.mail.ru>

On 03/19, Peter Lojkin wrote:
>
> after upgrade to 2.6.28 ulimit -t doesn't work. for example:
>
> bash# ulimit -t 3; cpuhog
>
> (where cpuhog is any program that continuously use cpu)
> with 2.6.27.20 cpuhog gets killed after 3sec as expected.
> with 2.6.28, 2.6.28.8, 2.6.29-rc8-git4 it's keep running indefinitely.
> ulimit -a and /proc/<pid>/limits show that cputime limit was set correctly.

Found this message on http://bugzilla.kernel.org/show_bug.cgi?id=12911 ...

I _think_ posix_cpu_timers_init_group() is not right, it should copy
cputime_expires->prof_exp.

Peter, any chance you can test the (uncompiled/untested) patch below?

Also, I assume that something like

	$ ulimit -t 3
	$ while true; do true; done

kills the shell correctly, yes? IOW, I suspect that ulimit works, but
cpuhog never check RLIMIT_CPU because fastpath_timer_check() always
returns 0 due to task_cputime_zero(&sig->cputime_expires) == T.

I'm afraid we need the fix fo 2.6.29 as well, but I am looking at rc3.

Hmm. check_process_timers() updates ->cputime_expires, but it never
clears (say) cputime_expires.prof_exp, why? Can't we just do

	if (cputime_gt(sig->cputime_expires.prof_exp, prof_expires))
		sig->cputime_expires.prof_exp = prof_expires;
at the end?

Oleg.

--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -790,9 +790,7 @@ static void posix_cpu_timers_init_group(
 	sig->it_prof_incr = cputime_zero;
 
 	/* Cached expiration times. */
-	sig->cputime_expires.prof_exp = cputime_zero;
-	sig->cputime_expires.virt_exp = cputime_zero;
-	sig->cputime_expires.sched_exp = 0;
+	sig->cputime_expires = current->signal->cputime_expires;
 
 	/* The timer lists. */
 	INIT_LIST_HEAD(&sig->cpu_timers[0]);


  reply	other threads:[~2009-03-22 20:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 18:34 2.6.28, limiting cpu time doesn't work Peter Lojkin
2009-03-22 20:14 ` Oleg Nesterov [this message]
2009-03-22 22:08   ` Peter Lojkin
2009-03-22 23:11     ` Oleg Nesterov
2009-03-23 16:43       ` Ingo Molnar
2009-03-23 19:34         ` [PATCH, for 2.6.29] BUG 12911: fix RLIMIT_CPU && fork() Oleg Nesterov
2009-03-23 19:45           ` [tip:timers/urgent] posix timers: " Oleg Nesterov
2009-03-24 18:26             ` Oleg Nesterov
2009-03-24 21:05               ` Ingo Molnar
2009-03-24 21:34                 ` Oleg Nesterov
2009-03-24  2:43       ` 2.6.28, limiting cpu time doesn't work Peter Lojkin

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=20090322201436.GA12838@redhat.com \
    --to=oleg@redhat.com \
    --cc=ia6432@inbox.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rjw@sisk.pl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.