public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] nptl: Start new threads with all signals blocked [BZ #25098]
Date: Thu, 17 Oct 2019 21:49:00 -0000	[thread overview]
Message-ID: <87eezbvy81.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <37512974-b590-967b-25aa-6bf0082adeb7@linaro.org> (Adhemerval Zanella's message of "Thu, 17 Oct 2019 15:33:53 -0300")

* Adhemerval Zanella:

>> The cost of doing this is two rt_sigprocmask system calls on the old
>> thread, and one rt_sigprocmask system call on the new thread.  (If
>> there was a way to clone a new thread with a signals disabled, this
>> could be brought down to one system call each.)  The thread descriptor
>> increases in size, too, and sigset_t is fairly large.  This increase
>> could be brought down by reusing space the in the descriptor which is
>> not needed before running user code, or by switching to an internal
>> sigset_t definition which only covers the signals supported by the
>> kernel definition.  (Part of the thread descriptor size increase is
>> already offset by reduced stack usage in the thread start wrapper
>> routine after this commit.)
>
> I think this change worth parametrizing it on Linux to save some space
> on the pthread_t structure, since it save about 120 bytes per thread
> and it is unlikely Linux will eventually increase the signal size.

Do you see this as a precondition for this change?

> I think the idea of keeping the fields was that tools that abuse 
> the ABI and access such metadata directly could work across glibc
> versions. However, the C11 thread state already changed the internal
> layout so I don't see much gain on keep this idea.  I would say to 
> just remove the field altogether.

I can certainly do that.

>> +  /* Block alll signals, so that the new thread starts out with
>> +     signals disabled.  This avoids race conditions in the thread
>> +     startup.  */
>
> s/alll/all

Fixed locally.

>> +  sigset_t original_sigmask;
>> +  __libc_signal_block_all (&original_sigmask);
>> +
>> +  /* Conceptually, the new thread needs to inherit the signal mask of
>> +     this thread.  Therefore, it needs to restore the saved signal
>> +     mask of this thread, so save it in the startup information.  */
>> +  pd->sigmask = original_sigmask;
>> +#ifdef SIGCANCEL
>> +  /* Reset the cancellation signal mask in case this thread is running
>> +     cancellation.  */
>> +  __sigdelset (&pd->sigmask, SIGCANCEL);
>> +#endif
>> +
>
> Do we still have a nptl target that does not have SIGCANCEL support?

I don't think so.  I can remove all the #ifdef's and run a build with
build-many-glibcs.py tomorrow.

Thanks,
Florian

  reply	other threads:[~2019-10-17 21:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:33 Florian Weimer
2019-10-14 13:32 ` Christian Brauner
2019-10-15 11:58   ` Florian Weimer
2019-10-15 12:03     ` Christian Brauner
2019-10-17 18:34 ` Adhemerval Zanella
2019-10-17 21:49   ` Florian Weimer [this message]
2019-10-18 12:20     ` Adhemerval Zanella
2019-11-29 11:08 Florian Weimer

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=87eezbvy81.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).