mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "罗勇刚(Yonggang Luo)" <luoyonggang@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: Jens Gustedt <jens.gustedt@inria.fr>, enh <enh@google.com>,
	musl@lists.openwall.com
Subject: Re: [musl] [PATCH v3 0/5] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_base c2y/cnd_timedwait_base
Date: Thu, 22 Jun 2023 02:43:54 +0800	[thread overview]
Message-ID: <CAE2XoE8Zh+k07zzg6JPVxO3+WU3dkQL=Yza_obHL1u3WPXwmOw@mail.gmail.com> (raw)
In-Reply-To: <20230621145427.GK4163@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 3944 bytes --]

On Wed, Jun 21, 2023 at 10:54 PM Rich Felker <dalias@libc.org> wrote:
>
> On Wed, Jun 21, 2023 at 02:10:50PM +0800, 罗勇刚(Yonggang Luo) wrote:
> > On Wed, Jun 21, 2023 at 6:47 AM Rich Felker <dalias@libc.org> wrote:
> > >
> > > On Tue, Jun 20, 2023 at 10:36:58PM +0800, Yonggang Luo wrote:
> > > > Currently, musl doesn't have pthread_mutex_clocklock
> > pthread_cond_clockdwait, but
> > > > glibc, android bionic, qnx libc already have these two functions, so
> > implement them in
> > > > musl.
> > > >
> > > > And for c11 threads, the mtx and cnd doesn't support for monotonic
> > timedlock and timedwait;
> > > > So add a proposaled function mtx_timedlock_base cnd_timedwait_base
to
> > do that.
> > > > The protype of these two functions is:
> > > > int mtx_timedlock_base(mtx_t *restrict m, int time_base, const
struct
> > timespec *restrict ts);
> > > > int cnd_timedwait_base(cnd_t *restrict c, mtx_t *restrict m, int
> > time_base, const struct timespec *restrict ts);
> > > > The time_base at least can be TIME_UTC/TIME_MONOTONIC, the
implementer
> > can implement it with any provided
> > > > TIME_* base parameter provided in c2y time.h, if TIME_MONOTONIC can
not
> > natively supported, fallback to TIME_UTC
> > > > should provided, for other TIME_* base parameter, it's implementer's
> > choice.
> > > >
> > > > And indeed mtx_timedlock_base and cnd_timedwait_base  can be
> > implemented ontop of
> > > > posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait, so I
> > implemented
> > > > posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait first in
> > musl.
> > >
> > > Implementation of any function in this family is contingent on
> > > standardization; musl won't add things in a namespace likely to
> > > conflict with future standardization that's not at least already very
> > > far along the road to being standardized.
> > >
> > > I believe the corresponding pthread functions are already on that
> > > path, but the c11-thread-api ones afaik aren't. Adding support for the
> > > former was raised in the past, and the concern was that it may be
> >
> > Do you means the pthread functions is already on the way? where is it
and
>
> It was proposed for standardization as Austin Group issue 1216 -
> http://austingroupbugs.net/view.php?id=1216 - and approved for
> inclusion in future versions of the standard. This means it's pretty
> much automatically something that qualifies for inclusion in musl, so
> it's a TODO item that just hasn't been done yet.
>
> > > adding an extra cost to the existing functions most callers actually
> > > want to use for the sake of a fringe need, in terms of an extra call
> > > frame layer. That can probably be mitigated by lifting the initial
> > > trylock, but doing this in a way that's not a mess and doesn't
> >
> > We can use always_inline to avoid that.
>
> No, because these are separate TUs. But even if you put them in the

What's is TUs, sorry I can not understand it

> same TU to do it, doubling the code size of each affected function is
> not really desirable. Doing that for a single function or small set of
> functions wouldn't really matter, but as a policy it's not done in
> musl because if you did it for *every* function that might potentially
> benefit, the size (and likely performance due to icache considerations
> etc.) cost would be quite high.
>
> At first I thought lifting the trylock but otherwise calling thru to
> the "most general form" (clocklock) was probably the right way to do
> it, but it might just make sense to change lock to call clocklock
> directly instead of calling timedlock and having that in turn call
> clocklock. This way the number of call levels is unchanged for normal
> lock operations, only increased for the classic timedlock.
>
> Rich



--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

[-- Attachment #2: Type: text/html, Size: 4896 bytes --]

  reply	other threads:[~2023-06-21 18:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 14:36 Yonggang Luo
2023-06-20 14:36 ` [musl] [PATCH v3 1/5] trim spaces of pthread_cond_timedwait.c and pthread_mutex_timedlock.c Yonggang Luo
2023-06-20 14:37 ` [musl] [PATCH v3 2/5] Rename files for implement pthread_mutex_clocklock and pthread_cond_clockwait Yonggang Luo
2023-06-20 14:37 ` [musl] [PATCH v3 3/5] add pthread_mutex_clocklock and pthread_cond_clockdwait Yonggang Luo
2023-06-21 15:04   ` Rich Felker
2023-06-20 14:37 ` [musl] [PATCH v3 4/5] c23: Implement newly base for timespec_get Yonggang Luo
2023-06-20 14:37 ` [musl] [PATCH v3 5/5] c2y: Add monotonic timedlock/timedwait support for threads mtx/cnd Yonggang Luo
2023-06-20 22:47 ` [musl] [PATCH v3 0/5] Add posix/pthread_mutex_clocklock posix/pthread_cond_clockdwait c2y/mtx_timedlock_base c2y/cnd_timedwait_base Rich Felker
2023-06-21  6:10   ` 罗勇刚(Yonggang Luo)
2023-06-21 14:54     ` Rich Felker
2023-06-21 18:43       ` 罗勇刚(Yonggang Luo) [this message]
2023-06-21 18:58         ` enh
2023-06-21  6:25   ` 罗勇刚(Yonggang Luo)
2023-06-21 14:44     ` 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='CAE2XoE8Zh+k07zzg6JPVxO3+WU3dkQL=Yza_obHL1u3WPXwmOw@mail.gmail.com' \
    --to=luoyonggang@gmail.com \
    --cc=dalias@libc.org \
    --cc=enh@google.com \
    --cc=jens.gustedt@inria.fr \
    --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).