mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Markus Wichmann <nullplan@gmx.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Split fork and abort locks
Date: Sat, 20 Jan 2024 16:32:32 -0500	[thread overview]
Message-ID: <20240120213232.GY4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <ZauAbDW5gvvb6iDM@voyager>

On Sat, Jan 20, 2024 at 09:12:28AM +0100, Markus Wichmann wrote:
> Hi all,
> 
> a while ago I had noticed that __abort_lock was being taken in some
> functions that have nothing to do with SIGABRT. Namely in the forking
> functions. Investigating this a bit, I noticed that __abort_lock had
> become dual purpose. But this is a code smell.
> 
> Actually, there are several locks that have expanded in scope a bit
> since their introduction. At least the ptc lock (__inhibit_ptc() et al.)
> deserves a closer look later on as well. Seems to me like in case of the
> default stack size, that lock is used simply because an rwlock was
> needed and this one was around.

The scope of this lock has always been modification to state that new
thread creation depends on, which is largely "how much storage does a
new thread need?"

Originally, the relevant state was just the amount of TLS memory
needed. With the addition of default stack size control, that also
became part of the relevant state. In theory these could be protected
by different locks, but I don't see any good reason for splitting
them.

The reason fork takes the __inhibit_ptc lock is that it has to take
all the internal locks; this has nothing to do with the scope of
what's protected by the particular lock.

Rich

      parent reply	other threads:[~2024-01-20 21:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20  8:12 Markus Wichmann
2024-01-20 11:29 ` Alexey Izbyshev
2024-01-20 21:24   ` Rich Felker
2024-01-20 21:32 ` Rich Felker [this message]

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=20240120213232.GY4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nullplan@gmx.net \
    /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).