mailing list of musl libc
 help / color / mirror / code / Atom feed
* =?gb18030?B?UmU6IFJlOiBbbXVzbF0gUXVlc3Rpb26juldoeSBtdXNsIGNhbGwgYV9iYXJyaWVyIGluIF9fcHRocmVhZF9vbmNlPw==?=
@ 2023-05-18  2:49 =?gb18030?B?ODQ3NTY3MTYx?=
  2023-05-18 12:23 ` Re: [musl] Question:Why musl call a_barrier in __pthread_once? Szabolcs Nagy
  0 siblings, 1 reply; 7+ messages in thread
From: =?gb18030?B?ODQ3NTY3MTYx?= @ 2023-05-18  2:49 UTC (permalink / raw)
  To: =?gb18030?B?bXVzbA==?=

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 1135 bytes --]

Hi,

> There is an alternate algorithm for pthread_once that doesn't require
> a barrier in the common case, which I've considered implementing. But
> it does need efficient access to thread-local storage. At one time,
> this was a kinda bad assumption (especially legacy mips is horribly
> slow at TLS) but nowadays it's probably the right choice to make, and
> we should check that out again...

1¡¢Can we move dmb after we get the value of control£¿ like this£º

int __pthread_once(pthread_once_t *control, void (*init)(void))
{
    /* Return immediately if init finished before, but ensure that
    * effects of the init routine are visible to the caller. */
    if (*(volatile int *)control == 2) {
        // a_barrier();
        return 0;
    }

    a_barrier();
    return __pthread_once_full(control, init);
}

2¡¢Can we use 'ldar' to  instead of dmb here? I see musl
already use 'stlxr' in a_sc.  like this:

static inline int load(volatile int *p)
{
	int v;
	__asm__ __volatile__ ("ldar %w0,%1" : "=r"(v) : "Q"(*p));
	return v;
}

if (load((volatile int *)control) == 2) {
    return 0;
}

...


Chuang Yin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-05-18 14:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-18  2:49 =?gb18030?B?UmU6IFJlOiBbbXVzbF0gUXVlc3Rpb26juldoeSBtdXNsIGNhbGwgYV9iYXJyaWVyIGluIF9fcHRocmVhZF9vbmNlPw==?= =?gb18030?B?ODQ3NTY3MTYx?=
2023-05-18 12:23 ` Re: [musl] Question:Why musl call a_barrier in __pthread_once? Szabolcs Nagy
2023-05-18 13:29   ` Rich Felker
2023-05-18 14:01     ` Jₑₙₛ Gustedt
2023-05-18 14:08       ` Rich Felker
2023-05-18 14:15     ` Jeffrey Walton
2023-05-18 14:20       ` Rich Felker

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).