public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	"H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: [PATCH] nptl: Provide a way to block all signals for the timer helper thread
Date: Thu, 14 May 2020 13:52:17 -0400	[thread overview]
Message-ID: <ccc9cc72-2880-8818-34d9-f468fbd14339@redhat.com> (raw)
In-Reply-To: <871rnp3qvg.fsf@oldenburg2.str.redhat.com>

On 5/12/20 3:17 PM, Florian Weimer wrote:
> * Carlos O'Donell:
> 
>>> +/* Exactly like pthread_create if NEW_SIGMASK == NULL.  Otherwise, do
>>> +   not use the current signal mask for the new thread, but set it to
>>> +   *NEW_SIGMASK instead (without unblocking internal signals).  */


Suggest:

/* Exactly like pthread_create if NEW_SIGMASK is NULL.
   Create the new thread using the thread descriptor at NEWTHREAD,
   and the thread attributes from *ATTR, executing provided START_ROUTINE
   with a single void argument ARG.  The last argument is not present in
   the public API for pthread_create, but is part of the internal glibc API.
   The last argument is the signal mask to be restored in the new thread,
   and is normally NULL, in which case the parent's signal mask is restored
   as mandated by the standard's requirement for pthread_create.  In some cases
   though you may wish to keep certain signals blocked to avoid race cases,
   and today this includes the helper thread created by SIGEV_THREAD where all
   signals are blocked except SIGCANCEL.  Thus the new_sigmask argument is
   primarily intended for the creation of helper threads not user threads.  */

>>> +extern int __pthread_create_internal (pthread_t *newthread,
>>> +				      const pthread_attr_t *attr,
>>> +				      void *(*start_routine) (void *),
>>> +				      void *arg, const sigset_t *new_sigmask);
>>> +#if IS_IN (libpthread)
>>> +hidden_proto (__pthread_create_internal)
>>> +#endif
>>
>> OK.
>>
>>>  
>>>  /* Functions with versioned interfaces.  */
>>>  extern int __pthread_create_2_1 (pthread_t *newthread,
>>> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
>>> index afd379e89a..2430d65723 100644
>>> --- a/nptl/pthread_create.c
>>> +++ b/nptl/pthread_create.c
>>> @@ -603,10 +603,10 @@ report_thread_creation (struct pthread *pd)
>>>    return false;
>>>  }
>>>  
>>> -


>>>  int
>>> -__pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
>>> -		      void *(*start_routine) (void *), void *arg)
>>
>> Could you please provide a detailed explanation of why we have a signal 
>> mask here?
> 
> Why isn't the comment in the header file sufficient?
> 
> I find your requirement puzzling.

I am asking for task oriented documentation for our internal APIs.

Task oriented documentation allows a non-expert to carry out an operation without
the need of an expert.

Simple API documentation lacks sufficient detail for a non-expert to use the API 
and to know what they would need to pass in this argument.

See my suggestion above.

>> Future reviewers of this code will be left wondering why the interface was
>> designed as it is, and that's difficult to explain without a more thorough
>> code audit.
> 
> Hmm.  NULL == use some default is pretty standard?  It's already used
> for the attr argument.

I hope my clarification of task-oriented vs. API helps.

>>> @@ -873,6 +880,15 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
>>>  
>>>    return retval;
>>>  }
>>> +hidden_def (__pthread_create_internal)
>>> +
>>> +int
>>> +__pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr,
>>> +		      void *(*start_routine) (void *), void *arg)
>>> +{
>>> +  return __pthread_create_internal (newthread, attr, start_routine, arg,
>>> +				    false);
>>
>> My preference is to use NULL with an informative cast.
>>
>> Unless you can show existing practice. I'm not a fan of using false
>> like this.
> 
> No, this is an accident.

Perfect.

-- 
Cheers,
Carlos.


  reply	other threads:[~2020-05-14 17:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 15:02 Florian Weimer
2020-05-12 15:03 ` Florian Weimer
2020-05-12 16:09   ` H.J. Lu
2020-05-12 18:38     ` Carlos O'Donell
2020-05-12 19:02 ` Adhemerval Zanella
2020-05-14 15:46   ` Florian Weimer
2020-05-14 17:54     ` Carlos O'Donell
2020-05-12 19:09 ` Carlos O'Donell
2020-05-12 19:17   ` Florian Weimer
2020-05-14 17:52     ` Carlos O'Donell [this message]
2020-05-14 18:30       ` Florian Weimer
2020-05-14 19:33         ` Carlos O'Donell
2020-05-14 20:32           ` Adhemerval Zanella
2020-05-14 20:40             ` Carlos O'Donell
2020-05-19 11:08           ` Florian Weimer
2020-05-13 15:25 ` Carlos O'Donell
2020-05-13 16:22   ` 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=ccc9cc72-2880-8818-34d9-f468fbd14339@redhat.com \
    --to=carlos@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --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).