From: Rich Felker <dalias@libc.org>
To: Alexey Izbyshev <izbyshev@ispras.ru>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Why is setrlimit() considered to have per-thread effect?
Date: Thu, 15 Oct 2020 13:13:16 -0400 [thread overview]
Message-ID: <20201015171315.GV17637@brightrain.aerifal.cx> (raw)
In-Reply-To: <68e70f27d78c9507631dd2c22187f77d@ispras.ru>
On Thu, Oct 15, 2020 at 07:13:30PM +0300, Alexey Izbyshev wrote:
> On 2020-10-15 18:49, Rich Felker wrote:
> >setrlimit implemented in terms of prlimit does; as far as I can tell
> >prlimit does not perform any process-global action itself but just
> >lets you target different tasks. This means we *could* "optimize"
> >setrlimit to skip __synccall and instead just iterate over the thread
> >list and SYS_prlimit each one from the calling thread context.
> >
> >The prlimit function on the other hand behaves as the Linux syscall
> >and lets you set thread-specific limits.
> >
> But in my understanding, prlimit() sets process- (not thread-)
> specific limits, and have done so since its introduction[1]. The
That was not my understanding, but it may be true. I would not assume
it's true just because of the word "process" in a commit message or
comment since kernel folks, especially in that era, regularly used
"process" and "thread" interchangibly/inconsistently.
> code operates on "signal" structure which is shared between threads
> of a thread group. Further, an earlier commit[2] explicitly says
> that "...rlimit are
> per process and not per-thread.". It's true that in pre-2.6.10
> kernels setrlimit() operated in per-thread limits (see my reply to
> Szabolcs), but it's not related to prlimit() syscall, which was
> added much later.
>
> To be clear, I did not propose to optimize setrlimit() in my initial
> email, I was just surprised that synccall() is needed at all. But if
> we want optimization, it seems that trying prlimit() first and
> falling back to synccall() in case of ENOSYS would be what we want.
If correct, I agree -- we can avoid the need for __synccall when
prlimit works. I'd like to find commits or source lines supporting
that in their actual (code) content though rather than just as a
mention in commit messages, since it's contrary to what my (probably
outdated) understanding of how rlimits worked was.
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c022a0acad534fd5f5d5f17280f6d4d135e74e81
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7855c35da7ba16b389d17710401c4a55a3ea2102
Somewhat off-topic, but for some reason that second link is bringing
my browser to a crawl swapping, despite the commit being tiny when I
view it locally in my kernel tree. Weird.
Rich
next prev parent reply other threads:[~2020-10-15 17:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-15 5:01 Alexey Izbyshev
2020-10-15 8:50 ` Szabolcs Nagy
2020-10-15 15:49 ` Rich Felker
2020-10-15 16:13 ` Alexey Izbyshev
2020-10-15 17:13 ` Rich Felker [this message]
2020-10-15 18:26 ` Alexey Izbyshev
2020-10-15 20:03 ` Rich Felker
2020-10-15 15:50 ` Alexey Izbyshev
2020-10-15 20:05 ` Rich Felker
2020-10-15 15:43 ` Rich Felker
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=20201015171315.GV17637@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=izbyshev@ispras.ru \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).