Re: per-thread rusage

From: Ulrich Drepper
Date: Tue May 01 2007 - 20:17:48 EST


On 5/1/07, Theodore Tso <tytso@xxxxxxx> wrote:
There are two ways of implementing this. One is to have the
JVM periodically poll using a pthread_getrusage() interface.

Not a good idea.

A better
choice might be some kind of per-thread CPU limit, that would result
in a thread-specific SIGXCPU signal. But there are no interfaces
today that do anything like this.

We have, in principal: setrlimit. We jump through hoops in the moment
to make RLIMIT_CPU a per-process facility. This is all nice. All you
need to do is to add resources RLIMIT_*_THREAD (e.g.,
RLIMIT_CPU_THREAD) and additionally do accounting in a per-thread
basis.

The only issue which has to be decided is what is the action when the
limit is exceeded. An unanswered signal kills the process, not just
the thread. And you cannot just terminate a thread in the kernel
since there might be userlevel cleanup to do. The thread library can
also not simply hijack the SIGXCPU signal, the application want to use
it. The thread cancellation must appear like any other cancellation,
perhaps with a special status value (PTHREAD_CANCELED_XCPU instead of
PTHREAD_CANCEL). But that's a userlevel detail.

So what would be additionally needed is a method to specify what
signal to sent. The default might just as well be SIGXCPU but this
must be changable.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/