Re: [PATCH 0/3] extend get/setrlimit to support setting rlimits externalto a process (v7)

From: Jiri Slaby
Date: Mon Nov 09 2009 - 03:54:35 EST


On 11/06/2009 10:26 AM, Ingo Molnar wrote:
> Also, the locking there looks messy:
>
> + /* optimization: 'current' doesn't need locking, e.g. setrlimit */
> + if (tsk != current) {
> + /* protect tsk->signal and tsk->sighand from disappearing */
> + read_lock(&tasklist_lock);
> + if (!tsk->sighand) {
> + retval = -ESRCH;
> + goto out;
> + }
> }
>
> Neil's splitup into a helper function looks _far_ cleaner.

Oops, I don't understand here. Looking at
http://patchwork.kernel.org/patch/54863/
and
http://decibel.fi.muni.cz/cgi-bin/gitweb.cgi?p=linux.git;a=commitdiff;h=ba9ba971a9241250646091935d77d2f31b7c15af

They are almost identical. That 'if' above is added by:
http://decibel.fi.muni.cz/cgi-bin/gitweb.cgi?p=linux.git;a=commitdiff;h=bab65b1e6c0fd797a1ecdb32911faa82947effd0

The latter commit is to avoid performance penalty introduced for
setrlimit syscall by the added lock (as it's unneeded for 'current'). If
you find that crappy, there is no problem to drop it, indeed.
--
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/